}
}
-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;
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;
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;
}