summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2008-09-18 16:01:57 +1000
committerNeilBrown <neilb@suse.de>2008-09-18 16:01:57 +1000
commit352452c3648f683d5ee60c62ab243c37af87ada1 (patch)
tree2efef370fef2b2eb51502dae92c63e8c59bf71ec
parentf35f25259279573c6274e2783536c0b0a399bdd4 (diff)
Handle incremental assembly of containers.
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>
-rw-r--r--Incremental.c13
-rw-r--r--mdadm.h8
-rw-r--r--super-ddf.c2
-rw-r--r--super-intel.c2
4 files changed, 23 insertions, 2 deletions
diff --git a/Incremental.c b/Incremental.c
index aa9eb88d..5965dd1f 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -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 a1bd77f2..5bc41e81 100644
--- 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;
diff --git a/super-ddf.c b/super-ddf.c
index 70889dc3..957a1341 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -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 */
diff --git a/super-intel.c b/super-intel.c
index f5c6b09b..cc321825 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -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;
}