md: allow degraded raid1 array to resync after an unclean shutdown.
PATCH 1/1 md: allow degraded raid1 array to resync after an unclean shutdown.
In reply to a message not in the archiveThe following is (I think) appropriate for 2.4.30. The bug it fixes can result in data corruption in a fairly unusual circumstance (having a 3 drive raid1 array running in degraded mode, and suffering a system crash).
### Comments for Changeset
If a raid1 array has more than two devices, and not all are working, then it will not resync after an unclean shutdown (as it will think that it should reconstruct a failed drive, and will find there aren't any spares...)
This patch fixes the problem.
Problem found by Mario Holbe <[email protected]> (thanks!)
### Diffstat output
./drivers/md/raid1.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/md/raid1.c renamed from drivers/md/raid1.c~current~ +8 -5
@@ -891,6 +891,8 @@ static int raid1_diskop(mddev_t *mddev,mdp_disk_t *failed_desc, *spare_desc, *added_desc;mdk_rdev_t *spare_rdev, *failed_rdev; +if (conf->resync_mirrors) +return 1 ;/* Cannot do any diskops during a resync */ switch (state) {case DISKOP_SPARE_ACTIVE :
@@ -1333,6 +1335,8 @@ static void raid1syncd (void *data)up (&mddev->recovery_sem);raid1_shrink_buffers (conf); + +md_recover_arrays ();/* incase we are degraded and a spare is available */ }/*
@@ -1741,10 +1745,6 @@ static int raid1_run (mddev_t *mddev) conf->last_used = j; -if (conf->working_disks != sb->raid_disks) { -printk (KERN_ALERT "raid1: md%d, not all disks are operational -- trying to recover array\n" ,mdidx (mddev)); - start_recovery =1 ; - } {const char * name ="raid1d" ;
@@ -1756,7 +1756,7 @@ static int raid1_run (mddev_t *mddev) } } -if (!start_recovery && !(sb->state & (1 <<MD_SB_CLEAN )) && +if (!(sb->state & (1 <<MD_SB_CLEAN )) && (conf->working_disks >1 )) {const char * name ="raid1syncd" ;
@@ -1769,6 +1769,9 @@ static int raid1_run (mddev_t *mddev)printk (START_RESYNC ,mdidx (mddev)); conf->resync_mirrors =1 ;md_wakeup_thread (conf->resync_thread); + }else if (conf->working_disks != sb->raid_disks) { +printk (KERN_ALERT "raid1: md%d, not all disks are operational -- trying to recover array\n" ,mdidx (mddev)); + start_recovery =1 ; }/*
Quoted 4 lines
The following is (I think) appropriate for 2.4.30. The bug it fixes can result in data corruption in a fairly unusual circumstance (having a 3 drive raid1 array running in degraded mode, and suffering a system crash).
What's unusual? Having a 3 drive raid1 array?
It's not unusual for a system to crash after a RAID array gets sent to degraded mode. Happens a lot on a system I administer. Probably caused by a linux-si3112-ide bug which first results in read errors, then (after md has been told to resync) results in a complete system crash...
Another topic:
Just noticed MD usage in a screenshot:
http://linuxdevices.com/files/misc/ravehd_screenshot.png
From this article:
http://linuxdevices.com/news/NS8217660071.html
Just in case anybody cares :-).