Fix compare_super to take supertype instead of a superblock.

As this function takes 2 superblocks, the change is a bit more subtle,
so is done separately.
This commit is contained in:
Neil Brown 2007-12-14 20:14:27 +11:00
parent 68c7d6d790
commit 64557c3391
5 changed files with 19 additions and 13 deletions

View 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

View File

@ -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) {

View File

@ -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);

View File

@ -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

View File

@ -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;