fix RebuildMap() to retrieve 'subarray' info
RebuildMap falsely returns container info for member arrays. Retrieving the subarray and container_dev details prior to ->load_super() changes the result from: md127 imsm 082c6371:74b5ce03:64972e41:6b0860d5 /dev/md/imsm md126 imsm 082c6371:74b5ce03:64972e41:6b0860d5 /dev/md/vol0 ...to: md126 /md127/0 3e03aee2:78c3c593:1e8ecaf0:eefb53ed /dev/md/vol0 md127 imsm 082c6371:74b5ce03:64972e41:6b0860d5 /dev/md/imsm Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
af99d9ca67
commit
f98d41ddb4
32
mapfile.c
32
mapfile.c
|
@ -297,6 +297,34 @@ struct map_ent *map_by_name(struct map_ent **map, char *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* sets the proper subarray and container_dev according to the metadata
|
||||||
|
* version super_by_fd does this automatically, this routine is meant as
|
||||||
|
* a supplement for guess_super()
|
||||||
|
*/
|
||||||
|
static void set_member_info(struct supertype *st, struct mdstat_ent *ent)
|
||||||
|
{
|
||||||
|
char version[strlen(ent->metadata_version)+1];
|
||||||
|
|
||||||
|
st->subarray[0] = '\0';
|
||||||
|
|
||||||
|
if (strncmp(ent->metadata_version, "external:", 9) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
strcpy(version, ent->metadata_version);
|
||||||
|
|
||||||
|
if (is_subarray(&version[9])) {
|
||||||
|
char *subarray = strrchr(version, '/');
|
||||||
|
char *name = &version[10];
|
||||||
|
|
||||||
|
if (!subarray)
|
||||||
|
return;
|
||||||
|
*subarray++ = '\0';
|
||||||
|
|
||||||
|
st->container_dev = devname2devnum(name);
|
||||||
|
strncpy(st->subarray, subarray, sizeof(st->subarray));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RebuildMap(void)
|
void RebuildMap(void)
|
||||||
{
|
{
|
||||||
struct mdstat_ent *mdstat = mdstat_read(0, 0);
|
struct mdstat_ent *mdstat = mdstat_read(0, 0);
|
||||||
|
@ -337,8 +365,10 @@ void RebuildMap(void)
|
||||||
st = guess_super(dfd);
|
st = guess_super(dfd);
|
||||||
if ( st == NULL)
|
if ( st == NULL)
|
||||||
ok = -1;
|
ok = -1;
|
||||||
else
|
else {
|
||||||
|
set_member_info(st, md);
|
||||||
ok = st->ss->load_super(st, dfd, NULL);
|
ok = st->ss->load_super(st, dfd, NULL);
|
||||||
|
}
|
||||||
close(dfd);
|
close(dfd);
|
||||||
if (ok != 0)
|
if (ok != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue