diff options
author | NeilBrown <neilb@suse.de> | 2011-12-22 18:17:51 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-12-22 18:17:51 -0500 |
commit | b8321b68d1445f308324517e45fb0a5c2b48e271 (patch) | |
tree | 3fc4c9b253435753d2154d9bd697a7869163c29a | |
parent | 476a7abb9b00adfe6bf70e82800367319ab8078b (diff) |
md: change hot_remove_disk to take an rdev rather than a number.
Soon an array will be able to have multiple devices with the
same raid_disk number (an original and a replacement). So removing
a device based on the number won't work. So pass the actual device
handle instead.
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | drivers/md/md.c | 6 | ||||
-rw-r--r-- | drivers/md/md.h | 2 | ||||
-rw-r--r-- | drivers/md/multipath.c | 7 | ||||
-rw-r--r-- | drivers/md/raid1.c | 7 | ||||
-rw-r--r-- | drivers/md/raid10.c | 7 | ||||
-rw-r--r-- | drivers/md/raid5.c | 10 |
6 files changed, 18 insertions, 21 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index d51c688d9c94..0e2288824938 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -2689,7 +2689,7 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len) | |||
2689 | if (rdev->mddev->pers->hot_remove_disk == NULL) | 2689 | if (rdev->mddev->pers->hot_remove_disk == NULL) |
2690 | return -EINVAL; | 2690 | return -EINVAL; |
2691 | err = rdev->mddev->pers-> | 2691 | err = rdev->mddev->pers-> |
2692 | hot_remove_disk(rdev->mddev, rdev->raid_disk); | 2692 | hot_remove_disk(rdev->mddev, rdev); |
2693 | if (err) | 2693 | if (err) |
2694 | return err; | 2694 | return err; |
2695 | sysfs_unlink_rdev(rdev->mddev, rdev); | 2695 | sysfs_unlink_rdev(rdev->mddev, rdev); |
@@ -7340,7 +7340,7 @@ static int remove_and_add_spares(struct mddev *mddev) | |||
7340 | ! test_bit(In_sync, &rdev->flags)) && | 7340 | ! test_bit(In_sync, &rdev->flags)) && |
7341 | atomic_read(&rdev->nr_pending)==0) { | 7341 | atomic_read(&rdev->nr_pending)==0) { |
7342 | if (mddev->pers->hot_remove_disk( | 7342 | if (mddev->pers->hot_remove_disk( |
7343 | mddev, rdev->raid_disk)==0) { | 7343 | mddev, rdev) == 0) { |
7344 | sysfs_unlink_rdev(mddev, rdev); | 7344 | sysfs_unlink_rdev(mddev, rdev); |
7345 | rdev->raid_disk = -1; | 7345 | rdev->raid_disk = -1; |
7346 | } | 7346 | } |
@@ -7477,7 +7477,7 @@ void md_check_recovery(struct mddev *mddev) | |||
7477 | test_bit(Faulty, &rdev->flags) && | 7477 | test_bit(Faulty, &rdev->flags) && |
7478 | atomic_read(&rdev->nr_pending)==0) { | 7478 | atomic_read(&rdev->nr_pending)==0) { |
7479 | if (mddev->pers->hot_remove_disk( | 7479 | if (mddev->pers->hot_remove_disk( |
7480 | mddev, rdev->raid_disk)==0) { | 7480 | mddev, rdev) == 0) { |
7481 | sysfs_unlink_rdev(mddev, rdev); | 7481 | sysfs_unlink_rdev(mddev, rdev); |
7482 | rdev->raid_disk = -1; | 7482 | rdev->raid_disk = -1; |
7483 | } | 7483 | } |
diff --git a/drivers/md/md.h b/drivers/md/md.h index cf742d9306ec..670c10e6b484 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -428,7 +428,7 @@ struct md_personality | |||
428 | */ | 428 | */ |
429 | void (*error_handler)(struct mddev *mddev, struct md_rdev *rdev); | 429 | void (*error_handler)(struct mddev *mddev, struct md_rdev *rdev); |
430 | int (*hot_add_disk) (struct mddev *mddev, struct md_rdev *rdev); | 430 | int (*hot_add_disk) (struct mddev *mddev, struct md_rdev *rdev); |
431 | int (*hot_remove_disk) (struct mddev *mddev, int number); | 431 | int (*hot_remove_disk) (struct mddev *mddev, struct md_rdev *rdev); |
432 | int (*spare_active) (struct mddev *mddev); | 432 | int (*spare_active) (struct mddev *mddev); |
433 | sector_t (*sync_request)(struct mddev *mddev, sector_t sector_nr, int *skipped, int go_faster); | 433 | sector_t (*sync_request)(struct mddev *mddev, sector_t sector_nr, int *skipped, int go_faster); |
434 | int (*resize) (struct mddev *mddev, sector_t sectors); | 434 | int (*resize) (struct mddev *mddev, sector_t sectors); |
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index 5899246fa37e..a222f516660e 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c | |||
@@ -292,17 +292,16 @@ static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev) | |||
292 | return err; | 292 | return err; |
293 | } | 293 | } |
294 | 294 | ||
295 | static int multipath_remove_disk(struct mddev *mddev, int number) | 295 | static int multipath_remove_disk(struct mddev *mddev, struct md_rdev *rdev) |
296 | { | 296 | { |
297 | struct mpconf *conf = mddev->private; | 297 | struct mpconf *conf = mddev->private; |
298 | int err = 0; | 298 | int err = 0; |
299 | struct md_rdev *rdev; | 299 | int number = rdev->raid_disk; |
300 | struct multipath_info *p = conf->multipaths + number; | 300 | struct multipath_info *p = conf->multipaths + number; |
301 | 301 | ||
302 | print_multipath_conf(conf); | 302 | print_multipath_conf(conf); |
303 | 303 | ||
304 | rdev = p->rdev; | 304 | if (rdev == p->rdev) { |
305 | if (rdev) { | ||
306 | if (test_bit(In_sync, &rdev->flags) || | 305 | if (test_bit(In_sync, &rdev->flags) || |
307 | atomic_read(&rdev->nr_pending)) { | 306 | atomic_read(&rdev->nr_pending)) { |
308 | printk(KERN_ERR "hot-remove-disk, slot %d is identified" | 307 | printk(KERN_ERR "hot-remove-disk, slot %d is identified" |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index ede2461e79c5..4317f8de143a 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1327,16 +1327,15 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev) | |||
1327 | return err; | 1327 | return err; |
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | static int raid1_remove_disk(struct mddev *mddev, int number) | 1330 | static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev) |
1331 | { | 1331 | { |
1332 | struct r1conf *conf = mddev->private; | 1332 | struct r1conf *conf = mddev->private; |
1333 | int err = 0; | 1333 | int err = 0; |
1334 | struct md_rdev *rdev; | 1334 | int number = rdev->raid_disk; |
1335 | struct mirror_info *p = conf->mirrors+ number; | 1335 | struct mirror_info *p = conf->mirrors+ number; |
1336 | 1336 | ||
1337 | print_conf(conf); | 1337 | print_conf(conf); |
1338 | rdev = p->rdev; | 1338 | if (rdev == p->rdev) { |
1339 | if (rdev) { | ||
1340 | if (test_bit(In_sync, &rdev->flags) || | 1339 | if (test_bit(In_sync, &rdev->flags) || |
1341 | atomic_read(&rdev->nr_pending)) { | 1340 | atomic_read(&rdev->nr_pending)) { |
1342 | err = -EBUSY; | 1341 | err = -EBUSY; |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 685ddf325ee4..f5088dda4dca 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -1385,16 +1385,15 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev) | |||
1385 | return err; | 1385 | return err; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | static int raid10_remove_disk(struct mddev *mddev, int number) | 1388 | static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev) |
1389 | { | 1389 | { |
1390 | struct r10conf *conf = mddev->private; | 1390 | struct r10conf *conf = mddev->private; |
1391 | int err = 0; | 1391 | int err = 0; |
1392 | struct md_rdev *rdev; | 1392 | int number = rdev->raid_disk; |
1393 | struct mirror_info *p = conf->mirrors+ number; | 1393 | struct mirror_info *p = conf->mirrors+ number; |
1394 | 1394 | ||
1395 | print_conf(conf); | 1395 | print_conf(conf); |
1396 | rdev = p->rdev; | 1396 | if (rdev == p->rdev) { |
1397 | if (rdev) { | ||
1398 | if (test_bit(In_sync, &rdev->flags) || | 1397 | if (test_bit(In_sync, &rdev->flags) || |
1399 | atomic_read(&rdev->nr_pending)) { | 1398 | atomic_read(&rdev->nr_pending)) { |
1400 | err = -EBUSY; | 1399 | err = -EBUSY; |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index a68c49250ed5..6b9fc58e8f2d 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -5038,16 +5038,15 @@ static int raid5_spare_active(struct mddev *mddev) | |||
5038 | return count; | 5038 | return count; |
5039 | } | 5039 | } |
5040 | 5040 | ||
5041 | static int raid5_remove_disk(struct mddev *mddev, int number) | 5041 | static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev) |
5042 | { | 5042 | { |
5043 | struct r5conf *conf = mddev->private; | 5043 | struct r5conf *conf = mddev->private; |
5044 | int err = 0; | 5044 | int err = 0; |
5045 | struct md_rdev *rdev; | 5045 | int number = rdev->raid_disk; |
5046 | struct disk_info *p = conf->disks + number; | 5046 | struct disk_info *p = conf->disks + number; |
5047 | 5047 | ||
5048 | print_raid5_conf(conf); | 5048 | print_raid5_conf(conf); |
5049 | rdev = p->rdev; | 5049 | if (rdev == p->rdev) { |
5050 | if (rdev) { | ||
5051 | if (number >= conf->raid_disks && | 5050 | if (number >= conf->raid_disks && |
5052 | conf->reshape_progress == MaxSector) | 5051 | conf->reshape_progress == MaxSector) |
5053 | clear_bit(In_sync, &rdev->flags); | 5052 | clear_bit(In_sync, &rdev->flags); |
@@ -5369,7 +5368,8 @@ static void raid5_finish_reshape(struct mddev *mddev) | |||
5369 | d < conf->raid_disks - mddev->delta_disks; | 5368 | d < conf->raid_disks - mddev->delta_disks; |
5370 | d++) { | 5369 | d++) { |
5371 | struct md_rdev *rdev = conf->disks[d].rdev; | 5370 | struct md_rdev *rdev = conf->disks[d].rdev; |
5372 | if (rdev && raid5_remove_disk(mddev, d) == 0) { | 5371 | if (rdev && |
5372 | raid5_remove_disk(mddev, rdev) == 0) { | ||
5373 | sysfs_unlink_rdev(mddev, rdev); | 5373 | sysfs_unlink_rdev(mddev, rdev); |
5374 | rdev->raid_disk = -1; | 5374 | rdev->raid_disk = -1; |
5375 | } | 5375 | } |