]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Add subarray arg to container_content.
authorNeilBrown <neilb@suse.de>
Mon, 22 Nov 2010 08:35:26 +0000 (19:35 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 22 Nov 2010 08:35:26 +0000 (19:35 +1100)
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>
Assemble.c
Incremental.c
mdadm.h
super-ddf.c
super-intel.c
super0.c
super1.c

index f66a21b96526d5b646cc3e58dc55fc12b53fea6b..37b8413377047914c28f03001785b8f74a6cf98e 100644 (file)
@@ -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 */
 
index e74e52b560ff34a70ea37a2e82be9c428a4c4e40..0978a81f8ddb390f2003e51b4a3baa1ede9625bf 100644 (file)
@@ -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 deff94827dee2b456424702a69d9123d2f4c3422..d46139ce2ae335da8e7d3541799af393c539fdba 100644 (file)
--- 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 */
index 30e228d38bd93930e577743656f67108b5f96426..83e4a31a062cb98f3faf3168b66e6b2ba0323e55 100644 (file)
@@ -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;
index 156585c446b61eeccfc04febb3038d13eeeb1c9f..f64731b6cf34f56edadd46b955fcf64dadd62e33 100644 (file)
@@ -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
index b9d149eb6a80c30124311f65fd13b2d67c61055a..3e17b803ffa2e4a407d824e28db1280fcad598b4 100644 (file)
--- 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,
index a52df6452b16f5c7e4d44052ddc298ca1b929058..bc5f4a7f8b07c90ec8ea1d81bbe0d61f8bd385b4 100644 (file)
--- 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,