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>
This commit is contained in:
NeilBrown 2008-09-18 16:01:57 +10:00
parent f35f252592
commit 352452c364
4 changed files with 23 additions and 2 deletions

View 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,

View File

@ -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;

View 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 */

View 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;
}