Commit b8321b68 authored by NeilBrown's avatar NeilBrown

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: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 476a7abb
...@@ -2689,7 +2689,7 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -2689,7 +2689,7 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len)
if (rdev->mddev->pers->hot_remove_disk == NULL) if (rdev->mddev->pers->hot_remove_disk == NULL)
return -EINVAL; return -EINVAL;
err = rdev->mddev->pers-> err = rdev->mddev->pers->
hot_remove_disk(rdev->mddev, rdev->raid_disk); hot_remove_disk(rdev->mddev, rdev);
if (err) if (err)
return err; return err;
sysfs_unlink_rdev(rdev->mddev, rdev); sysfs_unlink_rdev(rdev->mddev, rdev);
...@@ -7340,7 +7340,7 @@ static int remove_and_add_spares(struct mddev *mddev) ...@@ -7340,7 +7340,7 @@ static int remove_and_add_spares(struct mddev *mddev)
! test_bit(In_sync, &rdev->flags)) && ! test_bit(In_sync, &rdev->flags)) &&
atomic_read(&rdev->nr_pending)==0) { atomic_read(&rdev->nr_pending)==0) {
if (mddev->pers->hot_remove_disk( if (mddev->pers->hot_remove_disk(
mddev, rdev->raid_disk)==0) { mddev, rdev) == 0) {
sysfs_unlink_rdev(mddev, rdev); sysfs_unlink_rdev(mddev, rdev);
rdev->raid_disk = -1; rdev->raid_disk = -1;
} }
...@@ -7477,7 +7477,7 @@ void md_check_recovery(struct mddev *mddev) ...@@ -7477,7 +7477,7 @@ void md_check_recovery(struct mddev *mddev)
test_bit(Faulty, &rdev->flags) && test_bit(Faulty, &rdev->flags) &&
atomic_read(&rdev->nr_pending)==0) { atomic_read(&rdev->nr_pending)==0) {
if (mddev->pers->hot_remove_disk( if (mddev->pers->hot_remove_disk(
mddev, rdev->raid_disk)==0) { mddev, rdev) == 0) {
sysfs_unlink_rdev(mddev, rdev); sysfs_unlink_rdev(mddev, rdev);
rdev->raid_disk = -1; rdev->raid_disk = -1;
} }
......
...@@ -428,7 +428,7 @@ struct md_personality ...@@ -428,7 +428,7 @@ struct md_personality
*/ */
void (*error_handler)(struct mddev *mddev, struct md_rdev *rdev); void (*error_handler)(struct mddev *mddev, struct md_rdev *rdev);
int (*hot_add_disk) (struct mddev *mddev, struct md_rdev *rdev); int (*hot_add_disk) (struct mddev *mddev, struct md_rdev *rdev);
int (*hot_remove_disk) (struct mddev *mddev, int number); int (*hot_remove_disk) (struct mddev *mddev, struct md_rdev *rdev);
int (*spare_active) (struct mddev *mddev); int (*spare_active) (struct mddev *mddev);
sector_t (*sync_request)(struct mddev *mddev, sector_t sector_nr, int *skipped, int go_faster); sector_t (*sync_request)(struct mddev *mddev, sector_t sector_nr, int *skipped, int go_faster);
int (*resize) (struct mddev *mddev, sector_t sectors); int (*resize) (struct mddev *mddev, sector_t sectors);
......
...@@ -292,17 +292,16 @@ static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev) ...@@ -292,17 +292,16 @@ static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev)
return err; return err;
} }
static int multipath_remove_disk(struct mddev *mddev, int number) static int multipath_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
{ {
struct mpconf *conf = mddev->private; struct mpconf *conf = mddev->private;
int err = 0; int err = 0;
struct md_rdev *rdev; int number = rdev->raid_disk;
struct multipath_info *p = conf->multipaths + number; struct multipath_info *p = conf->multipaths + number;
print_multipath_conf(conf); print_multipath_conf(conf);
rdev = p->rdev; if (rdev == p->rdev) {
if (rdev) {
if (test_bit(In_sync, &rdev->flags) || if (test_bit(In_sync, &rdev->flags) ||
atomic_read(&rdev->nr_pending)) { atomic_read(&rdev->nr_pending)) {
printk(KERN_ERR "hot-remove-disk, slot %d is identified" printk(KERN_ERR "hot-remove-disk, slot %d is identified"
......
...@@ -1327,16 +1327,15 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1327,16 +1327,15 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
return err; return err;
} }
static int raid1_remove_disk(struct mddev *mddev, int number) static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
{ {
struct r1conf *conf = mddev->private; struct r1conf *conf = mddev->private;
int err = 0; int err = 0;
struct md_rdev *rdev; int number = rdev->raid_disk;
struct mirror_info *p = conf->mirrors+ number; struct mirror_info *p = conf->mirrors+ number;
print_conf(conf); print_conf(conf);
rdev = p->rdev; if (rdev == p->rdev) {
if (rdev) {
if (test_bit(In_sync, &rdev->flags) || if (test_bit(In_sync, &rdev->flags) ||
atomic_read(&rdev->nr_pending)) { atomic_read(&rdev->nr_pending)) {
err = -EBUSY; err = -EBUSY;
......
...@@ -1385,16 +1385,15 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1385,16 +1385,15 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
return err; return err;
} }
static int raid10_remove_disk(struct mddev *mddev, int number) static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
{ {
struct r10conf *conf = mddev->private; struct r10conf *conf = mddev->private;
int err = 0; int err = 0;
struct md_rdev *rdev; int number = rdev->raid_disk;
struct mirror_info *p = conf->mirrors+ number; struct mirror_info *p = conf->mirrors+ number;
print_conf(conf); print_conf(conf);
rdev = p->rdev; if (rdev == p->rdev) {
if (rdev) {
if (test_bit(In_sync, &rdev->flags) || if (test_bit(In_sync, &rdev->flags) ||
atomic_read(&rdev->nr_pending)) { atomic_read(&rdev->nr_pending)) {
err = -EBUSY; err = -EBUSY;
......
...@@ -5038,16 +5038,15 @@ static int raid5_spare_active(struct mddev *mddev) ...@@ -5038,16 +5038,15 @@ static int raid5_spare_active(struct mddev *mddev)
return count; return count;
} }
static int raid5_remove_disk(struct mddev *mddev, int number) static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
{ {
struct r5conf *conf = mddev->private; struct r5conf *conf = mddev->private;
int err = 0; int err = 0;
struct md_rdev *rdev; int number = rdev->raid_disk;
struct disk_info *p = conf->disks + number; struct disk_info *p = conf->disks + number;
print_raid5_conf(conf); print_raid5_conf(conf);
rdev = p->rdev; if (rdev == p->rdev) {
if (rdev) {
if (number >= conf->raid_disks && if (number >= conf->raid_disks &&
conf->reshape_progress == MaxSector) conf->reshape_progress == MaxSector)
clear_bit(In_sync, &rdev->flags); clear_bit(In_sync, &rdev->flags);
...@@ -5369,7 +5368,8 @@ static void raid5_finish_reshape(struct mddev *mddev) ...@@ -5369,7 +5368,8 @@ static void raid5_finish_reshape(struct mddev *mddev)
d < conf->raid_disks - mddev->delta_disks; d < conf->raid_disks - mddev->delta_disks;
d++) { d++) {
struct md_rdev *rdev = conf->disks[d].rdev; struct md_rdev *rdev = conf->disks[d].rdev;
if (rdev && raid5_remove_disk(mddev, d) == 0) { if (rdev &&
raid5_remove_disk(mddev, rdev) == 0) {
sysfs_unlink_rdev(mddev, rdev); sysfs_unlink_rdev(mddev, rdev);
rdev->raid_disk = -1; rdev->raid_disk = -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment