From: NeilBrown Date: Fri, 9 Dec 2011 03:27:07 +0000 (+1100) Subject: md/raid10: recognise replacements when assembling array. X-Git-Tag: next-20111212~39^2~8 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=99f35e0d85c9dbdfdcf5b6dc7f4cce6295a9dfd8;p=karo-tx-linux.git md/raid10: recognise replacements when assembling array. 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 --- diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 7d3d34f6c246..e1b029fd2269 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -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); @@ -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;