aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-06-17 03:48:26 -0400
committerNeilBrown <neilb@suse.de>2010-06-23 23:36:04 -0400
commit3424bf6a772cff606fc4bc24a3639c937afb547f (patch)
treebe299de834e0f939d19665efec4cacadd74c4914 /drivers/md
parent2f115882499f3e5eca33d1df07b8876cc752a1ff (diff)
md/raid5: don't include 'spare' drives when reshaping to fewer devices.
There are few situations where it would make any sense to add a spare when reducing the number of devices in an array, but it is conceivable: A 6 drive RAID6 with two missing devices could be reshaped to a 5 drive RAID6, and a spare could become available just in time for the reshape, but not early enough to have been recovered first. 'freezing' recovery can make this easy to do without any races. However doing such a thing is a bad idea. md will not record the partially-recovered state of the 'spare' and when the reshape finished it will think that the spare is still spare. Easiest way to avoid this confusion is to simply disallow it. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/raid5.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 66cd47973398..96c690279fc6 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5526,8 +5526,13 @@ static int raid5_start_reshape(mddev_t *mddev)
5526 5526
5527 /* Add some new drives, as many as will fit. 5527 /* Add some new drives, as many as will fit.
5528 * We know there are enough to make the newly sized array work. 5528 * We know there are enough to make the newly sized array work.
5529 * Don't add devices if we are reducing the number of
5530 * devices in the array. This is because it is not possible
5531 * to correctly record the "partially reconstructed" state of
5532 * such devices during the reshape and confusion could result.
5529 */ 5533 */
5530 list_for_each_entry(rdev, &mddev->disks, same_set) 5534 if (mddev->delta_disks >= 0)
5535 list_for_each_entry(rdev, &mddev->disks, same_set)
5531 if (rdev->raid_disk < 0 && 5536 if (rdev->raid_disk < 0 &&
5532 !test_bit(Faulty, &rdev->flags)) { 5537 !test_bit(Faulty, &rdev->flags)) {
5533 if (raid5_add_disk(mddev, rdev) == 0) { 5538 if (raid5_add_disk(mddev, rdev) == 0) {
@@ -5549,7 +5554,7 @@ static int raid5_start_reshape(mddev_t *mddev)
5549 } 5554 }
5550 5555
5551 /* When a reshape changes the number of devices, ->degraded 5556 /* When a reshape changes the number of devices, ->degraded
5552 * is measured against the large of the pre and post number of 5557 * is measured against the larger of the pre and post number of
5553 * devices.*/ 5558 * devices.*/
5554 if (mddev->delta_disks > 0) { 5559 if (mddev->delta_disks > 0) {
5555 spin_lock_irqsave(&conf->device_lock, flags); 5560 spin_lock_irqsave(&conf->device_lock, flags);