Add subarray arg to container_content.
This allows the info for a single array to be extracted, so we don't have to write it into st->subarray. For consistency, implement container_content for super0 and super1, to just return the mdinfo for the single array. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
ca145a1e4c
commit
00bbdbdac6
|
@ -331,7 +331,7 @@ int Assemble(struct supertype *st, char *mddev,
|
||||||
if (tmpdev->content)
|
if (tmpdev->content)
|
||||||
content = tmpdev->content;
|
content = tmpdev->content;
|
||||||
else
|
else
|
||||||
content = tst->ss->container_content(tst);
|
content = tst->ss->container_content(tst, NULL);
|
||||||
if (!content)
|
if (!content)
|
||||||
goto loop; /* empty container */
|
goto loop; /* empty container */
|
||||||
|
|
||||||
|
|
|
@ -1190,7 +1190,7 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
|
||||||
* array, choose a device name and assemble the array.
|
* array, choose a device name and assemble the array.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct mdinfo *list = st->ss->container_content(st);
|
struct mdinfo *list = st->ss->container_content(st, NULL);
|
||||||
struct mdinfo *ra;
|
struct mdinfo *ra;
|
||||||
struct map_ent *map = NULL;
|
struct map_ent *map = NULL;
|
||||||
|
|
||||||
|
|
2
mdadm.h
2
mdadm.h
|
@ -621,7 +621,7 @@ extern struct superswitch {
|
||||||
char *subdev, unsigned long long *freesize,
|
char *subdev, unsigned long long *freesize,
|
||||||
int verbose);
|
int verbose);
|
||||||
|
|
||||||
struct mdinfo *(*container_content)(struct supertype *st);
|
struct mdinfo *(*container_content)(struct supertype *st, char *subarray);
|
||||||
/* Allow a metadata handler to override mdadm's default layouts */
|
/* Allow a metadata handler to override mdadm's default layouts */
|
||||||
int (*default_layout)(int level); /* optional */
|
int (*default_layout)(int level); /* optional */
|
||||||
/* query the supertype for default chunk size */
|
/* query the supertype for default chunk size */
|
||||||
|
|
|
@ -2924,7 +2924,7 @@ static int load_super_ddf_all(struct supertype *st, int fd,
|
||||||
}
|
}
|
||||||
#endif /* MDASSEMBLE */
|
#endif /* MDASSEMBLE */
|
||||||
|
|
||||||
static struct mdinfo *container_content_ddf(struct supertype *st)
|
static struct mdinfo *container_content_ddf(struct supertype *st, char *subarray)
|
||||||
{
|
{
|
||||||
/* Given a container loaded by load_super_ddf_all,
|
/* Given a container loaded by load_super_ddf_all,
|
||||||
* extract information about all the arrays into
|
* extract information about all the arrays into
|
||||||
|
@ -2943,6 +2943,13 @@ static struct mdinfo *container_content_ddf(struct supertype *st)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
struct mdinfo *this;
|
struct mdinfo *this;
|
||||||
|
char *ep;
|
||||||
|
|
||||||
|
if (subarray &&
|
||||||
|
(strtoul(subarray, &ep, 10) != vc->vcnum ||
|
||||||
|
*ep != '\0'))
|
||||||
|
continue;
|
||||||
|
|
||||||
this = malloc(sizeof(*this));
|
this = malloc(sizeof(*this));
|
||||||
memset(this, 0, sizeof(*this));
|
memset(this, 0, sizeof(*this));
|
||||||
this->next = rest;
|
this->next = rest;
|
||||||
|
|
|
@ -4327,11 +4327,12 @@ static void update_recovery_start(struct imsm_dev *dev, struct mdinfo *array)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct mdinfo *container_content_imsm(struct supertype *st)
|
static struct mdinfo *container_content_imsm(struct supertype *st, char *subarray)
|
||||||
{
|
{
|
||||||
/* Given a container loaded by load_super_imsm_all,
|
/* Given a container loaded by load_super_imsm_all,
|
||||||
* extract information about all the arrays into
|
* extract information about all the arrays into
|
||||||
* an mdinfo tree.
|
* an mdinfo tree.
|
||||||
|
* If 'subarray' is given, just extract info about that array.
|
||||||
*
|
*
|
||||||
* For each imsm_dev create an mdinfo, fill it in,
|
* For each imsm_dev create an mdinfo, fill it in,
|
||||||
* then look for matching devices in super->disks
|
* then look for matching devices in super->disks
|
||||||
|
@ -4340,7 +4341,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st)
|
||||||
struct intel_super *super = st->sb;
|
struct intel_super *super = st->sb;
|
||||||
struct imsm_super *mpb = super->anchor;
|
struct imsm_super *mpb = super->anchor;
|
||||||
struct mdinfo *rest = NULL;
|
struct mdinfo *rest = NULL;
|
||||||
int i;
|
unsigned int i;
|
||||||
|
|
||||||
/* do not assemble arrays that might have bad blocks */
|
/* do not assemble arrays that might have bad blocks */
|
||||||
if (imsm_bbm_log_size(super->anchor)) {
|
if (imsm_bbm_log_size(super->anchor)) {
|
||||||
|
@ -4350,10 +4351,18 @@ static struct mdinfo *container_content_imsm(struct supertype *st)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < mpb->num_raid_devs; i++) {
|
for (i = 0; i < mpb->num_raid_devs; i++) {
|
||||||
struct imsm_dev *dev = get_imsm_dev(super, i);
|
struct imsm_dev *dev;
|
||||||
struct imsm_map *map = get_imsm_map(dev, 0);
|
struct imsm_map *map;
|
||||||
struct mdinfo *this;
|
struct mdinfo *this;
|
||||||
int slot;
|
int slot;
|
||||||
|
char *ep;
|
||||||
|
|
||||||
|
if (subarray &&
|
||||||
|
(i != strtoul(subarray, &ep, 10) || *ep != '\0'))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dev = get_imsm_dev(super, i);
|
||||||
|
map = get_imsm_map(dev, 0);
|
||||||
|
|
||||||
/* do not publish arrays that are in the middle of an
|
/* do not publish arrays that are in the middle of an
|
||||||
* unsupported migration
|
* unsupported migration
|
||||||
|
|
12
super0.c
12
super0.c
|
@ -401,6 +401,17 @@ static void getinfo_super0(struct supertype *st, struct mdinfo *info, char *map)
|
||||||
info->array.working_disks = working;
|
info->array.working_disks = working;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct mdinfo *container_content0(struct supertype *st, char *subarray)
|
||||||
|
{
|
||||||
|
struct mdinfo *info;
|
||||||
|
|
||||||
|
if (subarray)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
info = malloc(sizeof(*info));
|
||||||
|
getinfo_super0(st, info, NULL);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
static int update_super0(struct supertype *st, struct mdinfo *info,
|
static int update_super0(struct supertype *st, struct mdinfo *info,
|
||||||
char *update,
|
char *update,
|
||||||
|
@ -1136,6 +1147,7 @@ struct superswitch super0 = {
|
||||||
.match_home = match_home0,
|
.match_home = match_home0,
|
||||||
.uuid_from_super = uuid_from_super0,
|
.uuid_from_super = uuid_from_super0,
|
||||||
.getinfo_super = getinfo_super0,
|
.getinfo_super = getinfo_super0,
|
||||||
|
.container_content = container_content0,
|
||||||
.update_super = update_super0,
|
.update_super = update_super0,
|
||||||
.init_super = init_super0,
|
.init_super = init_super0,
|
||||||
.store_super = store_super0,
|
.store_super = store_super0,
|
||||||
|
|
13
super1.c
13
super1.c
|
@ -645,6 +645,18 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
|
||||||
info->array.working_disks = working;
|
info->array.working_disks = working;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct mdinfo *container_content1(struct supertype *st, char *subarray)
|
||||||
|
{
|
||||||
|
struct mdinfo *info;
|
||||||
|
|
||||||
|
if (subarray)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
info = malloc(sizeof(*info));
|
||||||
|
getinfo_super1(st, info, NULL);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
static int update_super1(struct supertype *st, struct mdinfo *info,
|
static int update_super1(struct supertype *st, struct mdinfo *info,
|
||||||
char *update,
|
char *update,
|
||||||
char *devname, int verbose,
|
char *devname, int verbose,
|
||||||
|
@ -1683,6 +1695,7 @@ struct superswitch super1 = {
|
||||||
.match_home = match_home1,
|
.match_home = match_home1,
|
||||||
.uuid_from_super = uuid_from_super1,
|
.uuid_from_super = uuid_from_super1,
|
||||||
.getinfo_super = getinfo_super1,
|
.getinfo_super = getinfo_super1,
|
||||||
|
.container_content = container_content1,
|
||||||
.update_super = update_super1,
|
.update_super = update_super1,
|
||||||
.init_super = init_super1,
|
.init_super = init_super1,
|
||||||
.store_super = store_super1,
|
.store_super = store_super1,
|
||||||
|
|
Loading…
Reference in New Issue