diff options
author | NeilBrown <neilb@suse.de> | 2011-12-22 18:17:57 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-12-22 18:17:57 -0500 |
commit | 7ef449d1ec3668acbba6af6a500d0c84636b436f (patch) | |
tree | 4a9e23c9b88f404e896ba8748bdc7bb2b18ec65c /drivers/md | |
parent | c19d57980b38a5bb613a898937a1cf85f422fb9b (diff) |
md/raid1: If there is a spare and a want_replacement device, start replacement.
When attempting to add a spare to a RAID1 array, also consider
adding it as a replacement for a want_replacement device.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-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; |