Initialize st->devnum and st->container_dev in super_by_fd
Precludes needing to deduce this information later, like in Detail.c and soon in Grow.c. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
30f58b2208
commit
5f7e44b29f
11
Detail.c
11
Detail.c
|
@ -98,16 +98,13 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
|
||||||
if (st)
|
if (st)
|
||||||
max_disks = st->max_devs;
|
max_disks = st->max_devs;
|
||||||
|
|
||||||
if (sra && is_subarray(sra->text_version) &&
|
if (subarray) {
|
||||||
strchr(sra->text_version+1, '/')) {
|
|
||||||
/* This is a subarray of some container.
|
/* This is a subarray of some container.
|
||||||
* We want the name of the container, and the member
|
* We want the name of the container, and the member
|
||||||
*/
|
*/
|
||||||
char *s = strchr(sra->text_version+1, '/');
|
int dn = st->container_dev;
|
||||||
int dn;
|
|
||||||
*s++ = '\0';
|
member = subarray;
|
||||||
member = s;
|
|
||||||
dn = devname2devnum(sra->text_version+1);
|
|
||||||
container = map_dev(dev2major(dn), dev2minor(dn), 1);
|
container = map_dev(dev2major(dn), dev2minor(dn), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
util.c
10
util.c
|
@ -1068,6 +1068,7 @@ struct supertype *super_by_fd(int fd, char **subarrayp)
|
||||||
char version[20];
|
char version[20];
|
||||||
int i;
|
int i;
|
||||||
char *subarray = NULL;
|
char *subarray = NULL;
|
||||||
|
int container = NoMdDev;
|
||||||
|
|
||||||
sra = sysfs_read(fd, 0, GET_VERSION);
|
sra = sysfs_read(fd, 0, GET_VERSION);
|
||||||
|
|
||||||
|
@ -1089,15 +1090,15 @@ struct supertype *super_by_fd(int fd, char **subarrayp)
|
||||||
}
|
}
|
||||||
if (minor == -2 && is_subarray(verstr)) {
|
if (minor == -2 && is_subarray(verstr)) {
|
||||||
char *dev = verstr+1;
|
char *dev = verstr+1;
|
||||||
|
|
||||||
subarray = strchr(dev, '/');
|
subarray = strchr(dev, '/');
|
||||||
int devnum;
|
|
||||||
if (subarray)
|
if (subarray)
|
||||||
*subarray++ = '\0';
|
*subarray++ = '\0';
|
||||||
devnum = devname2devnum(dev);
|
|
||||||
subarray = strdup(subarray);
|
subarray = strdup(subarray);
|
||||||
|
container = devname2devnum(dev);
|
||||||
if (sra)
|
if (sra)
|
||||||
sysfs_free(sra);
|
sysfs_free(sra);
|
||||||
sra = sysfs_read(-1, devnum, GET_VERSION);
|
sra = sysfs_read(-1, container, GET_VERSION);
|
||||||
if (sra && sra->text_version[0])
|
if (sra && sra->text_version[0])
|
||||||
verstr = sra->text_version;
|
verstr = sra->text_version;
|
||||||
else
|
else
|
||||||
|
@ -1113,8 +1114,11 @@ struct supertype *super_by_fd(int fd, char **subarrayp)
|
||||||
st->sb = NULL;
|
st->sb = NULL;
|
||||||
if (subarrayp)
|
if (subarrayp)
|
||||||
*subarrayp = subarray;
|
*subarrayp = subarray;
|
||||||
|
st->container_dev = container;
|
||||||
|
st->devnum = fd2devnum(fd);
|
||||||
} else
|
} else
|
||||||
free(subarray);
|
free(subarray);
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
#endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
|
#endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
|
||||||
|
|
Loading…
Reference in New Issue