diff options
author | Dan Williams <dan.j.williams@intel.com> | 2009-08-01 02:11:41 +0200 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-08-01 02:11:41 +0200 |
commit | 9b1fb67776d63a491df3e7aa13916cd122436e20 (patch) | |
tree | 420e3b233adccbba3c1572c8b03a3b81259a1e6b /Create.c | |
parent | imsm: fixup examine_brief to be more descriptive in the container only case (diff) | |
download | mdadm-9b1fb67776d63a491df3e7aa13916cd122436e20.tar.xz mdadm-9b1fb67776d63a491df3e7aa13916cd122436e20.zip |
conditionally update uuids in the map file after Create()
The map file needs to be updated after adding the first member array to
an Intel metadata container. The uuid for an imsm container uses the
->family_num field of the metadata. This field is static, but is only
set after the first member array has been created. Prior to this all
devices are free floating spares and do not have any information that
can identify specific container membership. At Create() time we take
the uninitialized uuid from ->get_info_super() prior to updating the
metadata. So the current result is:
# mdadm --create /dev/md/imsm /dev/sd[b-e] -n 4 -e imsm
# mdadm --create /dev/md/vol0 /dev/md/imsm -n 4 -l 0
# cat /var/run/mdadm/map
md126 /md127/0 3e03aee2:78c3c593:1e8ecaf0:eefb53ed /dev/md/vol0
md127 imsm 53d6f8b1:7a783f24:f30483c5:705c48c7 /dev/md/imsm
# mdadm -Ebs
ARRAY metadata=imsm UUID=589d2d2c:4221a54d:acb63c06:c3907f52
ARRAY /dev/md/vol0 container=589d2d2c:4221a54d:acb63c06:c3907f52
member=0 UUID=57b89b63:5cd0eae1:17dd26b3:51cc78d4
So, before we write out the new metadata check to see if the member
array uuid has changed as a result of this addition. If it has, update
its uuid in the map file and flag its parent container for updating. In
support of updating the container uuid the semantics of
->write_init_super are changed to clear any metadata specific member
array cursors (e.g. ddf_super.currentconf or intel_super.current_vol)
such that a subsequent call to ->getinfo_super returns container
information.
Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'Create.c')
-rw-r--r-- | Create.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -792,7 +792,39 @@ int Create(struct supertype *st, char *mddev, dv == moved_disk && dnum != insert_point) break; } if (pass == 1) { + struct mdinfo info_new; + struct map_ent *me = NULL; + + /* check to see if the uuid has changed due to these + * metadata changes, and if so update the member array + * and container uuid. Note ->write_init_super clears + * the subarray cursor such that ->getinfo_super once + * again returns container info. + */ + map_lock(&map); + st->ss->getinfo_super(st, &info_new); + if (st->ss->external && level != LEVEL_CONTAINER && + !same_uuid(info_new.uuid, info.uuid, 0)) { + map_update(&map, fd2devnum(mdfd), + info_new.text_version, + info_new.uuid, chosen_name); + me = map_by_devnum(&map, st->container_dev); + } + st->ss->write_init_super(st); + + /* update parent container uuid */ + if (me) { + char *path = strdup(me->path); + + st->ss->getinfo_super(st, &info_new); + map_update(&map, st->container_dev, + info_new.text_version, + info_new.uuid, path); + free(path); + } + map_unlock(&map); + flush_metadata_updates(st); } } |