summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-07-18 14:46:08 -0500
committerDavid Teigland <teigland@redhat.com>2016-07-18 14:46:08 -0500
commiteede6da120249f0fcffe088176b2d43d71f6f642 (patch)
treeda4d913288bdfe88ea62da2387e3730cba6767fb
parent4b4d4670042db3edb1270097f4d6046a6a827bac (diff)
downloadlvm2-dev-dct-lvmetad-fix-update.tar.gz
lvmetad: only update with committed metadatadev-dct-lvmetad-fix-update
This fixes a regression from commit a7c45ddc5, which moved the lvmetad VG update from vg_commit() to unlock_vg(). The lvmetad VG update needs to send the version of metadata that was committed (and is already being preserved for this purpose), rather than sending whatever 'vg' represents. The 'vg' may have been partially modified since vg_commit(), and contain non-committed metadata that shouldn't be sent to lvmetad.
-rw-r--r--lib/cache/lvmetad.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index c320b1c82..401df7ce1 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -1199,6 +1199,7 @@ int lvmetad_vg_update_finish(struct volume_group *vg)
struct dm_hash_node *n;
struct metadata_area *mda;
char mda_id[128], *num;
+ struct volume_group *vgc;
struct dm_config_tree *vgmeta;
struct pv_list *pvl;
struct lvmcache_info *info;
@@ -1216,7 +1217,13 @@ int lvmetad_vg_update_finish(struct volume_group *vg)
if (!id_write_format(&vg->id, uuid, sizeof(uuid)))
return_0;
- if (!(vgmeta = export_vg_to_config_tree(vg))) {
+ /*
+ * vg->vg_committted is the state of the VG metadata when vg_commit()
+ * was called. Since then, vg-> may have been partially modified and
+ * not committed. We only want to send committed metadata to lvmetad.
+ */
+
+ if (!(vgmeta = export_vg_to_config_tree(vg->vg_committed))) {
log_error("Failed to export VG to config tree.");
return 0;
}
@@ -1242,11 +1249,13 @@ int lvmetad_vg_update_finish(struct volume_group *vg)
daemon_reply_destroy(reply);
- n = (vg->fid && vg->fid->metadata_areas_index) ?
- dm_hash_get_first(vg->fid->metadata_areas_index) : NULL;
+ vgc = vg->vg_committed;
+
+ n = (vgc->fid && vgc->fid->metadata_areas_index) ?
+ dm_hash_get_first(vgc->fid->metadata_areas_index) : NULL;
while (n) {
- mda = dm_hash_get_data(vg->fid->metadata_areas_index, n);
- (void) dm_strncpy(mda_id, dm_hash_get_key(vg->fid->metadata_areas_index, n), sizeof(mda_id));
+ mda = dm_hash_get_data(vgc->fid->metadata_areas_index, n);
+ (void) dm_strncpy(mda_id, dm_hash_get_key(vgc->fid->metadata_areas_index, n), sizeof(mda_id));
if ((num = strchr(mda_id, '_'))) {
*num = 0;
++num;
@@ -1257,13 +1266,13 @@ int lvmetad_vg_update_finish(struct volume_group *vg)
lvmcache_foreach_mda(info, _fixup_ignored, &baton);
}
}
- n = dm_hash_get_next(vg->fid->metadata_areas_index, n);
+ n = dm_hash_get_next(vgc->fid->metadata_areas_index, n);
}
- dm_list_iterate_items(pvl, &vg->pvs) {
+ dm_list_iterate_items(pvl, &vgc->pvs) {
/* NB. the PV fmt pointer is sometimes wrong during vgconvert */
if (pvl->pv->dev && !lvmetad_pv_found(vg->cmd, &pvl->pv->id, pvl->pv->dev,
- vg->fid ? vg->fid->fmt : pvl->pv->fmt,
+ vgc->fid ? vgc->fid->fmt : pvl->pv->fmt,
pvl->pv->label_sector, NULL, NULL, NULL))
return 0;
}