Commit c8ab903e authored by NeilBrown's avatar NeilBrown

md/raid10: allow removal of failed replacement devices.

Enhance raid10_remove_disk to be able to remove ->replacement
as well as ->rdev
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent abbf098e
...@@ -1429,16 +1429,23 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1429,16 +1429,23 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
struct r10conf *conf = mddev->private; struct r10conf *conf = mddev->private;
int err = 0; int err = 0;
int number = rdev->raid_disk; int number = rdev->raid_disk;
struct mirror_info *p = conf->mirrors+ number; struct md_rdev **rdevp;
struct mirror_info *p = conf->mirrors + number;
print_conf(conf); print_conf(conf);
if (rdev == p->rdev) { if (rdev == p->rdev)
rdevp = &p->rdev;
else if (rdev == p->replacement)
rdevp = &p->replacement;
else
return 0;
if (test_bit(In_sync, &rdev->flags) || if (test_bit(In_sync, &rdev->flags) ||
atomic_read(&rdev->nr_pending)) { atomic_read(&rdev->nr_pending)) {
err = -EBUSY; err = -EBUSY;
goto abort; goto abort;
} }
/* Only remove faulty devices in recovery /* Only remove faulty devices if recovery
* is not possible. * is not possible.
*/ */
if (!test_bit(Faulty, &rdev->flags) && if (!test_bit(Faulty, &rdev->flags) &&
...@@ -1447,16 +1454,16 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1447,16 +1454,16 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
err = -EBUSY; err = -EBUSY;
goto abort; goto abort;
} }
p->rdev = NULL; *rdevp = NULL;
synchronize_rcu(); synchronize_rcu();
if (atomic_read(&rdev->nr_pending)) { if (atomic_read(&rdev->nr_pending)) {
/* lost the race, try later */ /* lost the race, try later */
err = -EBUSY; err = -EBUSY;
p->rdev = rdev; *rdevp = rdev;
goto abort; goto abort;
} }
err = md_integrity_register(mddev); err = md_integrity_register(mddev);
}
abort: abort:
print_conf(conf); print_conf(conf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment