Create: user container_dev rather than subarray for some tests.

It makes more sense to test for container_dev than for subarray
for several places in Create where it then uses container_dev.

This allows us to subsequently remove subarray.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2010-11-22 20:24:50 +11:00
parent 9b63e64836
commit d1d599ea0d
6 changed files with 11 additions and 3 deletions

View File

@ -672,7 +672,7 @@ int Create(struct supertype *st, char *mddev,
sysfs_init(&info, mdfd, 0);
if (st->ss->external && st->subarray[0]) {
if (st->ss->external && st->container_dev != NoMdDev) {
/* member */
/* When creating a member, we need to be careful
@ -775,7 +775,8 @@ int Create(struct supertype *st, char *mddev,
if (have_container)
fd = -1;
else {
if (st->ss->external && st->subarray[0])
if (st->ss->external &&
st->container_dev != NoMdDev)
fd = open(dv->devname, O_RDWR);
else
fd = open(dv->devname, O_RDWR|O_EXCL);
@ -906,7 +907,7 @@ int Create(struct supertype *st, char *mddev,
}
if (verbose >= 0)
fprintf(stderr, Name ": array %s started.\n", mddev);
if (st->ss->external && st->subarray[0]) {
if (st->ss->external && st->container_dev != NoMdDev) {
if (need_mdmon)
start_mdmon(st->container_dev);

View File

@ -893,6 +893,7 @@ static struct supertype *match_metadata_desc_ddf(char *arg)
st = malloc(sizeof(*st));
memset(st, 0, sizeof(*st));
st->container_dev = NoMdDev;
st->ss = &super_ddf;
st->max_devs = 512;
st->minor_version = 0;

View File

@ -333,6 +333,7 @@ static struct supertype *match_metadata_desc_imsm(char *arg)
if (!st)
return NULL;
memset(st, 0, sizeof(*st));
st->container_dev = NoMdDev;
st->ss = &super_imsm;
st->max_devs = IMSM_MAX_DEVICES;
st->minor_version = 0;

View File

@ -917,6 +917,7 @@ static struct supertype *match_metadata_desc0(char *arg)
if (!st) return st;
memset(st, 0, sizeof(*st));
st->container_dev = NoMdDev;
st->ss = &super0;
st->info = NULL;
st->minor_version = 90;

View File

@ -1371,6 +1371,7 @@ static struct supertype *match_metadata_desc1(char *arg)
if (!st) return st;
memset(st, 0, sizeof(*st));
st->container_dev = NoMdDev;
st->ss = &super1;
st->max_devs = 384;
st->sb = NULL;

3
util.c
View File

@ -1126,6 +1126,9 @@ struct supertype *guess_super_type(int fd, enum guess_types guess_type)
int i;
st = malloc(sizeof(*st));
memset(st, 0, sizeof(*st));
st->container_dev = NoMdDev;
for (i=0 ; superlist[i]; i++) {
int rv;
ss = superlist[i];