]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Make child_monitor a candidate for ->manage_reshape
authorNeilBrown <neilb@suse.de>
Wed, 12 Jan 2011 03:46:17 +0000 (14:46 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 12 Jan 2011 03:46:17 +0000 (14:46 +1100)
Child_monitor was design to perform 'manage_reshape' for native
arrays.  So change the signature for ->manage_reshape to match
child_monitor and move the all to the same place that child_monitor
is called from.

Also give super-intel a manage_reshape handler which simple calls
child_monitor.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow.c
mdadm.h
mdmon.c
super-intel.c

diff --git a/Grow.c b/Grow.c
index 81ecb97cbfedb7c1d22ec94a65c235145b969db8..9edd4c71942d2fc3ba91aeb368f24185c7e0484f 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -867,30 +867,6 @@ unsigned long compute_backup_blocks(int nchunk, int ochunk,
        return blocks;
 }
 
-/* 'struct reshape' records the intermediate states
- * a general reshape.
- * The starting geometry is converted to the 'before' geometry
- * by at most an atomic level change. They could be the same.
- * Similarly the 'after' geometry is converted to the final
- * geometry by at most a level change.
- * Note that 'before' and 'after' must have the same level.
- * 'blocks' is the minimum number of sectors for a reshape unit.
- * This will be a multiple of the stripe size in each of the
- * 'before' and 'after' geometries.
- * If 'blocks' is 0, no restriping is necessary.
- */
-struct reshape {
-       int level;
-       int parity; /* number of parity blocks/devices */
-       struct {
-               int layout;
-               int data_disks;
-       } before, after;
-       unsigned long long backup_blocks;
-       unsigned long long stripes; /* number of old stripes that comprise 'blocks'*/
-       unsigned long long new_size; /* New size of array in sectors */
-};
-
 char *analyse_change(struct mdinfo *info, struct reshape *re)
 {
        /* Based on the current array state in info->array and
@@ -1277,11 +1253,6 @@ static int reshape_container(char *container, int cfd, char *devname,
                             int force,
                             char *backup_file,
                             int quiet);
-static int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
-                        struct supertype *st, unsigned long stripes,
-                        int *fds, unsigned long long *offsets,
-                        int dests, int *destfd, unsigned long long *destoffsets);
-
 
 int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
                 long long size,
@@ -1944,14 +1915,6 @@ static int reshape_array(char *container, int fd, char *devname,
        }
 
        start_reshape(sra);
-       if (st->ss->external) {
-               /* metadata handler takes it from here */
-               ping_manager(container);
-               st->ss->manage_reshape(st, backup_file);
-               frozen = 0;
-               goto release;
-       }
-
 
        /* Now we just need to kick off the reshape and watch, while
         * handling backups of the data...
@@ -1968,9 +1931,19 @@ static int reshape_array(char *container, int fd, char *devname,
 
                odisks = reshape.before.data_disks + reshape.parity;
 
-               done = child_monitor(fd, sra, &reshape, st, blocks,
-                                    fdlist, offsets,
-                                    d - odisks, fdlist+odisks, offsets+odisks);
+               if (st->ss->external) {
+                       /* metadata handler takes it from here */
+                       done = st->ss->manage_reshape(
+                               fd, sra, &reshape, st, blocks,
+                               fdlist, offsets,
+                               d - odisks, fdlist+odisks,
+                               offsets+odisks);
+               } else
+                       done = child_monitor(
+                               fd, sra, &reshape, st, blocks,
+                               fdlist, offsets,
+                               d - odisks, fdlist+odisks,
+                               offsets+odisks);
 
                if (backup_file && done)
                        unlink(backup_file);
@@ -2692,10 +2665,10 @@ static void validate(int afd, int bfd, unsigned long long offset)
        }
 }
 
