From: Dan Williams Date: Tue, 28 Oct 2008 17:55:31 +0000 (-0700) Subject: imsm: copy raid device info when associating spares X-Git-Tag: mdadm-3.0-devel2~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78d30f94c48020f4efcefe8332095e58a99f1e17;p=thirdparty%2Fmdadm.git imsm: copy raid device info when associating spares 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 --- diff --git a/super-intel.c b/super-intel.c index babb0984..68ecbe4a 100644 --- a/super-intel.c +++ b/super-intel.c @@ -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; }