md/raid1: Allow a failed replacement device to be removed.
authorNeilBrown <neilb@suse.de>
Thu, 22 Dec 2011 23:17:56 +0000 (10:17 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 22 Dec 2011 23:17:56 +0000 (10:17 +1100)
Replacement devices are stored at a different offset, so look
there too.

Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/raid1.c

index e7768e37f36a363d810d22ee44f84f1aea7a8f4b..3d9aa0c928217150d3fc25c0b69f10b2b0908452 100644 (file)
@@ -1336,6 +1336,9 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
        int number = rdev->raid_disk;
        struct mirror_info *p = conf->mirrors+ number;
 
+       if (rdev != p->rdev)
+               p = conf->mirrors + conf->raid_disks + number;
+
        print_conf(conf);
        if (rdev == p->rdev) {
                if (test_bit(In_sync, &rdev->flags) ||
@@ -1359,6 +1362,9 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
                        err = -EBUSY;
                        p->rdev = rdev;
                        goto abort;
+               } else {
+                       clear_bit(Replacement, &rdev->flags);
+                       clear_bit(WantReplacement, &rdev->flags);
                }
                err = md_integrity_register(mddev);
        }