]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Remove st->text_version in favour of info->text_version
authorNeil Brown <neilb@suse.de>
Mon, 26 May 2008 23:18:55 +0000 (09:18 +1000)
committerNeil Brown <neilb@suse.de>
Mon, 26 May 2008 23:18:55 +0000 (09:18 +1000)
I want the metadata handler to have more control over the 'version',
particularly for arrays which are members of containers.
So discard st->text_version and instead use info->text_version
which getinfo_super can initialise.

Assemble.c
Create.c
mdadm.h
super-ddf.c
super-intel.c
util.c

index 9c320c2d8aea7ceffb680b5b03a90e41b782b539..16f45cdf1ddc6bd21afa95ffec6e91e29633ed74 100644 (file)
@@ -848,7 +848,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                struct mdinfo *sra;
                if (st->ss->external) {
                        char ver[100];
                struct mdinfo *sra;
                if (st->ss->external) {
                        char ver[100];
-                       strcat(strcpy(ver, "external:"), st->ss->text_version);
+                       strcat(strcpy(ver, "external:"), info.text_version);
                        sra = sysfs_read(mdfd, 0, 0);
                        if ((vers % 100) < 2 ||
                            sra == NULL ||
                        sra = sysfs_read(mdfd, 0, 0);
                        if ((vers % 100) < 2 ||
                            sra == NULL ||
index 59a41a66aff5a2e6b3b6dcde4d64e0e9b23deda4..b7f0914329b79940db80577b615e3a73e6ea4052 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -512,6 +512,8 @@ int Create(struct supertype *st, char *mddev, int mdfd,
        if (!st->ss->init_super(st, &info.array, size, name, homehost, uuid))
                return 1;
 
        if (!st->ss->init_super(st, &info.array, size, name, homehost, uuid))
                return 1;
 
+       st->ss->getinfo_super(st, &info);
+
        if (bitmap_file && vers < 9003) {
                major_num = BITMAP_MAJOR_HOSTENDIAN;
 #ifdef __BIG_ENDIAN
        if (bitmap_file && vers < 9003) {
                major_num = BITMAP_MAJOR_HOSTENDIAN;
 #ifdef __BIG_ENDIAN
@@ -541,7 +543,8 @@ int Create(struct supertype *st, char *mddev, int mdfd,
                char ver[100];
                if (st->ss->external == 1)
                        /* container */
                char ver[100];
                if (st->ss->external == 1)
                        /* container */
-                       strcat(strcpy(ver, "external:"), st->ss->text_version);
+                       strcat(strcpy(ver, "external:"),
+                              info.text_version);
                else {
                        /* member */
                        sprintf(ver, "external:/%s/%d",
                else {
                        /* member */
                        sprintf(ver, "external:/%s/%d",
diff --git a/mdadm.h b/mdadm.h
index b6102aaa3acf4147446d46573184432989ce2e07..73f22ae47481ebf1a74e2165c4384359ea759d98 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -433,7 +433,6 @@ extern struct superswitch {
 
 
        int major;
 
 
        int major;
-       char *text_version;
        int swapuuid; /* true if uuid is bigending rather than hostendian */
        int external;
 } super0, super1, super_ddf, super_ddf_bvd, super_ddf_svd, *superlist[];
        int swapuuid; /* true if uuid is bigending rather than hostendian */
        int external;
 } super0, super1, super_ddf, super_ddf_bvd, super_ddf_svd, *superlist[];
index c7dcc1ae1abe6749a27b01d93d9e8aa1791f7655..fe76509c9fcfedb92819f914019ec72f4b685b5b 100644 (file)
@@ -1212,6 +1212,8 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info)
 
        info->reshape_active = 0;
 
 
        info->reshape_active = 0;
 
+       strcpy(info->text_version, "ddf");
+
 //     uuid_from_super_ddf(info->uuid, sbv);
 
 //     info->name[] ?? ;
 //     uuid_from_super_ddf(info->uuid, sbv);
 
 //     info->name[] ?? ;
@@ -1259,6 +1261,10 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info)
 
        uuid_from_super_ddf(st, info->uuid);
 
 
        uuid_from_super_ddf(st, info->uuid);
 
+       sprintf(info->text_version, "/%s/%d",
+               devnum2devname(st->container_dev),
+               info->container_member);
+
 //     info->name[] ?? ;
 }
 
 //     info->name[] ?? ;
 }
 
@@ -2680,7 +2686,6 @@ struct superswitch super_ddf = {
        .major          = 1000,
        .swapuuid       = 0,
        .external       = 1,
        .major          = 1000,
        .swapuuid       = 0,
        .external       = 1,
-       .text_version   = "ddf",
 
 /* for mdmon */
        .open_new       = ddf_open_new,
 
 /* for mdmon */
        .open_new       = ddf_open_new,
@@ -2713,7 +2718,6 @@ struct superswitch super_ddf_container = {
        .major          = 1000,
        .swapuuid       = 0,
        .external       = 1,
        .major          = 1000,
        .swapuuid       = 0,
        .external       = 1,
-       .text_version   = "ddf",
 };
 
 struct superswitch super_ddf_bvd = {
 };
 
 struct superswitch super_ddf_bvd = {
@@ -2737,7 +2741,6 @@ struct superswitch super_ddf_bvd = {
        .major          = 1001,
        .swapuuid       = 0,
        .external       = 2,
        .major          = 1001,
        .swapuuid       = 0,
        .external       = 2,
-       .text_version   = "ddf",
 };
 
 struct superswitch super_ddf_svd = {
 };
 
 struct superswitch super_ddf_svd = {
@@ -2756,5 +2759,4 @@ struct superswitch super_ddf_svd = {
        .major          = 1002,
        .swapuuid       = 0,
        .external       = 2,
        .major          = 1002,
        .swapuuid       = 0,
        .external       = 2,
-       .text_version   = "ddf",
 };
 };
index edfcae89eac9626840b25d4accf73a416272a1ea..69aef65301d06f288f3ad7717f126f1c69a328f5 100644 (file)
@@ -443,11 +443,17 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info)
        info->disk.state |= s & FAILED_DISK ? (1 << MD_DISK_FAULTY) : 0;
        info->disk.state |= s & USABLE_DISK ? (1 << MD_DISK_SYNC) : 0;
        info->reshape_active = 0;
        info->disk.state |= s & FAILED_DISK ? (1 << MD_DISK_FAULTY) : 0;
        info->disk.state |= s & USABLE_DISK ? (1 << MD_DISK_SYNC) : 0;
        info->reshape_active = 0;
+
+       strcpy(info->text_version, "imsm");
 }
 
 static void getinfo_super_imsm_raid(struct supertype *st, struct mdinfo *info)
 {
        printf("%s\n", __FUNCTION__);
 }
 
 static void getinfo_super_imsm_raid(struct supertype *st, struct mdinfo *info)
 {
        printf("%s\n", __FUNCTION__);
+
+       sprintf(info->text_version, "/%s/%d",
+               devnum2devname(st->container_dev),
+               info->container_member); // FIXME is this even set here?
 }
 
 static int update_super_imsm(struct supertype *st, struct mdinfo *info,
 }
 
 static int update_super_imsm(struct supertype *st, struct mdinfo *info,
@@ -1063,6 +1069,10 @@ static struct mdinfo *container_content_imsm(struct supertype *st)
                strncpy(this->name, (char *) dev->volume, MAX_RAID_SERIAL_LEN);
                this->name[MAX_RAID_SERIAL_LEN] = 0;
 
                strncpy(this->name, (char *) dev->volume, MAX_RAID_SERIAL_LEN);
                this->name[MAX_RAID_SERIAL_LEN] = 0;
 
+               sprintf(this->text_version, "/%s/%d",
+                       devnum2devname(st->container_dev),
+                       this->container_member);
+
                memset(this->uuid, 0, sizeof(this->uuid));
 
                sz = __le32_to_cpu(dev->size_high);
                memset(this->uuid, 0, sizeof(this->uuid));
 
                sz = __le32_to_cpu(dev->size_high);
@@ -1352,7 +1362,6 @@ struct superswitch super_imsm = {
        .major          = 2000,
        .swapuuid       = 0,
        .external       = 1,
        .major          = 2000,
        .swapuuid       = 0,
        .external       = 1,
-       .text_version   = "imsm",
 
 /* for mdmon */
        .open_new       = imsm_open_new,
 
 /* for mdmon */
        .open_new       = imsm_open_new,
@@ -1389,7 +1398,6 @@ struct superswitch super_imsm_container = {
        .major          = 2000,
        .swapuuid       = 0,
        .external       = 1,
        .major          = 2000,
        .swapuuid       = 0,
        .external       = 1,
-       .text_version   = "imsm",
 };
 
 struct superswitch super_imsm_raid = {
 };
 
 struct superswitch super_imsm_raid = {
@@ -1409,5 +1417,4 @@ struct superswitch super_imsm_raid = {
        .major          = 2001,
        .swapuuid       = 0,
        .external       = 2,
        .major          = 2001,
        .swapuuid       = 0,
        .external       = 2,
-       .text_version   = "imsm",
 };
 };
diff --git a/util.c b/util.c
index 6f1620a6132fb51e169e5005693e6e7926173990..365e66b81e06c3b5779684c7e2e7af28d5cadde4 100644 (file)
--- a/util.c
+++ b/util.c
@@ -834,30 +834,19 @@ struct supertype *super_by_fd(int fd)
 #endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
 
 
 #endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
 
 
-struct supertype *dup_super(struct supertype *st)
+struct supertype *dup_super(struct supertype *orig)
 {
 {
-       struct supertype *stnew = NULL;
-       char *verstr = NULL;
-       char version[20];
-       int i;
+       struct supertype *st;
 
 
+       st = malloc(sizeof(*st));
        if (!st)
                return st;
        if (!st)
                return st;
-
-       if (st->ss->text_version)
-               strcpy(version, st->ss->text_version);
-       else if (st->minor_version == -1)
-               sprintf(version, "%d", st->ss->major);
-       else
-               sprintf(version, "%d.%d", st->ss->major, st->minor_version);
-       verstr = version;
-
-       for (i = 0; stnew == NULL && superlist[i] ; i++)
-               stnew = superlist[i]->match_metadata_desc(verstr);
-
-       if (stnew)
-               stnew->sb = NULL;
-       return stnew;
+       st->ss = orig->ss;
+       st->max_devs = orig->max_devs;
+       st->minor_version = orig->minor_version;
+       st->sb = NULL;
+       st->info = NULL;
+       return st;
 }
 
 struct supertype *guess_super(int fd)
 }
 
 struct supertype *guess_super(int fd)