[lvm-devel] master - use exclusive file lock on VG for activation

Joe Thornber thornber at sourceware.org
Thu Jun 7 15:22:07 UTC 2018


Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=616eeba6f2b33640534e26dea43661724edf3a14
Commit:        616eeba6f2b33640534e26dea43661724edf3a14
Parent:        e7aa51c70f17af10df906a7e123a497c1cf3c1ba
Author:        David Teigland <teigland at redhat.com>
AuthorDate:    Wed Jun 6 11:14:39 2018 -0500
Committer:     Joe Thornber <ejt at redhat.com>
CommitterDate: Thu Jun 7 16:17:04 2018 +0100

use exclusive file lock on VG for activation

Make activation commands:
  vgchange -ay, lvchange -ay, pvscan -aay

take an exclusive file lock on the VG to serialize
multiple concurrent activation commands which could
otherwise interfere with each other.
---
 tools/lvchange.c |    2 +-
 tools/pvscan.c   |    2 +-
 tools/vgchange.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/lvchange.c b/tools/lvchange.c
index a90174e..3ed6b06 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1386,7 +1386,7 @@ int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv)
 	} else /* Component LVs might be active, support easy deactivation */
 		cmd->process_component_lvs = 1;
 
-	ret = process_each_lv(cmd, argc, argv, NULL, NULL, 0,
+	ret = process_each_lv(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE,
 			      NULL, &_lvchange_activate_check, &_lvchange_activate_single);
 
 	if (ret != ECMD_PROCESSED)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 7cba0f4..61626e6 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -288,7 +288,7 @@ static int _pvscan_autoactivate(struct cmd_context *cmd, struct pvscan_aa_params
 		pp->refresh_all = 1;
 	}
 
-	ret = process_each_vg(cmd, 0, NULL, NULL, vgnames, 0, 0, handle, _pvscan_autoactivate_single);
+	ret = process_each_vg(cmd, 0, NULL, NULL, vgnames, READ_FOR_UPDATE, 0, handle, _pvscan_autoactivate_single);
 
 	destroy_processing_handle(cmd, handle);
 
diff --git a/tools/vgchange.c b/tools/vgchange.c
index a67c3be..b07057f 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -791,7 +791,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
 			cmd->lockd_vg_enforce_sh = 1;
 	}
 
-	if (update)
+	if (update || arg_is_set(cmd, activate_ARG))
 		flags |= READ_FOR_UPDATE;
 
 	if (!(handle = init_processing_handle(cmd, NULL))) {




More information about the lvm-devel mailing list