master - pvchange, pvresize: fix lockd_gl() usage

David Teigland <[email protected]>
Newsgroups dev.linux.lists.lvm-devel
Message-ID <[email protected]>
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=54b41dcd53d99059b691f72eb6e7556d4341634d
Commit:        54b41dcd53d99059b691f72eb6e7556d4341634d
Parent:        1ee6af344bd805d4fa847b95b326c2fe1e52d7cd
Author:        David Teigland <[email protected]>
AuthorDate:    Fri Jan 15 15:18:25 2016 -0600
Committer:     David Teigland <[email protected]>
CommitterDate: Mon Jan 18 09:35:06 2016 -0600

pvchange, pvresize: fix lockd_gl() usage

When an orphan PV is changed/resized, the
lvmlockd global lock is converted from sh
to ex. If the command is changing two
orphan PVs, the conversion to ex should
be done only once.
---
 tools/pvchange.c |    7 +++++--
 tools/pvresize.c |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/pvchange.c b/tools/pvchange.c
index 91e93c1..fad28d1 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -87,8 +87,11 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
 	 * i.e. the global lock is only needed for orphans.
 	 * Convert sh to ex.
 	 */
-	if (is_orphan(pv) && !lockd_gl(cmd, "ex", 0))
-		return_ECMD_FAILED;
+	if (is_orphan(pv)) {
+		if (!lockd_gl(cmd, "ex", 0))
+			return_ECMD_FAILED;
+		cmd->lockd_gl_disable = 1;
+	}
 
 	if (tagargs) {
 		/* tag or deltag */
diff --git a/tools/pvresize.c b/tools/pvresize.c
index 0b055e6..ad59bae 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -41,8 +41,11 @@ static int _pvresize_single(struct cmd_context *cmd,
 	 * i.e. the global lock is only needed for orphans.
 	 * Convert sh to ex.
 	 */
-	if (is_orphan(pv) && !lockd_gl(cmd, "ex", 0))
-		return_ECMD_FAILED;
+	if (is_orphan(pv)) {
+		if (!lockd_gl(cmd, "ex", 0))
+			return_ECMD_FAILED;
+		cmd->lockd_gl_disable = 1;
+	}
 
 	if (!pv_resize_single(cmd, vg, pv, params->new_size))
 		return_ECMD_FAILED;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.