summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2015-06-17 15:12:45 -0500
committerDavid Teigland <teigland@redhat.com>2015-06-23 17:08:54 -0500
commit3f63e708999d8663e3dd941cb21b1403cbc769d5 (patch)
tree9096d882ace23521efa35d4c9f06da8eb97d90a9
parentd037aa2e3e7e77f5b3a66cae1d18863b09e1708d (diff)
downloadlvm2-3f63e708999d8663e3dd941cb21b1403cbc769d5.tar.gz
lvmlockd: validate global cache for first gl lock
-rw-r--r--daemons/lvmlockd/lvmlockd-core.c13
-rw-r--r--daemons/lvmlockd/lvmlockd-internal.h1
2 files changed, 13 insertions, 1 deletions
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index cd48a90d9..12a24bbbe 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -1046,7 +1046,7 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
/* lm_lock() reads new r_version */
- if (r_version > r->version) {
+ if ((r_version > r->version) || (!r->version && !r->version_zero_valid)) {
/*
* New r_version of the lock: means that another
* host has changed data protected by this lock
@@ -1057,6 +1057,17 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
r->version = r_version;
/*
+ * When a new global lock is enabled in a new vg,
+ * it will have version zero, and the first time
+ * we use it we need to validate the global cache
+ * since we don't have any version history to know
+ * the state of the cache. The version could remain
+ * zero for a long time if no global state is changed
+ * to cause the GL version to be incremented to 1.
+ */
+ r->version_zero_valid = 1;
+
+ /*
* r is vglk: tell lvmetad to set the vg invalid
* flag, and provide the new r_version. If lvmetad finds
* that its cached vg has seqno less than the value
diff --git a/daemons/lvmlockd/lvmlockd-internal.h b/daemons/lvmlockd/lvmlockd-internal.h
index 39085a6fc..b6f4056f6 100644
--- a/daemons/lvmlockd/lvmlockd-internal.h
+++ b/daemons/lvmlockd/lvmlockd-internal.h
@@ -140,6 +140,7 @@ struct resource {
uint32_t version;
unsigned int lm_init : 1; /* lm_data is initialized */
unsigned int adopt : 1; /* temp flag in remove_inactive_lvs */
+ unsigned int version_zero_valid : 1;
struct list_head locks;
struct list_head actions;
struct val_blk *vb;