]> sourceware.org Git - lvm2.git/commitdiff
lvmetad: Avoid stale PV -> VG mappings on metadata update.
authorPetr Rockai <prokai@redhat.com>
Wed, 20 Jul 2011 18:45:32 +0000 (18:45 +0000)
committerPetr Rockai <prokai@redhat.com>
Wed, 20 Jul 2011 18:45:32 +0000 (18:45 +0000)
daemons/lvmetad/lvmetad-core.c

index c3226e0140f0792cb9f041b608c66c5f5d296e45..158734f63b9f98f3a5aabed8f1102eabb430bd38 100644 (file)
@@ -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;
 }
This page took 0.040976 seconds and 5 git commands to generate.