From: Dan Williams Date: Thu, 2 Oct 2008 01:50:44 +0000 (-0700) Subject: Allow a uuid of all f's to always match X-Git-Tag: mdadm-3.0-devel2~79 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=commitdiff_plain;h=36ba7d4849186b4c97bd6d5f905a390ff1de6f83 Allow a uuid of all f's to always match The uuid returned for an imsm spare device will never match the uuid of an active disk. So make mdadm interpret a uuid of all f's as "match any". Signed-off-by: Dan Williams --- diff --git a/mdadm.h b/mdadm.h index 7a39187e..1eba5783 100644 --- a/mdadm.h +++ b/mdadm.h @@ -767,6 +767,7 @@ extern char *conf_word(FILE *file, int allow_key); extern void free_line(char *line); extern int match_oneof(char *devices, char *devname); extern void uuid_from_super(int uuid[4], mdp_super_t *super); +extern const int uuid_match_any[4]; extern int same_uuid(int a[4], int b[4], int swapuuid); extern void copy_uuid(void *a, int b[4], int swapuuid); extern char *fname_from_uuid(struct supertype *st, diff --git a/super-intel.c b/super-intel.c index 108f0b4f..7962ac36 100644 --- a/super-intel.c +++ b/super-intel.c @@ -785,6 +785,7 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info) struct intel_super *super = st->sb; struct imsm_disk *disk; __u32 s; + int is_spare = 0; if (super->current_vol >= 0) { getinfo_super_imsm_volume(st, info); @@ -826,8 +827,13 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info) info->disk.state = s & CONFIGURED_DISK ? (1 << MD_DISK_ACTIVE) : 0; info->disk.state |= s & FAILED_DISK ? (1 << MD_DISK_FAULTY) : 0; info->disk.state |= s & USABLE_DISK ? (1 << MD_DISK_SYNC) : 0; + if (s & SPARE_DISK) + is_spare = 1; } - uuid_from_super_imsm(st, info->uuid); + if (is_spare) + memcpy(info->uuid, uuid_match_any, sizeof(int[4])); + else + uuid_from_super_imsm(st, info->uuid); } static int update_super_imsm(struct supertype *st, struct mdinfo *info, diff --git a/util.c b/util.c index 4c049423..f6e4dd0e 100644 --- a/util.c +++ b/util.c @@ -222,8 +222,13 @@ int enough(int level, int raid_disks, int layout, int clean, } } +const int uuid_match_any[4] = { ~0, ~0, ~0, ~0 }; int same_uuid(int a[4], int b[4], int swapuuid) { + if (memcmp(a, uuid_match_any, sizeof(int[4])) == 0 || + memcmp(b, uuid_match_any, sizeof(int[4])) == 0) + return 1; + if (swapuuid) { /* parse uuids are hostendian. * uuid's from some superblocks are big-ending