]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Allow a uuid of all f's to always match
authorDan Williams <dan.j.williams@intel.com>
Thu, 2 Oct 2008 01:50:44 +0000 (18:50 -0700)
committerDan Williams <dan.j.williams@intel.com>
Wed, 15 Oct 2008 21:43:57 +0000 (14:43 -0700)
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 <dan.j.williams@intel.com>
mdadm.h
super-intel.c
util.c

diff --git a/mdadm.h b/mdadm.h
index 7a39187e28cacd3b1018f88d3ac454831e805e99..1eba5783231ee5530402848e8814ae15d39d3140 100644 (file)
--- 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,
index 108f0b4f5d6cafe7a410ba36f939782460d705bd..7962ac365bbd5d2c51a0b1c08ccd7445678d059b 100644 (file)
@@ -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 4c0494236dfd6a97bf0d838d083346cf95c467ae..f6e4dd0eb19fed3a9c2875d7a1531cddae77c85d 100644 (file)
--- 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