Skip to contentSkip to conversation

master - pvchange, pvresize: fix lockd_gl() usage

PATCH David Teigland 1 participant 1 message Jan 18, 2016

lore
Share & tools
lore
#0 lore raw
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(-)
tools/pvchange.c +5 -2
index 91e93c1..fad28d1 100644
@@ -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 */
tools/pvresize.c +5 -2
index 0b055e6..ad59bae 100644
@@ -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;