Commit 7bfec5f3 authored by NeilBrown's avatar NeilBrown

md/raid5: If there is a spare and a want_replacement device, start replacement.

When attempting to add a spare to a RAID[456] array, also consider
adding it as a replacement for a want_replacement device.

This requires that common md code attempt hot_add even when the array
is not formally degraded.
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 17045f52
...@@ -7399,7 +7399,6 @@ static int remove_and_add_spares(struct mddev *mddev) ...@@ -7399,7 +7399,6 @@ static int remove_and_add_spares(struct mddev *mddev)
} }
} }
if (mddev->degraded) {
list_for_each_entry(rdev, &mddev->disks, same_set) { list_for_each_entry(rdev, &mddev->disks, same_set) {
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(In_sync, &rdev->flags) && !test_bit(In_sync, &rdev->flags) &&
...@@ -7418,7 +7417,6 @@ static int remove_and_add_spares(struct mddev *mddev) ...@@ -7418,7 +7417,6 @@ static int remove_and_add_spares(struct mddev *mddev)
} }
} }
} }
}
return spares; return spares;
} }
......
...@@ -5376,8 +5376,9 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev) ...@@ -5376,8 +5376,9 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev)
disk = rdev->saved_raid_disk; disk = rdev->saved_raid_disk;
else else
disk = first; disk = first;
for ( ; disk <= last ; disk++) for ( ; disk <= last ; disk++) {
if ((p=conf->disks + disk)->rdev == NULL) { p = conf->disks + disk;
if (p->rdev == NULL) {
clear_bit(In_sync, &rdev->flags); clear_bit(In_sync, &rdev->flags);
rdev->raid_disk = disk; rdev->raid_disk = disk;
err = 0; err = 0;
...@@ -5386,6 +5387,17 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev) ...@@ -5386,6 +5387,17 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev)
rcu_assign_pointer(p->rdev, rdev); rcu_assign_pointer(p->rdev, rdev);
break; break;
} }
if (test_bit(WantReplacement, &p->rdev->flags) &&
p->replacement == NULL) {
clear_bit(In_sync, &rdev->flags);
set_bit(Replacement, &rdev->flags);
rdev->raid_disk = disk;
err = 0;
conf->fullsync = 1;
rcu_assign_pointer(p->replacement, rdev);
break;
}
}
print_raid5_conf(conf); print_raid5_conf(conf);
return err; return err;
} }
......
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