]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
imsm: copy raid device info when associating spares
authorDan Williams <dan.j.williams@intel.com>
Tue, 28 Oct 2008 17:55:31 +0000 (10:55 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 28 Oct 2008 17:55:31 +0000 (10:55 -0700)
If a spare is included in the list of examined disks we need to copy in at
least enough information to get the uuid of the populated container.

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

index babb098499478df6756a725009c513c0aec91546..68ecbe4a0db5cc0a302c407bd43bbac8dd6181c1 100644 (file)
@@ -938,6 +938,24 @@ static int compare_super_imsm(struct supertype *st, struct supertype *tst)
         */
        if (first->anchor->num_raid_devs == 0 &&
            sec->anchor->num_raid_devs > 0) {
+               int i;
+
+               /* we need to copy raid device info from sec if an allocation
+                * fails here we don't associate the spare
+                */
+               for (i = 0; i < sec->anchor->num_raid_devs; i++) {
+                       first->dev_tbl[i] = malloc(sizeof(struct imsm_dev));
+                       if (!first->dev_tbl) {
+                               while (--i >= 0) {
+                                       free(first->dev_tbl[i]);
+                                       first->dev_tbl[i] = NULL;
+                               }
+                               fprintf(stderr, "imsm: failed to associate spare\n"); 
+                               return 3;
+                       }
+                       *first->dev_tbl[i] = *sec->dev_tbl[i];
+               }
+
                first->anchor->num_raid_devs = sec->anchor->num_raid_devs;
                first->anchor->family_num = sec->anchor->family_num;
        }