From: NeilBrown Date: Mon, 22 Nov 2010 08:35:26 +0000 (+1100) Subject: Add subarray arg to container_content. X-Git-Tag: mdadm-3.2~306 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=00bbdbdac69e6d90fc71b8a2bfe574928ec66da3;p=thirdparty%2Fmdadm.git 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 --- diff --git a/Assemble.c b/Assemble.c index f66a21b9..37b84133 100644 --- a/Assemble.c +++ b/Assemble.c @@ -331,7 +331,7 @@ int Assemble(struct supertype *st, char *mddev, if (tmpdev->content) content = tmpdev->content; else - content = tst->ss->container_content(tst); + content = tst->ss->container_content(tst, NULL); if (!content) goto loop; /* empty container */ diff --git a/Incremental.c b/Incremental.c index e74e52b5..0978a81f 100644 --- a/Incremental.c +++ b/Incremental.c @@ -1190,7 +1190,7 @@ int Incremental_container(struct supertype *st, char *devname, int verbose, * 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 map_ent *map = NULL; diff --git a/mdadm.h b/mdadm.h index deff9482..d46139ce 100644 --- a/mdadm.h +++ b/mdadm.h @@ -621,7 +621,7 @@ extern struct superswitch { char *subdev, unsigned long long *freesize, 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 */ int (*default_layout)(int level); /* optional */ /* query the supertype for default chunk size */ diff --git a/super-ddf.c b/super-ddf.c index 30e228d3..83e4a31a 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -2924,7 +2924,7 @@ static int load_super_ddf_all(struct supertype *st, int fd, } #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, * 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 j; struct mdinfo *this; + char *ep; + + if (subarray && + (strtoul(subarray, &ep, 10) != vc->vcnum || + *ep != '\0')) + continue; + this = malloc(sizeof(*this)); memset(this, 0, sizeof(*this)); this->next = rest; diff --git a/super-intel.c b/super-intel.c index 156585c4..f64731b6 100644 --- a/super-intel.c +++ b/super-intel.c @@ -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, * extract information about all the arrays into * an mdinfo tree. + * If 'subarray' is given, just extract info about that array. * * For each imsm_dev create an mdinfo, fill it in, * 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 imsm_super *mpb = super->anchor; struct mdinfo *rest = NULL; - int i; + unsigned int i; /* do not assemble arrays that might have bad blocks */ 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++) { - struct imsm_dev *dev = get_imsm_dev(super, i); - struct imsm_map *map = get_imsm_map(dev, 0); + struct imsm_dev *dev; + struct imsm_map *map; struct mdinfo *this; 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 * unsupported migration diff --git a/super0.c b/super0.c index b9d149eb..3e17b803 100644 --- a/super0.c +++ b/super0.c @@ -401,6 +401,17 @@ static void getinfo_super0(struct supertype *st, struct mdinfo *info, char *map) 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, char *update, @@ -1136,6 +1147,7 @@ struct superswitch super0 = { .match_home = match_home0, .uuid_from_super = uuid_from_super0, .getinfo_super = getinfo_super0, + .container_content = container_content0, .update_super = update_super0, .init_super = init_super0, .store_super = store_super0, diff --git a/super1.c b/super1.c index a52df645..bc5f4a7f 100644 --- a/super1.c +++ b/super1.c @@ -645,6 +645,18 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map) 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, char *update, char *devname, int verbose, @@ -1683,6 +1695,7 @@ struct superswitch super1 = { .match_home = match_home1, .uuid_from_super = uuid_from_super1, .getinfo_super = getinfo_super1, + .container_content = container_content1, .update_super = update_super1, .init_super = init_super1, .store_super = store_super1,