Remove 'major' from superswitch.
authorNeil Brown <neilb@suse.de>
Sat, 12 Jul 2008 10:27:37 +0000 (20:27 +1000)
committerNeil Brown <neilb@suse.de>
Sat, 12 Jul 2008 10:27:37 +0000 (20:27 +1000)
It isn't generally meaningful.

Assemble.c
Create.c
Incremental.c
Query.c
mdadm.h
super-ddf.c
super-intel.c
super0.c
super1.c
sysfs.c

index cb2725d..d9b9b81 100644 (file)
@@ -542,8 +542,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                            == devices[devcnt].i.events
                            && (devices[best[i]].i.disk.minor
                                != devices[devcnt].i.disk.minor)
-                           && st->ss->major == 0
-                           && info.array.level != -4) {
+                           && st->ss == &super0
+                           && info.array.level != LEVEL_MULTIPATH) {
                                /* two different devices with identical superblock.
                                 * Could be a mis-detection caused by overlapping
                                 * partitions.  fail-safe.
@@ -866,8 +866,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                if ((vers % 100) >= 1) { /* can use different versions */
                        mdu_array_info_t inf;
                        memset(&inf, 0, sizeof(inf));
-                       inf.major_version = st->ss->major;
-                       inf.minor_version = st->minor_version;
+                       inf.major_version = info.array.major_version;
+                       inf.minor_version = info.array.minor_version;
                        rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
                } else
                        rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
index 91937df..eb67968 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -76,6 +76,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
        unsigned long long bitmapsize;
        struct mdinfo *sra;
        struct mdinfo info;
+       int did_default = 0;
 
        int major_num = BITMAP_MAJOR_HI;
 
@@ -289,12 +290,9 @@ int Create(struct supertype *st, char *mddev, int mdfd,
                                        dname);
                                exit(2);
                        }
