summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2015-07-02 10:43:13 -0500
committerDavid Teigland <teigland@redhat.com>2015-07-02 10:43:13 -0500
commit9eab3fe140d4f640ab1b7fa748750686cf6ce7c8 (patch)
tree4b7b9cab2d35415b8b1a71993438afaea469770e
parent89e6bc061684e4d81988bbfc0fdf34fb12a4dd68 (diff)
downloadlvm2-9eab3fe140d4f640ab1b7fa748750686cf6ce7c8.tar.gz
Fix global lock with vgremove @tag
A very special case where we need to disable the gl after lockd_gl(ex) to prevent process_each_vg from changing it with lockd_gl(sh).
-rw-r--r--lib/commands/toolcontext.h1
-rw-r--r--lib/locking/lvmlockd.c9
-rw-r--r--tools/vgremove.c7
3 files changed, 17 insertions, 0 deletions
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 33c4706cc..5e43dd8e0 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -103,6 +103,7 @@ struct cmd_context {
unsigned include_shared_vgs:1; /* report/display cmds can reveal lockd VGs */
unsigned include_active_foreign_vgs:1; /* cmd should process foreign VGs with active LVs */
unsigned vg_read_print_access_error:1; /* print access errors from vg_read */
+ unsigned lockd_gl_disable:1;
unsigned lockd_vg_disable:1;
unsigned lockd_lv_disable:1;
unsigned lockd_vg_default_sh:1;
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index d4f9dcd66..9a8c4b4e3 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -1324,6 +1324,12 @@ int lockd_gl_create(struct cmd_context *cmd, const char *def_mode, const char *v
* if the local version number is lower than the version number in the
* lock, then the local lvmetad state must be updated.
*
+ * There are two cases where the global lock can be taken in shared mode,
+ * and then later converted to ex. pvchange and pvresize use process_each_pv
+ * which does lockd_gl("sh") to get the list of VGs. Later, in the "_single"
+ * function called within process_each_pv, the PV may be an orphan, in which
+ * case the ex global lock is needed, so it's converted to ex at that point.
+ *
* Effects of misconfiguring use_lvmlockd.
*
* - Setting use_lvmlockd=1 tells lvm commands to use the global lock.
@@ -1366,6 +1372,9 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
if (!_use_lvmlockd)
return 1;
+ if (cmd->lockd_gl_disable)
+ return 1;
+
if (def_mode && !strcmp(def_mode, "un")) {
if (cmd->lock_gl_mode && !strcmp(cmd->lock_gl_mode, "na"))
return 1;
diff --git a/tools/vgremove.c b/tools/vgremove.c
index 7c1f0ee4e..692d11461 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -101,6 +101,13 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
if (!lockd_gl(cmd, "ex", LDGL_UPDATE_NAMES))
return ECMD_FAILED;
+ /*
+ * This is a special case: if vgremove is given a tag, it causes
+ * process_each_vg to do lockd_gl(sh) when getting a list of all
+ * VG names. We don't want the gl converted to sh, so disable it.
+ */
+ cmd->lockd_gl_disable = 1;
+
cmd->handles_missing_pvs = 1;
ret = process_each_vg(cmd, argc, argv,
READ_FOR_UPDATE,