]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Parse the 'instance' part of external:/mdXX/INST in metadata handler.
authorNeil Brown <neilb@suse.de>
Mon, 26 May 2008 23:18:57 +0000 (09:18 +1000)
committerNeil Brown <neilb@suse.de>
Mon, 26 May 2008 23:18:57 +0000 (09:18 +1000)
This give more flexability.

managemon.c
mdadm.h
super-ddf.c
super-intel.c

index 91755f92db7b3068f913634254aa42d61d4d7547..4b06778e356403332f5bdaae28ed01c35a140900 100644 (file)
@@ -203,8 +203,7 @@ static void manage_new(struct mdstat_ent *mdstat,
 
        struct active_array *new;
        struct mdinfo *mdi, *di;
-       char *n;
-       int inst;
+       char *inst;
        int i;
 
        new = malloc(sizeof(*new));
@@ -218,10 +217,7 @@ static void manage_new(struct mdstat_ent *mdstat,
 
        new->container = container;
 
-       n = &mdstat->metadata_version[10+strlen(container->devname)+1];
-       inst = atoi(n);
-       if (inst < 0)
-               abort();//FIXME
+       inst = &mdstat->metadata_version[10+strlen(container->devname)+1];
 
        mdi = sysfs_read(-1, new->devnum,
                         GET_LEVEL|GET_CHUNK|GET_DISKS|
diff --git a/mdadm.h b/mdadm.h
index f795b4a4581e23fb5c5e8f70d01c2fc4661e3316..783cd82d7ec42b0ea495379896d5570fbfd6298f 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -413,7 +413,8 @@ extern struct superswitch {
        struct mdinfo *(*container_content)(struct supertype *st);
 
 /* for mdmon */
-       int (*open_new)(struct supertype *c, struct active_array *a, int inst);
+       int (*open_new)(struct supertype *c, struct active_array *a,
+                       char *inst);
 
        /* Tell the metadata handler the current state of the array.
         * This covers whether it is known to be consistent (no pending writes)
index e8082b536738d515e024c1ab2155e06210ff2d6c..8af85bdc70c2ee9be629af9d00a17c2434d16187 100644 (file)
@@ -1201,14 +1201,19 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info)
 
        info->disk.major = 0;
        info->disk.minor = 0;
-       info->disk.number = __be32_to_cpu(ddf->dlist->disk.refnum);
-//     info->disk.raid_disk = find refnum in the table and use index;
-       info->disk.raid_disk = -1;
-       for (i = 0; i < __be16_to_cpu(ddf->phys->max_pdes) ; i++)
-               if (ddf->phys->entries[i].refnum == ddf->dlist->disk.refnum) {
-                       info->disk.raid_disk = i;
-                       break;
-               }
+       if (ddf->dlist) {
+               info->disk.number = __be32_to_cpu(ddf->dlist->disk.refnum);
+               info->disk.raid_disk = -1;
+               for (i = 0; i < __be16_to_cpu(ddf->phys->max_pdes) ; i++)
+                       if (ddf->phys->entries[i].refnum ==
+                           ddf->dlist->disk.refnum) {
+                               info->disk.raid_disk = i;
+                               break;
+                       }
+       } else {
+               info->disk.number = -1;
+//             info->disk.raid_disk = find refnum in the table and use index;
+       }
        info->disk.state = (1 << MD_DISK_SYNC);
 
        info->reshape_active = 0;
@@ -2516,9 +2521,10 @@ static int compare_super_ddf(struct supertype *st, struct supertype *tst)
  * We need to confirm that the array matches the metadata in 'c' so
  * that we don't corrupt any metadata.
  */
-static int ddf_open_new(struct supertype *c, struct active_array *a, int inst)
+static int ddf_open_new(struct supertype *c, struct active_array *a, char *inst)
 {
-       fprintf(stderr, "ddf: open_new %d\n", inst);
+       fprintf(stderr, "ddf: open_new %s\n", inst);
+       a->info.container_member = atoi(inst);
        return 0;
 }
 
index 69aef65301d06f288f3ad7717f126f1c69a328f5..8bf207309b00a17ff317e9d3d2ced396a0778af8 100644 (file)
@@ -1128,9 +1128,11 @@ static struct mdinfo *container_content_imsm(struct supertype *st)
 }
 
 
-static int imsm_open_new(struct supertype *c, struct active_array *a, int inst)
+static int imsm_open_new(struct supertype *c, struct active_array *a,
+                        char *inst)
 {
-       fprintf(stderr, "imsm: open_new %d\n", inst);
+       fprintf(stderr, "imsm: open_new %s\n", inst);
+       a->info.container_member = atoi(inst);
        return 0;
 }