Commit 657e3e4d authored by NeilBrown's avatar NeilBrown

md/raid5: allow removal for failed replacement devices.

Enhance raid5_remove_disk to be able to remove ->replacement
as well as ->rdev.
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 14a75d3e
...@@ -5086,36 +5086,42 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev) ...@@ -5086,36 +5086,42 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
struct r5conf *conf = mddev->private; struct r5conf *conf = mddev->private;
int err = 0; int err = 0;
int number = rdev->raid_disk; int number = rdev->raid_disk;
struct md_rdev **rdevp;
struct disk_info *p = conf->disks + number; struct disk_info *p = conf->disks + number;
print_raid5_conf(conf); print_raid5_conf(conf);
if (rdev == p->rdev) { if (rdev == p->rdev)
if (number >= conf->raid_disks && rdevp = &p->rdev;
conf->reshape_progress == MaxSector) else if (rdev == p->replacement)
clear_bit(In_sync, &rdev->flags); rdevp = &p->replacement;
else
return 0;
if (test_bit(In_sync, &rdev->flags) || if (number >= conf->raid_disks &&
atomic_read(&rdev->nr_pending)) { conf->reshape_progress == MaxSector)
err = -EBUSY; clear_bit(In_sync, &rdev->flags);
goto abort;
} if (test_bit(In_sync, &rdev->flags) ||
/* Only remove non-faulty devices if recovery atomic_read(&rdev->nr_pending)) {
* isn't possible. err = -EBUSY;
*/ goto abort;
if (!test_bit(Faulty, &rdev->flags) && }
mddev->recovery_disabled != conf->recovery_disabled && /* Only remove non-faulty devices if recovery
!has_failed(conf) && * isn't possible.
number < conf->raid_disks) { */
err = -EBUSY; if (!test_bit(Faulty, &rdev->flags) &&
goto abort; mddev->recovery_disabled != conf->recovery_disabled &&
} !has_failed(conf) &&
p->rdev = NULL; number < conf->raid_disks) {
synchronize_rcu(); err = -EBUSY;
if (atomic_read(&rdev->nr_pending)) { goto abort;
/* lost the race, try later */ }
err = -EBUSY; *rdevp = NULL;
p->rdev = rdev; synchronize_rcu();
} if (atomic_read(&rdev->nr_pending)) {
/* lost the race, try later */
err = -EBUSY;
*rdevp = rdev;
} }
abort: abort:
......
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