md: change hot_remove_disk to take an rdev rather than a number.
authorNeilBrown <neilb@suse.de>
Thu, 22 Dec 2011 23:17:51 +0000 (10:17 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 22 Dec 2011 23:17:51 +0000 (10:17 +1100)
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>
drivers/md/md.c
drivers/md/md.h
drivers/md/multipath.c
drivers/md/raid1.c
drivers/md/raid10.c
drivers/md/raid5.c

index d51c688d9c94f73be5305eb512fbaf026e24de8c..0e2288824938c087fba05f1eed2a7412b7af27e4 100644 (file)
@@ -2689,7 +2689,7 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len)
                if (rdev->mddev->pers->hot_remove_disk == NULL)
                        return -EINVAL;
                err = rdev->mddev->pers->
-                       hot_remove_disk(rdev->mddev, rdev->raid_disk);
+                       hot_remove_disk(rdev->mddev, rdev);
                if (err)
                        return err;
                sysfs_unlink_rdev(rdev->mddev, rdev);
@@ -7340,7 +7340,7 @@ static int remove_and_add_spares(struct mddev *mddev)
                     ! test_bit(In_sync, &rdev->flags)) &&
                    atomic_read(&rdev->nr_pending)==0) {
                        if (mddev->pers->hot_remove_disk(
-                                   mddev, rdev->raid_disk)==0) {
+                                   mddev, rdev) == 0) {
                                sysfs_unlink_rdev(mddev, rdev);
                                rdev->raid_disk = -1;
                        }
@@ -7477,7 +7477,7 @@ void md_check_recovery(struct mddev *mddev)
                                    test_bit(Faulty, &rdev->flags) &&
                                    atomic_read(&rdev->nr_pending)==0) {
                                        if (mddev->pers->hot_remove_disk(
-                                                   mddev, rdev->raid_disk)==0) {
+                                                   mddev, rdev) == 0) {
                                                sysfs_unlink_rdev(mddev, rdev);
                                                rdev->raid_disk = -1;
                                        }
index cf742d9306ecc52de68052c9dd0a4164924c2c63..670c10e6b484757d7d201e0768d21e2b5d6b1b36 100644 (file)
@@ -428,7 +428,7 @@ struct md_personality
         */
        void (*error_handler)(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);
        sector_t (*sync_request)(struct mddev *mddev, sector_t sector_nr, int *skipped, int go_faster);
        int (*resize) (struct mddev *mddev, sector_t sectors);
index 5899246fa37eccbff362cdc94f205b183c3b35c9..a222f516660ef4764d36d3a1c930412f315594cc 100644 (file)
@@ -292,17 +292,16 @@ static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev)
        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;
        int err = 0;
-       struct md_rdev *rdev;
+       int number = rdev->raid_disk;
        struct multipath_info *p = conf->multipaths + number;
 
        print_multipath_conf(conf);
 
-       rdev = p->rdev;
-       if (rdev) {
+       if (rdev == p->rdev) {
                if (test_bit(In_sync, &rdev->flags) ||
                    atomic_read(&rdev->nr_pending)) {
                        printk(KERN_ERR "hot-remove-disk, slot %d is identified"
index ede2461e79c51e8d3bd1ac04fcac4c7a974bbbbe..4317f8de143a64e0a4302cc6ab5c992dc9617f85 100644 (file)
@@ -1327,16 +1327,15 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
        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;
        int err = 0;
-       struct md_rdev *rdev;
+       int number = rdev->raid_disk;
        struct mirror_info *p = conf->mirrors+ number;
 
        print_conf(conf);
-       rdev = p->rdev;
-       if (rdev) {
+       if (rdev == p->rdev) {
                if (test_bit(In_sync, &rdev->flags) ||
                    atomic_read(&rdev->nr_pending)) {
                        err = -EBUSY;
index 685ddf325ee43f4492466c34a50a4a836c766e65..f5088dda4dca3527dc13893c8189779dfd53c671 100644 (file)
@@ -1385,16 +1385,15 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
        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;
        int err = 0;
-       struct md_rdev *rdev;
+       int number = rdev->raid_disk;
        struct mirror_info *p = conf->mirrors+ number;
 
        print_conf(conf);
-       rdev = p->rdev;
-       if (rdev) {
+       if (rdev == p->rdev) {
                if (test_bit(In_sync, &rdev->flags) ||
                    atomic_read(&rdev->nr_pending)) {
                        err = -EBUSY;
index a68c49250ed5bb36b69faf7f7aabda2c9f6ec5fb..6b9fc58e8f2de4cdea46b2441fc850d9ea76203e 100644 (file)
@@ -5038,16 +5038,15 @@ static int raid5_spare_active(struct mddev *mddev)
        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;
        int err = 0;
-       struct md_rdev *rdev;
+       int number = rdev->raid_disk;
        struct disk_info *p = conf->disks + number;
 
        print_raid5_conf(conf);
-       rdev = p->rdev;
-       if (rdev) {
+       if (rdev == p->rdev) {
                if (number >= conf->raid_disks &&
                    conf->reshape_progress == MaxSector)
                        clear_bit(In_sync, &rdev->flags);
@@ -5369,7 +5368,8 @@ static void raid5_finish_reshape(struct mddev *mddev)
                             d < conf->raid_disks - mddev->delta_disks;
                             d++) {
                                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);
                                        rdev->raid_disk = -1;
                                }