Skip to content

Commit

Permalink
md/raid10: recognise replacements when assembling array.
Browse files Browse the repository at this point in the history
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: NeilBrown <neilb@suse.de>
  • Loading branch information
neilbrown committed Dec 22, 2011
1 parent 4ca40c2 commit 56a2559
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/md/raid10.c
Expand Up @@ -3201,6 +3201,16 @@ static int run(struct mddev *mddev)
continue;
disk = conf->mirrors + disk_idx;

if (test_bit(Replacement, &rdev->flags)) {
if (disk->replacement)
goto out_free_conf;
disk->replacement = rdev;
} else {
if (disk->rdev)
goto out_free_conf;
disk->rdev = rdev;
}

disk->rdev = rdev;
disk_stack_limits(mddev->gendisk, rdev->bdev,
rdev->data_offset << 9);
Expand Down Expand Up @@ -3228,6 +3238,13 @@ static int run(struct mddev *mddev)

disk = conf->mirrors + i;

if (!disk->rdev && disk->replacement) {
/* The replacement is all we have - use it */
disk->rdev = disk->replacement;
disk->replacement = NULL;
clear_bit(Replacement, &disk->rdev->flags);
}

if (!disk->rdev ||
!test_bit(In_sync, &disk->rdev->flags)) {
disk->head_position = 0;
Expand Down

0 comments on commit 56a2559

Please sign in to comment.