]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix compare_super to take supertype instead of a superblock.
authorNeil Brown <neilb@suse.de>
Fri, 14 Dec 2007 09:14:27 +0000 (20:14 +1100)
committerNeil Brown <neilb@suse.de>
Fri, 14 Dec 2007 09:14:27 +0000 (20:14 +1100)
As this function takes 2 superblocks, the change is a bit more subtle,
so is done separately.

Assemble.c
Examine.c
mdadm.h
super0.c
super1.c

index 7837b19bf4f2c61924eeacd3f58568cebffd1278..98e497640118cbab2227797a6fd6e7b0ff01a234 100644 (file)
@@ -322,7 +322,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                        st = tst;
                if (st->ss != tst->ss ||
                    st->minor_version != tst->minor_version ||
-                   st->ss->compare_super(&first_super, super) != 0) {
+                   st->ss->compare_super(st, tst) != 0) {
                        /* Some mismatch. If exactly one array matches this host,
                         * we can resolve on that one.
                         * Or, if we are auto assembling, we just ignore the second
index b5316b9169149c48d47fb9516925f0dfa67869c8..806c55240f64cbf349fdc481c7200b35cf86ec5e 100644 (file)
--- a/Examine.c
+++ b/Examine.c
@@ -107,7 +107,7 @@ int Examine(mddev_dev_t devlist, int brief, int scan,
                        char *d;
                        for (ap=arrays; ap; ap=ap->next) {
                                if (st->ss == ap->st->ss &&
-                                   st->ss->compare_super(&ap->super, super)==0)
+                                   st->ss->compare_super(ap->st, st)==0)
                                        break;
                        }
                        if (!ap) {
diff --git a/mdadm.h b/mdadm.h
index bf583b41e9ce347fa4d54b0c7be1fbe4847345ec..ad108d40841c908c2aa3b2ba58a69786f2000320 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -357,7 +357,7 @@ extern struct superswitch {
        void (*add_to_super)(struct supertype *st, void *sbv, mdu_disk_info_t *dinfo);
        int (*store_super)(struct supertype *st, int fd, void *sbv);
        int (*write_init_super)(struct supertype *st, void *sbv, mdu_disk_info_t *dinfo, char *devname);
-       int (*compare_super)(void **firstp, void *secondv);
+       int (*compare_super)(struct supertype *st, struct supertype *tst);
        int (*load_super)(struct supertype *st, int fd, void **sbp, char *devname);
        struct supertype * (*match_metadata_desc)(char *arg);
        __u64 (*avail_size)(struct supertype *st, __u64 size);
@@ -375,6 +375,7 @@ struct supertype {
        struct superswitch *ss;
        int minor_version;
        int max_devs;
+       void *sb;
 };
 
 extern struct supertype *super_by_version(int vers, int minor);
@@ -510,7 +511,6 @@ extern int match_oneof(char *devices, char *devname);
 extern void uuid_from_super(int uuid[4], mdp_super_t *super);
 extern int same_uuid(int a[4], int b[4], int swapuuid);
 extern void copy_uuid(void *a, int b[4], int swapuuid);
-/* extern int compare_super(mdp_super_t *first, mdp_super_t *second);*/
 extern unsigned long calc_csum(void *super, int bytes);
 extern int enough(int level, int raid_disks, int layout, int clean,
                   char *avail, int avail_disks);
index b81037ed67a08a5dcc0359ea93adcaa3ed1c9c3d..873fd95cc3365bb1c63d035f2958eb4608841ee3 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -535,6 +535,7 @@ static int init_super0(struct supertype *st, void **sbp, mdu_array_info_t *info,
        int spares;
        memset(sb, 0, MD_SB_BYTES + sizeof(bitmap_super_t));
 
+       st->sb = sb;
        if (info->major_version == -1) {
                /* zeroing the superblock */
                *sbp = sb;
@@ -675,7 +676,7 @@ static int write_init_super0(struct supertype *st, void *sbv, mdu_disk_info_t *d
        return rv;
 }
 
-static int compare_super0(void **firstp, void *secondv)
+static int compare_super0(struct supertype *st, struct supertype *tst)
 {
        /*
         * return:
@@ -684,16 +685,16 @@ static int compare_super0(void **firstp, void *secondv)
         *  2 wrong uuid
         *  3 wrong other info
         */
-       mdp_super_t *first = *firstp;
-       mdp_super_t *second = secondv;
-
+       mdp_super_t *first = st->sb;
+       mdp_super_t *second = tst->sb;
        int uuid1[4], uuid2[4];
+
        if (second->md_magic != MD_SB_MAGIC)
                return 1;
        if (!first) {
                first = malloc(MD_SB_BYTES + sizeof(struct bitmap_super_s));
                memcpy(first, second, MD_SB_BYTES + sizeof(struct bitmap_super_s));
-               *firstp = first;
+               st->sb = first;
                return 0;
        }
 
@@ -781,6 +782,7 @@ static int load_super0(struct supertype *st, int fd, void **sbp, char *devname)
                free(super);
                return 2;
        }
+       st->sb = super;
        *sbp = super;
        if (st->ss == NULL) {
                st->ss = &super0;
@@ -820,6 +822,7 @@ static struct supertype *match_metadata_desc0(char *arg)
        st->ss = &super0;
        st->minor_version = 90;
        st->max_devs = MD_SB_DISKS;
+       st->sb = NULL;
        if (strcmp(arg, "0") == 0 ||
            strcmp(arg, "0.90") == 0 ||
            strcmp(arg, "default") == 0
index a534c3349201893a0d214850757fdfffa9a73685..9bf5912a752fc18b789abb332e4c19fdd6e1d6ad 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -661,6 +661,7 @@ static int init_super1(struct supertype *st, void **sbp, mdu_array_info_t *info,
        char defname[10];
        memset(sb, 0, 1024);
 
+       st->sb = sb;
        if (info->major_version == -1) {
                /* zeroing superblock */
                *sbp = sb;
@@ -947,7 +948,7 @@ static int write_init_super1(struct supertype *st, void *sbv,
        return rv;
 }
 
-static int compare_super1(void **firstp, void *secondv)
+static int compare_super1(struct supertype *st, struct supertype *tst)
 {
        /*
         * return:
@@ -956,8 +957,8 @@ static int compare_super1(void **firstp, void *secondv)
         *  2 wrong uuid
         *  3 wrong other info
         */
-       struct mdp_superblock_1 *first = *firstp;
-       struct mdp_superblock_1 *second = secondv;
+       struct mdp_superblock_1 *first = st->sb;
+       struct mdp_superblock_1 *second = tst->sb;
 
        if (second->magic != __cpu_to_le32(MD_SB_MAGIC))
                return 1;
@@ -969,7 +970,7 @@ static int compare_super1(void **firstp, void *secondv)
                               sizeof(struct misc_dev_info));
                memcpy(first, second, 1024+sizeof(bitmap_super_t) +
                       sizeof(struct misc_dev_info));
-               *firstp = first;
+               st->sb = first;
                return 0;
        }
        if (memcmp(first->set_uuid, second->set_uuid, 16)!= 0)
@@ -1106,6 +1107,7 @@ static int load_super1(struct supertype *st, int fd, void **sbp, char *devname)
                free(super);
                return 2;
        }
+       st->sb = super;
        *sbp = super;
 
        bsb = (struct bitmap_super_s *)(((char*)super)+1024);
@@ -1144,6 +1146,7 @@ static struct supertype *match_metadata_desc1(char *arg)
 
        st->ss = &super1;
        st->max_devs = 384;
+       st->sb = NULL;
        if (strcmp(arg, "1.0") == 0) {
                st->minor_version = 0;
                return st;