]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Handle incremental assembly of containers.
authorNeilBrown <neilb@suse.de>
Thu, 18 Sep 2008 06:01:57 +0000 (16:01 +1000)
committerNeilBrown <neilb@suse.de>
Thu, 18 Sep 2008 06:01:57 +0000 (16:01 +1000)
 mdadm -I /dev/part-of-container

should add that to a container, creating if it needed,
and then try to assemble any arrays in the container.

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

index aa9eb88dbf8fb652fad2787dc6af0757f2acb901..5965dd1f65bae33351f99373babdcbd7a563a1f2 100644 (file)
@@ -56,6 +56,7 @@ int Incremental(char *devname, int verbose, int runstop,
         * - Choose a free, high number.
         * - Use a partitioned device unless strong suggestion not to.
         *         e.g. auto=md
+        *   Don't choose partitioned for containers.
         * 5/ Find out if array already exists
         * 5a/ if it does not
         * - choose a name, from mdadm.conf or 'name' field in array.
@@ -67,6 +68,7 @@ int Incremental(char *devname, int verbose, int runstop,
         * - add the device
         * 6/ Make sure /var/run/mdadm.map contains this array.
         * 7/ Is there enough devices to possibly start the array?
+        *     For a container, this means running Incremental_container.
         * 7a/ if not, finish with success.
         * 7b/ if yes,
         * - read all metadata and arrange devices like -A does
@@ -90,7 +92,7 @@ int Incremental(char *devname, int verbose, int runstop,
        if (autof == 0)
                autof = ci->autof;
 
-       /* 1/ Check if devices is permitted by mdadm.conf */
+       /* 1/ Check if device is permitted by mdadm.conf */
 
        if (!conf_test_dev(devname)) {
                if (verbose >= 0)
@@ -142,7 +144,7 @@ int Incremental(char *devname, int verbose, int runstop,
        }
        close (dfd);
 
-       if (st->ss->container_content) {
+       if (st->ss->container_content && st->loaded_container) {
                /* This is a pre-built container array, so we do something
                 * rather different.
                 */
@@ -241,6 +243,8 @@ int Incremental(char *devname, int verbose, int runstop,
                char *nm, nbuf[1024];
                if ((autof&7) == 3 || (autof&7) == 5)
                        use_partitions = 0;
+               if (st->ss->external)
+                       use_partitions = 0;
                np = strchr(info.name, ':');
                if (np)
                        np++;
@@ -399,6 +403,11 @@ int Incremental(char *devname, int verbose, int runstop,
 
        /* 7/ Is there enough devices to possibly start the array? */
        /* 7a/ if not, finish with success. */
+       if (info.array.level == LEVEL_CONTAINER) {
+               /* Try to assemble within the container */
+               return Incremental(chosen_name, verbose, runstop,
+                                  NULL, homehost, autof);
+       }
        avail = NULL;
        active_disks = count_active(st, mdfd, &avail, &info);
        if (enough(info.array.level, info.array.raid_disks,
diff --git a/mdadm.h b/mdadm.h
index a1bd77f2d6c6c6e76913555e302ab4d3704de929..5bc41e81d3bbd8fc6b3ef46d3a7b4d13028a74a4 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -587,6 +587,12 @@ struct metadata_update {
  * metadata read in or created is stored in 'sb' and 'info'.
  * There are also fields used by mdmon to track containers.
  *
+ * A supertype may refer to:
+ *   Just an array, possibly in a container
+ *   A container, not identifying any particular array
+ *   Info read from just one device, not yet fully describing the array/container.
+ *
+ *
  * A supertype is created by:
  *   super_by_fd
  *   guess_super
@@ -600,6 +606,8 @@ struct supertype {
        char subarray[32];      /* name of array inside container */
        void *sb;
        void *info;
+       int loaded_container;   /* Set if load_super found a container,
+                                * not just one device */
 
        struct metadata_update *updates;
        struct metadata_update **update_tail;
index 70889dc388ee2be5973b2b5c8bb78b6ba7e76c01..957a13414194331dca890f417e360df89750f20c 100644 (file)
@@ -814,6 +814,7 @@ static int load_super_ddf(struct supertype *st, int fd,
                st->minor_version = 0;
                st->max_devs = 512;
        }
+       st->loaded_container = 0;
        return 0;
 
 }
@@ -2562,6 +2563,7 @@ static int load_super_ddf_all(struct supertype *st, int fd,
                st->max_devs = 512;
                st->container_dev = fd2devnum(fd);
        }
+       st->loaded_container = 1;
        return 0;
 }
 #endif /* MDASSEMBLE */
index f5c6b09b93a5b464fa93319316130e3eaa2baf21..cc32182514577bd953f99a5dfda1e8f506b5bae8 100644 (file)
@@ -1360,6 +1360,7 @@ static int load_super_imsm_all(struct supertype *st, int fd, void **sbp,
                st->minor_version = 0;
                st->max_devs = IMSM_MAX_DEVICES;
        }
+       st->loaded_container = 1;
 
        return 0;
 }
@@ -1402,6 +1403,7 @@ static int load_super_imsm(struct supertype *st, int fd, char *devname)
                st->minor_version = 0;
                st->max_devs = IMSM_MAX_DEVICES;
        }
+       st->loaded_container = 0;
 
        return 0;
 }