From 7a70e8aa8d47376ca37a1fe2c38f1db5c14aa36d Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 23 Feb 2009 14:26:11 -0700 Subject: imsm: fixup container spare uuids by default 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 --- super-intel.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'super-intel.c') diff --git a/super-intel.c b/super-intel.c index 4e75132..be01f32 100644 --- a/super-intel.c +++ b/super-intel.c @@ -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, -- cgit