Commit c19d5798 authored by NeilBrown's avatar NeilBrown

md/raid1: recognise replacements when assembling arrays.

If a Replacement is seen, file it as such.

If we see two replacements (or two normal devices) for the one slot,
abort.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 8c7a2c2b
...@@ -2453,14 +2453,20 @@ static struct r1conf *setup_conf(struct mddev *mddev) ...@@ -2453,14 +2453,20 @@ static struct r1conf *setup_conf(struct mddev *mddev)
conf->poolinfo->mddev = mddev; conf->poolinfo->mddev = mddev;
err = -EINVAL;
spin_lock_init(&conf->device_lock); spin_lock_init(&conf->device_lock);
list_for_each_entry(rdev, &mddev->disks, same_set) { list_for_each_entry(rdev, &mddev->disks, same_set) {
int disk_idx = rdev->raid_disk; int disk_idx = rdev->raid_disk;
if (disk_idx >= mddev->raid_disks if (disk_idx >= mddev->raid_disks
|| disk_idx < 0) || disk_idx < 0)
continue; continue;
if (test_bit(Replacement, &rdev->flags))
disk = conf->mirrors + conf->raid_disks + disk_idx;
else
disk = conf->mirrors + disk_idx; disk = conf->mirrors + disk_idx;
if (disk->rdev)
goto abort;
disk->rdev = rdev; disk->rdev = rdev;
disk->head_position = 0; disk->head_position = 0;
...@@ -2476,11 +2482,27 @@ static struct r1conf *setup_conf(struct mddev *mddev) ...@@ -2476,11 +2482,27 @@ static struct r1conf *setup_conf(struct mddev *mddev)
conf->pending_count = 0; conf->pending_count = 0;
conf->recovery_disabled = mddev->recovery_disabled - 1; conf->recovery_disabled = mddev->recovery_disabled - 1;
err = -EIO;
conf->last_used = -1; conf->last_used = -1;
for (i = 0; i < conf->raid_disks * 2; i++) { for (i = 0; i < conf->raid_disks * 2; i++) {
disk = conf->mirrors + i; disk = conf->mirrors + i;
if (i < conf->raid_disks &&
disk[conf->raid_disks].rdev) {
/* This slot has a replacement. */
if (!disk->rdev) {
/* No original, just make the replacement
* a recovering spare
*/
disk->rdev =
disk[conf->raid_disks].rdev;
disk[conf->raid_disks].rdev = NULL;
} else if (!test_bit(In_sync, &disk->rdev->flags))
/* Original is not in_sync - bad */
goto abort;
}
if (!disk->rdev || if (!disk->rdev ||
!test_bit(In_sync, &disk->rdev->flags)) { !test_bit(In_sync, &disk->rdev->flags)) {
disk->head_position = 0; disk->head_position = 0;
...@@ -2494,7 +2516,6 @@ static struct r1conf *setup_conf(struct mddev *mddev) ...@@ -2494,7 +2516,6 @@ static struct r1conf *setup_conf(struct mddev *mddev)
conf->last_used = i; conf->last_used = i;
} }
err = -EIO;
if (conf->last_used < 0) { if (conf->last_used < 0) {
printk(KERN_ERR "md/raid1:%s: no operational mirrors\n", printk(KERN_ERR "md/raid1:%s: no operational mirrors\n",
mdname(mddev)); mdname(mddev));
......
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