summaryrefslogtreecommitdiffstats
path: root/daemons/lvmetad/lvmetad-core.c
diff options
context:
space:
mode:
authorPetr Rockai <prockai@redhat.com>2011-07-20 18:45:32 +0000
committerPetr Rockai <prockai@redhat.com>2011-07-20 18:45:32 +0000
commitdcbf5a3b5d307c941a4e04f1b7abd90fcbdf0198 (patch)
treeaf26d21fbd1a7fddc7b0574daf73f8ad7bff881d /daemons/lvmetad/lvmetad-core.c
parentcd7bca83e12c56095cc5ac1b676e8f63727d0a1a (diff)
downloadlvm2-dcbf5a3b5d307c941a4e04f1b7abd90fcbdf0198.tar.gz
lvm2-dcbf5a3b5d307c941a4e04f1b7abd90fcbdf0198.tar.xz
lvm2-dcbf5a3b5d307c941a4e04f1b7abd90fcbdf0198.zip
lvmetad: Avoid stale PV -> VG mappings on metadata update.
Diffstat (limited to 'daemons/lvmetad/lvmetad-core.c')
-rw-r--r--daemons/lvmetad/lvmetad-core.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index c3226e01..158734f6 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -146,10 +146,9 @@ static void update_pv_status(lvmetad_state *s, const char *pvid)
}
}
-int update_pvid_map(lvmetad_state *s, struct config_tree *vg)
+int update_pvid_map(lvmetad_state *s, struct config_tree *vg, const char *vgid)
{
struct config_node *pv = pvs(vg);
- char *vgid = find_config_str(vg->root, "metadata/id", NULL);
if (!vgid)
return 0;
@@ -163,9 +162,9 @@ int update_pvid_map(lvmetad_state *s, struct config_tree *vg)
return 1;
}
-static int update_metadata(lvmetad_state *s, const char *vgid, struct config_node *metadata)
+static int update_metadata(lvmetad_state *s, const char *_vgid, struct config_node *metadata)
{
- struct config_tree *old = dm_hash_lookup(s->vgs, vgid);
+ struct config_tree *old = dm_hash_lookup(s->vgs, _vgid);
int seq = find_config_int(metadata, "metadata/seqno", -1);
int haveseq = -1;
@@ -186,16 +185,23 @@ static int update_metadata(lvmetad_state *s, const char *vgid, struct config_nod
return 1;
}
+ struct config_tree *cft = create_config_tree(NULL, 0);
+ cft->root = clone_config_node(cft, metadata, 0);
+ const char *vgid = find_config_str(cft->root, "metadata/id", NULL);
+
+ if (!vgid)
+ return 0;
+
if (haveseq >= 0 && haveseq < seq) {
+ /* temporarily orphan all of our PVs */
+ update_pvid_map(s, old, "#orphan");
/* need to update what we have since we found a newer version */
destroy_config_tree(old);
dm_hash_remove(s->vgs, vgid);
}
- struct config_tree *cft = create_config_tree(NULL, 0);
- cft->root = clone_config_node(cft, metadata, 0);
dm_hash_insert(s->vgs, vgid, cft);
- update_pvid_map(s, cft);
+ update_pvid_map(s, cft, vgid);
return 1;
}