diff options
-rw-r--r-- | drivers/md/raid1.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 6df0c41578af..e3cfca7cde16 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1315,8 +1315,9 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev) | |||
1315 | if (rdev->raid_disk >= 0) | 1315 | if (rdev->raid_disk >= 0) |
1316 | first = last = rdev->raid_disk; | 1316 | first = last = rdev->raid_disk; |
1317 | 1317 | ||
1318 | for (mirror = first; mirror <= last; mirror++) | 1318 | for (mirror = first; mirror <= last; mirror++) { |
1319 | if ( !(p=conf->mirrors+mirror)->rdev) { | 1319 | p = conf->mirrors+mirror; |
1320 | if (!p->rdev) { | ||
1320 | 1321 | ||
1321 | disk_stack_limits(mddev->gendisk, rdev->bdev, | 1322 | disk_stack_limits(mddev->gendisk, rdev->bdev, |
1322 | rdev->data_offset << 9); | 1323 | rdev->data_offset << 9); |
@@ -1343,6 +1344,18 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev) | |||
1343 | rcu_assign_pointer(p->rdev, rdev); | 1344 | rcu_assign_pointer(p->rdev, rdev); |
1344 | break; | 1345 | break; |
1345 | } | 1346 | } |
1347 | if (test_bit(WantReplacement, &p->rdev->flags) && | ||
1348 | p[conf->raid_disks].rdev == NULL) { | ||
1349 | /* Add this device as a replacement */ | ||
1350 | clear_bit(In_sync, &rdev->flags); | ||
1351 | set_bit(Replacement, &rdev->flags); | ||
1352 | rdev->raid_disk = mirror; | ||
1353 | err = 0; | ||
1354 | conf->fullsync = 1; | ||
1355 | rcu_assign_pointer(p[conf->raid_disks].rdev, rdev); | ||
1356 | break; | ||
1357 | } | ||
1358 | } | ||
1346 | md_integrity_add_rdev(rdev, mddev); | 1359 | md_integrity_add_rdev(rdev, mddev); |
1347 | print_conf(conf); | 1360 | print_conf(conf); |
1348 | return err; | 1361 | return err; |