summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2014-12-04 16:58:10 -0600
committerDavid Teigland <teigland@redhat.com>2014-12-09 15:45:41 -0600
commit6bea241b977a54ae04f723c145745ae6483b1b74 (patch)
tree29f02a9a2c45389bc98c4d14aa96d289204b0a5a
parent367ca05c3bf1d9487dc86d13be5e59c4c3c368cb (diff)
downloadlvm2-6bea241b977a54ae04f723c145745ae6483b1b74.tar.gz
pvscan: notify lvmlockd of lvmetad updates
lvmlockd keeps track of local vgs so that it can quickly determine if a vg lock request can be ignored (for a local vg) or is needed (for a lockd vg).
-rw-r--r--lib/locking/lvmlockd.c24
-rw-r--r--lib/locking/lvmlockd.h2
-rw-r--r--tools/pvscan.c16
3 files changed, 42 insertions, 0 deletions
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 88c9040d9..7f99a557a 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -1910,3 +1910,27 @@ int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg,
}
}
+int lockd_update_local(struct cmd_context *cmd)
+{
+ daemon_reply reply;
+ int result;
+ int ret;
+
+ reply = _lockd_send("update_local",
+ "pid = %d", getpid(),
+ NULL);
+
+ if (!_lockd_result(reply, &result, NULL)) {
+ ret = 0;
+ } else {
+ ret = (result < 0) ? 0 : 1;
+ }
+
+ if (!ret) {
+ log_error("lockd_update_local lvmlockd result %d", result);
+ }
+
+ daemon_reply_destroy(reply);
+
+ return ret;
+}
diff --git a/lib/locking/lvmlockd.h b/lib/locking/lvmlockd.h
index 0972cf3ac..4917beae4 100644
--- a/lib/locking/lvmlockd.h
+++ b/lib/locking/lvmlockd.h
@@ -104,6 +104,7 @@ void lockd_free_vg_final(struct cmd_context *cmd, struct volume_group *vg);
int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg);
int lockd_stop_vg(struct cmd_context *cmd, struct volume_group *vg);
int lockd_start_wait(struct cmd_context *cmd);
+int lockd_update_local(struct cmd_context *cmd);
/* locking */
@@ -146,6 +147,7 @@ int lockd_init_lv_args(struct cmd_context *cmd, struct volume_group *vg,
#define lockd_start_vg(cmd, vg) (1)
#define lockd_stop_vg(cmd, vg) (1)
#define lockd_start_wait(cmd) (1)
+#define lockd_update_local(cmd) (1)
#define lockd_gl_create(cmd, def_mode, vg_lock_type) (1)
#define lockd_gl(cmd, def_mode, flags) (1)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 9fcd7d155..1645821ed 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -314,6 +314,22 @@ out:
sync_local_dev_names(cmd);
unlock_vg(cmd, VG_GLOBAL);
+ /*
+ * lvmlockd wants to know about any new local vgs that
+ * have been added to lvmetad. If not done automatically
+ * here, then an explicit vgchange --lock-start would be
+ * needed to cause lvmlockd to update its list of local vgs
+ * from lvmetad. We could possibly optimize this by only
+ * calling this if a new vg has been found.
+ *
+ * This will do nothing during startup because lvmlockd is
+ * not yet running. lvmlockd will get an initial list of
+ * local vgs from lvmetad when it's started. This call is
+ * for the case when lvmetad/lvmlockd are already running
+ * and a new local vg appears to the system.
+ */
+ lockd_update_local(cmd);
+
return ret;
}