-static int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
-                        struct supertype *st, unsigned long blocks,
-                        int *fds, unsigned long long *offsets,
-                        int dests, int *destfd, unsigned long long *destoffsets)
+int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
+                 struct supertype *st, unsigned long blocks,
+                 int *fds, unsigned long long *offsets,
+                 int dests, int *destfd, unsigned long long *destoffsets)
 {
        /* Monitor a reshape where backup is being performed using
         * 'native' mechanism - either to a backup file, or
diff --git a/mdadm.h b/mdadm.h
index aaa8cf011375373ecdea710b90728ac55f2c2ff6..f67120e5865b8adc36c68c64b71f529394b026db 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -521,6 +521,31 @@ extern char *map_dev(int major, int minor, int create);
 struct active_array;
 struct metadata_update;
 
+
+/* 'struct reshape' records the intermediate states
+ * a general reshape.
+ * The starting geometry is converted to the 'before' geometry
+ * by at most an atomic level change. They could be the same.
+ * Similarly the 'after' geometry is converted to the final
+ * geometry by at most a level change.
+ * Note that 'before' and 'after' must have the same level.
+ * 'blocks' is the minimum number of sectors for a reshape unit.
+ * This will be a multiple of the stripe size in each of the
+ * 'before' and 'after' geometries.
+ * If 'blocks' is 0, no restriping is necessary.
+ */
+struct reshape {
+       int level;
+       int parity; /* number of parity blocks/devices */
+       struct {
+               int layout;
+               int data_disks;
+       } before, after;
+       unsigned long long backup_blocks;
+       unsigned long long stripes; /* number of old stripes that comprise 'blocks'*/
+       unsigned long long new_size; /* New size of array in sectors */
+};
+
 /* A superswitch provides entry point the a metadata handler.
  *
  * The super_switch primarily operates on some "metadata" that
@@ -693,7 +718,11 @@ extern struct superswitch {
        int (*reshape_super)(struct supertype *st, long long size, int level,
                             int layout, int chunksize, int raid_disks,
                             char *backup, char *dev, int verbose); /* optional */
-       int (*manage_reshape)(struct supertype *st, char *backup); /* optional */
+       int (*manage_reshape)( /* optional */
+               int afd, struct mdinfo *sra, struct reshape *reshape,
+               struct supertype *st, unsigned long blocks,
+               int *fds, unsigned long long *offsets,
+               int dests, int *destfd, unsigned long long *destoffsets);
 
 /* for mdmon */
        int (*open_new)(struct supertype *c, struct active_array *a,
@@ -1141,6 +1170,11 @@ extern int check_env(char *name);
 extern __u32 random32(void);
 extern int start_mdmon(int devnum);
 
+extern int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
+                        struct supertype *st, unsigned long stripes,
+                        int *fds, unsigned long long *offsets,
+                        int dests, int *destfd, unsigned long long *destoffsets);
+
 extern char *devnum2devname(int num);
 extern void fmt_devname(char *name, int num);
 extern int devname2devnum(char *name);
diff --git a/mdmon.c b/mdmon.c
index f56e57f320ebf3e061bef58625012a6bbae1fc8e..1f39f165d620035aebc06112a7ee872ceb34269b 100644 (file)
--- a/mdmon.c
+++ b/mdmon.c
@@ -517,3 +517,12 @@ static int mdmon(char *devname, int devnum, int must_fork, int takeover)
 
        exit(0);
 }
+
+/* Some stub functions so super-* can link with us */
+int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
+                 struct supertype *st, unsigned long blocks,
+                 int *fds, unsigned long long *offsets,
+                 int dests, int *destfd, unsigned long long *destoffsets)
+{
+       return 0;
+}
index d70a7df15b87af3db87f25b35024e24b6ea23b8f..d62e6b75574e8e5f8f89ed350b160a11382c947c 100644 (file)
@@ -6633,6 +6633,18 @@ exit_imsm_reshape_super:
        return ret_val;
 }
 
+static int imsm_manage_reshape(
+       int afd, struct mdinfo *sra, struct reshape *reshape,
+       struct supertype *st, unsigned long stripes,
+       int *fds, unsigned long long *offsets,
+       int dests, int *destfd, unsigned long long *destoffsets)
+{
+       /* Just use child_monitor for now */
+       return child_monitor(
+               afd, sra, reshape, st, stripes,
+               fds, offsets, dests, destfd, destoffsets);
+}
+
 struct superswitch super_imsm = {
 #ifndef        MDASSEMBLE
        .examine_super  = examine_super_imsm,
@@ -6670,6 +6682,7 @@ struct superswitch super_imsm = {
        .default_geometry = default_geometry_imsm,
        .get_disk_controller_domain = imsm_get_disk_controller_domain,
        .reshape_super  = imsm_reshape_super,
+       .manage_reshape = imsm_manage_reshape,
 
        .external       = 1,
        .name = "imsm",