]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
imsm: fixup container spare uuids by default
authorDan Williams <dan.j.williams@intel.com>
Mon, 23 Feb 2009 21:26:11 +0000 (14:26 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 24 Feb 2009 06:06:24 +0000 (23:06 -0700)
Spares in the imsm case are marked with the "match-all" uuid of
ffffffff-ffffffff-ffffffff-ffffffff.  When performing incremental
assembly we need to associate such devices with a populated container
uuid.  Also when performing --detail on a container with only spares
present we can make an attempt to return a real uuid.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
super-intel.c

index 4e7513265a5d31c4fbb21eef5eb8af5c2d80b7ca..be01f325c02c238a01d509f70b8db5b9aee1836d 100644 (file)
@@ -1152,6 +1152,32 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info)
        uuid_from_super_imsm(st, info->uuid);
 }
 
+/* check the config file to see if we can return a real uuid for this spare */
+static void fixup_container_spare_uuid(struct mdinfo *inf)
+{
+       struct mddev_ident_s *array_list;
+
+       if (inf->array.level != LEVEL_CONTAINER ||
+           memcmp(inf->uuid, uuid_match_any, sizeof(int[4])) != 0)
+               return;
+
+       array_list = conf_get_ident(NULL);
+
+       for (; array_list; array_list = array_list->next) {
+               if (array_list->uuid_set) {
+                       struct supertype *_sst; /* spare supertype */
+                       struct supertype *_cst; /* container supertype */
+
+                       _cst = array_list->st;
+                       _sst = _cst->ss->match_metadata_desc(inf->text_version);
+                       if (_sst) {
+                               memcpy(inf->uuid, array_list->uuid, sizeof(int[4]));
+                               free(_sst);
+                               break;
+                       }
+               }
+       }
+}
 
 static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info)
 {
@@ -1207,8 +1233,10 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info)
         */
        if (info->disk.state & (1 << MD_DISK_SYNC) || super->anchor->num_raid_devs)
                uuid_from_super_imsm(st, info->uuid);
-       else
+       else {
                memcpy(info->uuid, uuid_match_any, sizeof(int[4]));
+               fixup_container_spare_uuid(info);
+       }
 }
 
 static int update_super_imsm(struct supertype *st, struct mdinfo *info,