md: merge reconfig and check_reshape methods.
authorNeilBrown <neilb@suse.de>
Wed, 17 Jun 2009 22:47:55 +0000 (08:47 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 17 Jun 2009 22:47:55 +0000 (08:47 +1000)
The difference between these two methods is artificial.
Both check that a pending reshape is valid, and perform any
aspect of it that can be done immediately.
'reconfig' handles chunk size and layout.
'check_reshape' handles raid_disks.

So make them just one method.

Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/faulty.c
drivers/md/md.c
drivers/md/md.h
drivers/md/raid5.c

index 6513b7b3e37921b0c39882a4d7249538763c4412..6e83b38d931d6be62ad51e2855cf6008373abf80 100644 (file)
@@ -255,7 +255,7 @@ static void status(struct seq_file *seq, mddev_t *mddev)
 }
 
 
-static int reconfig(mddev_t *mddev)
+static int reshape(mddev_t *mddev)
 {
        int mode = mddev->new_layout & ModeMask;
        int count = mddev->new_layout >> ModeShift;
@@ -316,7 +316,7 @@ static int run(mddev_t *mddev)
        md_set_array_sectors(mddev, faulty_size(mddev, 0, 0));
        mddev->private = conf;
 
-       reconfig(mddev);
+       reshape(mddev);
 
        return 0;
 }
@@ -339,7 +339,7 @@ static struct mdk_personality faulty_personality =
        .run            = run,
        .stop           = stop,
        .status         = status,
-       .reconfig       = reconfig,
+       .check_reshape  = reshape,
        .size           = faulty_size,
 };
 
index 5caa421c2367b5928835172a62eaed5d71effc08..80f039ec3ac21cc7d2da43e4a90210a1a7c74e39 100644 (file)
@@ -2807,10 +2807,10 @@ layout_store(mddev_t *mddev, const char *buf, size_t len)
 
        if (mddev->pers) {
                int err;
-               if (mddev->pers->reconfig == NULL)
+               if (mddev->pers->check_reshape == NULL)
                        return -EBUSY;
                mddev->new_layout = n;
-               err = mddev->pers->reconfig(mddev);
+               err = mddev->pers->check_reshape(mddev);
                if (err) {
                        mddev->new_layout = mddev->layout;
                        return err;
@@ -2885,10 +2885,10 @@ chunk_size_store(mddev_t *mddev, const char *buf, size_t len)
 
        if (mddev->pers) {
                int err;
-               if (mddev->pers->reconfig == NULL)
+               if (mddev->pers->check_reshape == NULL)
                        return -EBUSY;
                mddev->new_chunk_sectors = n >> 9;
-               err = mddev->pers->reconfig(mddev);
+               err = mddev->pers->check_reshape(mddev);
                if (err) {
                        mddev->new_chunk_sectors = mddev->chunk_sectors;
                        return err;
@@ -5224,11 +5224,11 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
                 * we don't need to do anything at the md level, the
                 * personality will take care of it all.
                 */
-               if (mddev->pers->reconfig == NULL)
+               if (mddev->pers->check_reshape == NULL)
                        return -EINVAL;
                else {
                        mddev->new_layout = info->layout;
-                       rv = mddev->pers->reconfig(mddev);
+                       rv = mddev->pers->check_reshape(mddev);
                        if (rv)
                                mddev->new_layout = mddev->layout;
                        return rv;
@@ -6731,7 +6731,8 @@ void md_check_recovery(mddev_t *mddev)
                 */
 
                if (mddev->reshape_position != MaxSector) {
-                       if (mddev->pers->check_reshape(mddev) != 0)
+                       if (mddev->pers->check_reshape == NULL ||
+                           mddev->pers->check_reshape(mddev) != 0)
                                /* Cannot proceed */
                                goto unlock;
                        set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
index 815013f8da6c5424a863babf5bf701e8f94f3fdd..bac7c2bf8616a9e900b630d5ee302f30b5994dd7 100644 (file)
@@ -326,7 +326,6 @@ struct mdk_personality
        int (*check_reshape) (mddev_t *mddev);
        int (*start_reshape) (mddev_t *mddev);
        void (*finish_reshape) (mddev_t *mddev);
-       int (*reconfig) (mddev_t *mddev);
        /* quiesce moves between quiescence states
         * 0 - fully active
         * 1 - no new requests allowed
index 136051bc6725aeb5d9b1117a2ffc73d2e556d68a..5ea2bdece278f34c190b87a65124a7febf65413d 100644 (file)
@@ -4868,14 +4868,14 @@ static int check_stripe_cache(mddev_t *mddev)
        return 1;
 }
 
-static int raid5_check_reshape(mddev_t *mddev)
+static int check_reshape(mddev_t *mddev)
 {
        raid5_conf_t *conf = mddev->private;
 
        if (mddev->delta_disks == 0 &&
            mddev->new_layout == mddev->layout &&
            mddev->new_chunk_sectors == mddev->chunk_sectors)
-               return -EINVAL; /* nothing to do */
+               return 0; /* nothing to do */
        if (mddev->bitmap)
                /* Cannot grow a bitmap yet */
                return -EBUSY;
@@ -5165,7 +5165,7 @@ static void *raid5_takeover_raid6(mddev_t *mddev)
 }
 
 
-static int raid5_reconfig(mddev_t *mddev)
+static int raid5_check_reshape(mddev_t *mddev)
 {
        /* For a 2-drive array, the layout and chunk size can be changed
         * immediately as not restriping is needed.
@@ -5202,12 +5202,13 @@ static int raid5_reconfig(mddev_t *mddev)
                set_bit(MD_CHANGE_DEVS, &mddev->flags);
                md_wakeup_thread(mddev->thread);
        }
-       return 0;
+       return check_reshape(mddev);
 }
 
-static int raid6_reconfig(mddev_t *mddev)
+static int raid6_check_reshape(mddev_t *mddev)
 {
        int new_chunk = mddev->new_chunk_sectors;
+
        if (mddev->new_layout >= 0 && !algorithm_valid_raid6(mddev->new_layout))
                return -EINVAL;
        if (new_chunk > 0) {
@@ -5221,7 +5222,7 @@ static int raid6_reconfig(mddev_t *mddev)
        }
 
        /* They look valid */
-       return 0;
+       return check_reshape(mddev);
 }
 
 static void *raid5_takeover(mddev_t *mddev)
@@ -5312,12 +5313,11 @@ static struct mdk_personality raid6_personality =
        .sync_request   = sync_request,
        .resize         = raid5_resize,
        .size           = raid5_size,
-       .check_reshape  = raid5_check_reshape,
+       .check_reshape  = raid6_check_reshape,
        .start_reshape  = raid5_start_reshape,
        .finish_reshape = raid5_finish_reshape,
        .quiesce        = raid5_quiesce,
        .takeover       = raid6_takeover,
-       .reconfig       = raid6_reconfig,
 };
 static struct mdk_personality raid5_personality =
 {
@@ -5340,7 +5340,6 @@ static struct mdk_personality raid5_personality =
        .finish_reshape = raid5_finish_reshape,
        .quiesce        = raid5_quiesce,
        .takeover       = raid5_takeover,
-       .reconfig       = raid5_reconfig,
 };
 
 static struct mdk_personality raid4_personality =