-                       if (st->ss->major != 0 ||
+                       if (st->ss != &super0 ||
                            st->minor_version != 90)
-                               fprintf(stderr, Name ": Defaulting to version"
-                                       " %d.%d metadata\n",
-                                       st->ss->major,
-                                       st->minor_version);
+                               did_default = 1;
                } else {
                        if (!st->ss->validate_geometry(st, level, layout,
                                                       raiddisks,
@@ -356,9 +354,12 @@ int Create(struct supertype *st, char *mddev, int mdfd,
                }
                if (level > 0 || level == LEVEL_MULTIPATH
                    || level == LEVEL_FAULTY
-                   || (st && st->ss->external) ) {
+                   || st->ss->external ) {
                        /* size is meaningful */
-                       if (minsize > 0x100000000ULL && st->ss->major == 0) {
+                       if (!st->ss->validate_geometry(st, level, layout,
+                                                      raiddisks,
+                                                      chunk, minsize,
+                                                      NULL, NULL)) {
                                fprintf(stderr, Name ": devices too large for RAID level %d\n", level);
                                return 1;
                        }
@@ -485,7 +486,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
                + info.array.failed_disks;
        info.array.layout = layout;
        info.array.chunk_size = chunk*1024;
-       info.array.major_version = st->ss->major;
+       info.array.major_version = 0; /* Flag to say "not zeroing superblock" */
 
        if (name == NULL || *name == 0) {
                /* base name on mddev */
@@ -516,6 +517,10 @@ int Create(struct supertype *st, char *mddev, int mdfd,
 
        st->ss->getinfo_super(st, &info);
 
+       if (did_default)
+               fprintf(stderr, Name ": Defaulting to version"
+                       " %s metadata\n", info.text_version);
+
        if (bitmap_file && vers < 9003) {
                major_num = BITMAP_MAJOR_HOSTENDIAN;
 #ifdef __BIG_ENDIAN
@@ -586,8 +591,8 @@ int Create(struct supertype *st, char *mddev, int mdfd,
        } else  if ((vers % 100) >= 1) { /* can use different versions */
                mdu_array_info_t inf;
                memset(&inf, 0, sizeof(inf));
-               inf.major_version = st->ss->major;
-               inf.minor_version = st->minor_version;
+               inf.major_version = info.array.major_version;
+               inf.minor_version = info.array.minor_version;
                rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
        } else
                rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
index 6ac67ac..712f2bd 100644 (file)
@@ -300,12 +300,11 @@ int Incremental(char *devname, int verbose, int runstop,
        /* - add the device */
                mdu_array_info_t ainf;
                mdu_disk_info_t disk;
-               char md[20];
                struct mdinfo *sra;
 
                memset(&ainf, 0, sizeof(ainf));
-               ainf.major_version = st->ss->major;
-               ainf.minor_version = st->minor_version;
+               ainf.major_version = info.array.major_version;
+               ainf.minor_version = info.array.minor_version;
                if (ioctl(mdfd, SET_ARRAY_INFO, &ainf) != 0) {
                        fprintf(stderr, Name
                                ": SET_ARRAY_INFO failed for %s: %s\b",
@@ -313,9 +312,8 @@ int Incremental(char *devname, int verbose, int runstop,
                        close(mdfd);
                        return 2;
                }
-               sprintf(md, "%d.%d\n", st->ss->major, st->minor_version);
                sra = sysfs_read(mdfd, devnum, GET_VERSION);
-               sysfs_set_str(sra, NULL, "metadata_version", md);
+               sysfs_set_str(sra, NULL, "metadata_version", info.text_version);
                memset(&disk, 0, sizeof(disk));
                disk.major = major(stb.st_rdev);
                disk.minor = minor(stb.st_rdev);
@@ -352,29 +350,18 @@ int Incremental(char *devname, int verbose, int runstop,
                int err;
                struct mdinfo *sra;
                struct supertype *st2;
-               sra = sysfs_read(mdfd, devnum, (GET_VERSION | GET_DEVS |
-                                               GET_STATE));
+               sra = sysfs_read(mdfd, devnum, (GET_DEVS | GET_STATE));
 
-               if (sra->array.major_version != st->ss->major ||
-                   sra->array.minor_version != st->minor_version) {
-                       if (verbose >= 0)
-                               fprintf(stderr, Name
-             ": %s has different metadata to chosen array %s %d.%d %d.%d.\n",
-                                       devname, chosen_name,
-                                       sra->array.major_version,
-                                       sra->array.minor_version,
-                                       st->ss->major, st->minor_version);
-                       close(mdfd);
-                       return 1;
-               }
                sprintf(dn, "%d:%d", sra->devs->disk.major,
                        sra->devs->disk.minor);
                dfd2 = dev_open(dn, O_RDONLY);
                st2 = dup_super(st);
-               if (st2->ss->load_super(st2, dfd2, NULL)) {
+               if (st2->ss->load_super(st2, dfd2, NULL) ||
+                   st->ss->compare_super(st, st2) != 0) {
                        fprintf(stderr, Name
-                               ": Strange error loading metadata for %s.\n",
-                               chosen_name);
+                               ": metadata mismatch between %s and "
+                               "chosen array %s\n",
+                               devname, chosen_name);
                        close(mdfd);
                        close(dfd2);
                        return 2;
diff --git a/Query.c b/Query.c
index 0802964..fcbafcf 100644 (file)
--- a/Query.c
+++ b/Query.c
@@ -96,7 +96,7 @@ int Query(char *dev)
        if (superror == 0) {
                /* array might be active... */
                st->ss->getinfo_super(st, &info);
-               if (st->ss->major == 0) {
+               if (st->ss == &super0) {
                        mddev = get_md_name(info.array.md_minor);
                        disc.number = info.disk.number;
                        activity = "undetected";
@@ -121,7 +121,7 @@ int Query(char *dev)
                       activity,
                       map_num(pers, info.array.level),
                       mddev);
-               if (st->ss->major == 0)
+               if (st->ss == &super0)
                        put_md_name(mddev);
        }
        return 0;
diff --git a/mdadm.h b/mdadm.h
index 041e53d..c0e3691 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -448,7 +448,6 @@ extern struct superswitch {
        struct mdinfo *(*activate_spare)(struct active_array *a,
                                         struct metadata_update **updates);
 
-       int major;
        int swapuuid; /* true if uuid is bigending rather than hostendian */
        int external;
 } super0, super1, super_ddf, super_ddf_bvd, super_ddf_svd, *superlist[];
index 2cc876d..8f7cec4 100644 (file)
@@ -3119,7 +3119,6 @@ struct superswitch super_ddf = {
        .match_metadata_desc = match_metadata_desc_ddf,
        .getinfo_super_n  = getinfo_super_n_container,
 
-       .major          = 1000,
        .swapuuid       = 0,
        .external       = 1,
 
@@ -3152,7 +3151,6 @@ struct superswitch super_ddf_container = {
        .container_content = container_content_ddf,
        .getinfo_super_n  = getinfo_super_n_container,
 
-       .major          = 1000,
        .swapuuid       = 0,
        .external       = 1,
 };
@@ -3174,7 +3172,6 @@ struct superswitch super_ddf_bvd = {
        .free_super     = free_super_ddf,
        .match_metadata_desc = match_metadata_desc_ddf_bvd,
 
-       .major          = 1001,
        .swapuuid       = 0,
        .external       = 2,
 };
@@ -3192,7 +3189,6 @@ struct superswitch super_ddf_svd = {
        .free_super     = free_super_ddf,
        .match_metadata_desc = match_metadata_desc_ddf_svd,
 
-       .major          = 1002,
        .swapuuid       = 0,
        .external       = 2,
 };
index 263e398..68674e5 100644 (file)
@@ -1873,7 +1873,6 @@ struct superswitch super_imsm = {
        .getinfo_super_n  = getinfo_super_n_imsm_container,
 
        .validate_geometry = validate_geometry_imsm,
-       .major          = 2000,
        .swapuuid       = 0,
        .external       = 1,
 
@@ -1909,7 +1908,6 @@ struct superswitch super_imsm_container = {
 
        .container_content = container_content_imsm,
 
-       .major          = 2000,
        .swapuuid       = 0,
        .external       = 1,
 };
@@ -1928,7 +1926,6 @@ struct superswitch super_imsm_volume = {
 
 
        .validate_geometry = validate_geometry_imsm_volume,
-       .major          = 2001,
        .swapuuid       = 0,
        .external       = 2,
 };
index 47b95ec..6bb5a7e 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -1089,6 +1089,5 @@ struct superswitch super0 = {
        .write_bitmap = write_bitmap0,
        .free_super = free_super0,
        .validate_geometry = validate_geometry0,
-       .major = 0,
        .swapuuid = 0,
 };
index d2d8d95..ae6c8a3 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -493,7 +493,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info)
        int role;
 
        info->array.major_version = 1;
-       info->array.minor_version = __le32_to_cpu(sb->feature_map);
+       info->array.minor_version = st->minor_version;
        info->array.patch_version = 0;
        info->array.raid_disks = __le32_to_cpu(sb->raid_disks);
        info->array.level = __le32_to_cpu(sb->level);
@@ -1502,7 +1502,6 @@ struct superswitch super1 = {
        .write_bitmap = write_bitmap1,
        .free_super = free_super1,
        .validate_geometry = validate_geometry1,
-       .major = 1,
 #if __BYTE_ORDER == BIG_ENDIAN
        .swapuuid = 0,
 #else
diff --git a/sysfs.c b/sysfs.c
index 5f0c212..ae10b1e 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -134,10 +134,12 @@ struct mdinfo *sysfs_read(int fd, int devnum, unsigned long options)
                        sra->array.major_version = -1;
                        sra->array.minor_version = -2;
                        strcpy(sra->text_version, buf+9);
-               } else
+               } else {
                        sscanf(buf, "%d.%d",
                               &sra->array.major_version,
                               &sra->array.minor_version);
+                       strcpy(sra->text_version, buf);
+               }
        }
        if (options & GET_LEVEL) {
                strcpy(base, "level");