]> sourceware.org Git - lvm2.git/commitdiff
lvmetad: Give inconsistent metadata warnings in pvscan --cache.
authorPetr Rockai <prockai@redhat.com>
Wed, 19 Sep 2012 21:45:51 +0000 (23:45 +0200)
committerPetr Rockai <prockai@redhat.com>
Wed, 26 Sep 2012 15:26:23 +0000 (17:26 +0200)
daemons/lvmetad/lvmetad-core.c
lib/cache/lvmetad.c

index c6cc3d9fc247b3caf3ebccea51eb07d69688096e..f796e33022f35b58bb825f80a6e38a0a89cba377 100644 (file)
@@ -636,7 +636,7 @@ static int vg_remove_if_missing(lvmetad_state *s, const char *vgid)
  * this function, so they can be safely destroyed after update_metadata returns
  * (anything that might have been retained is copied). */
 static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid,
-                          struct dm_config_node *metadata)
+                          struct dm_config_node *metadata, int64_t *oldseq)
 {
        struct dm_config_tree *cft;
        struct dm_config_tree *old;
@@ -665,6 +665,13 @@ static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid
 
        filter_metadata(metadata); /* sanitize */
 
+       if (oldseq) {
+               if (old)
+                       *oldseq = haveseq;
+               else
+                       *oldseq = seq;
+       }
+
        if (seq == haveseq) {
                retval = 1;
                if (compare_config(metadata, old->root))
@@ -786,6 +793,7 @@ static response pv_found(lvmetad_state *s, request r)
        const char *old;
        const char *pvid_dup;
        int complete = 0, orphan = 0;
+       int64_t seqno = -1, seqno_old = -1;
 
        if (!pvid)
                return reply_fail("need PV UUID");
@@ -830,7 +838,7 @@ static response pv_found(lvmetad_state *s, request r)
                if (daemon_request_int(r, "metadata/seqno", -1) < 0)
                        return reply_fail("need VG seqno");
 
-               if (!update_metadata(s, vgname, vgid, metadata))
+               if (!update_metadata(s, vgname, vgid, metadata, &seqno_old))
                        return reply_fail("metadata update failed");
        } else {
                lock_pvid_to_vgid(s);
@@ -839,9 +847,10 @@ static response pv_found(lvmetad_state *s, request r)
        }
 
        if (vgid) {
-               if ((cft = lock_vg(s, vgid)))
+               if ((cft = lock_vg(s, vgid))) {
                        complete = update_pv_status(s, cft, cft->root, 0);
-               else if (!strcmp(vgid, "#orphan"))
+                       seqno = dm_config_find_int(cft->root, "metadata/seqno", -1);
+               } else if (!strcmp(vgid, "#orphan"))
                        orphan = 1;
                else {
                        unlock_vg(s, vgid);
@@ -854,6 +863,8 @@ static response pv_found(lvmetad_state *s, request r)
                                   "status = %s", orphan ? "orphan" :
                                                     (complete ? "complete" : "partial"),
                                   "vgid = %s", vgid ? vgid : "#orphan",
+                                  "seqno_before = %"PRId64, seqno_old,
+                                  "seqno_after = %"PRId64, seqno,
                                   NULL);
 }
 
@@ -872,7 +883,7 @@ static response vg_update(lvmetad_state *s, request r)
 
                /* TODO defer metadata update here; add a separate vg_commit
                 * call; if client does not commit, die */
-               if (!update_metadata(s, vgname, vgid, metadata))
+               if (!update_metadata(s, vgname, vgid, metadata, NULL))
                        return reply_fail("metadata update failed");
        }
        return daemon_reply_simple("OK", NULL);
index 8ac5732c3b058c5b884e87f78b7e69d6e5e45433..24a6b165c73a5be27125954efac68736094ddef9 100644 (file)
@@ -720,6 +720,11 @@ int lvmetad_pv_found(struct id pvid, struct device *device, const struct format_
 
        result = _lvmetad_handle_reply(reply, "update PV", uuid, NULL);
 
+       if (vg && result &&
+           (daemon_reply_int(reply, "seqno_after", -1) != vg->seqno ||
+            daemon_reply_int(reply, "seqno_after", -1) != daemon_reply_int(reply, "seqno_before", -1)))
+               log_warn("WARNING: Inconsistent metadata found for VG %s", vg->name);
+
        if (result && handler) {
                status = daemon_reply_str(reply, "status", "<missing>");
                if (!strcmp(status, "partial"))
This page took 0.044285 seconds and 5 git commands to generate.