summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-01-13 15:55:41 -0600
committerDavid Teigland <teigland@redhat.com>2016-01-13 16:40:02 -0600
commit9e9c7575413dca7a1ac7a5f363d1c7a464f86c3d (patch)
treec45e6866277a75e1a48ce985435fe81ca2b7c616
parent1b1f42b49005665e669b52f78864cad59d81f64b (diff)
downloadlvm2-9e9c7575413dca7a1ac7a5f363d1c7a464f86c3d.tar.gz
vgchange: fix lockd_gl results
The wrong error value was being checked from lockd_gl() in two cases. Clarify the use of lockd_gl() in the lock-start case.
-rw-r--r--tools/vgchange.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 62e602a6c..6cbb04235 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -1046,11 +1046,26 @@ static int _lockd_vgchange(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, lockstop_ARG))
cmd->lockd_vg_default_sh = 1;
- /* Starting a vg lockspace means there are no locks available yet. */
-
- if (arg_is_set(cmd, lockstart_ARG))
+ /*
+ * Starting lockspaces. For VGs not yet started, locks are not
+ * available to acquire, and for VGs already started, there's nothing
+ * to do, so disable VG locks. Try to acquire the global lock sh to
+ * validate the cache (if no gl is available, lockd_gl will force a
+ * cache validation). If the global lock is available, it can be
+ * benficial to hold sh to serialize lock-start with vgremove of the
+ * same VG from another host.
+ */
+ if (arg_is_set(cmd, lockstart_ARG)) {
cmd->lockd_vg_disable = 1;
+ if (!lockd_gl(cmd, "sh", 0))
+ log_debug("No global lock for lock start");
+
+ /* Disable the lockd_gl in process_each_vg. */
+ cmd->lockd_gl_disable = 1;
+ return 1;
+ }
+
/*
* Changing system_id or lock_type must only be done on explicitly
* named vgs.
@@ -1059,17 +1074,7 @@ static int _lockd_vgchange(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, systemid_ARG) || arg_is_set(cmd, locktype_ARG))
cmd->command->flags &= ~ALL_VGS_IS_DEFAULT;
- if (arg_is_set(cmd, lockstart_ARG)) {
- /*
- * The lockstart condition takes the global lock to serialize
- * with any other host that tries to remove the VG while this
- * tries to start it. (Zero argc means all VGs, in wich case
- * process_each_vg will acquire the global lock.)
- */
- if (argc && !lockd_gl(cmd, "sh", 0))
- return_ECMD_FAILED;
-
- } else if (arg_is_set(cmd, systemid_ARG) || arg_is_set(cmd, locktype_ARG)) {
+ if (arg_is_set(cmd, systemid_ARG) || arg_is_set(cmd, locktype_ARG)) {
/*
* This is a special case where taking the global lock is
* not needed to protect global state, because the change is
@@ -1079,7 +1084,7 @@ static int _lockd_vgchange(struct cmd_context *cmd, int argc, char **argv)
* lock_type.
*/
if (!lockd_gl(cmd, "ex", LDGL_UPDATE_NAMES))
- return_ECMD_FAILED;
+ return 0;
}
return 1;