summaryrefslogtreecommitdiffstats
path: root/super-intel.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-07-31 17:11:41 -0700
committerDan Williams <dan.j.williams@intel.com>2009-07-31 17:11:41 -0700
commit9b1fb67776d63a491df3e7aa13916cd122436e20 (patch)
tree420e3b233adccbba3c1572c8b03a3b81259a1e6b /super-intel.c
parent0d5a423fe7481de5ce20c6174841afeb1aadd255 (diff)
downloadmdadm-9b1fb67776d63a491df3e7aa13916cd122436e20.tar.gz
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 'super-intel.c')
-rw-r--r--super-intel.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/super-intel.c b/super-intel.c
index 207d3be..56947de 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -2724,17 +2724,16 @@ static int write_super_imsm(struct intel_super *super, int doclose)
}
-static int create_array(struct supertype *st)
+static int create_array(struct supertype *st, int dev_idx)
{
size_t len;
struct imsm_update_create_array *u;
struct intel_super *super = st->sb;
- struct imsm_dev *dev = get_imsm_dev(super, super->current_vol);
+ struct imsm_dev *dev = get_imsm_dev(super, dev_idx);
struct imsm_map *map = get_imsm_map(dev, 0);
struct disk_info *inf;
struct imsm_disk *disk;
int i;
- int idx;
len = sizeof(*u) - sizeof(*dev) + sizeof_imsm_dev(dev, 0) +
sizeof(*inf) * map->num_members;
@@ -2746,11 +2745,12 @@ static int create_array(struct supertype *st)
}
u->type = update_create_array;
- u->dev_idx = super->current_vol;
+ u->dev_idx = dev_idx;
imsm_copy_dev(&u->dev, dev);
inf = get_disk_info(u);
for (i = 0; i < map->num_members; i++) {
- idx = get_imsm_disk_idx(dev, i);
+ int idx = get_imsm_disk_idx(dev, i);
+
disk = get_imsm_disk(super, idx);
serialcpy(inf[i].serial, disk->serial);
}
@@ -2784,21 +2784,26 @@ static int _add_disk(struct supertype *st)
static int write_init_super_imsm(struct supertype *st)
{
+ struct intel_super *super = st->sb;
+ int current_vol = super->current_vol;
+
+ /* we are done with current_vol reset it to point st at the container */
+ super->current_vol = -1;
+
if (st->update_tail) {
/* queue the recently created array / added disk
* as a metadata update */
- struct intel_super *super = st->sb;
struct dl *d;
int rv;
/* determine if we are creating a volume or adding a disk */
- if (super->current_vol < 0) {
+ if (current_vol < 0) {
/* in the add disk case we are running in mdmon
* context, so don't close fd's
*/
return _add_disk(st);
} else
- rv = create_array(st);
+ rv = create_array(st, current_vol);
for (d = super->disks; d ; d = d->next) {
close(d->fd);