summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2015-05-29 10:08:09 -0500
committerDavid Teigland <teigland@redhat.com>2015-06-02 11:39:34 -0500
commitdecd8234e28a717383400883133761d9931a19e4 (patch)
treeee9e1efb13ad7db5f4213d979c62a077cf8c1ff5
parentcdff5cb1695cab77dbebef0833b8a6c71cba6437 (diff)
downloadlvm2-decd8234e28a717383400883133761d9931a19e4.tar.gz
vgcreate: option to allow waiting for lock start
vgcreate with '--lock-opt wait' will cause the command to wait for the lock start to complete before returning, the same as when starting explicitly with 'vgchange --lock-start --lock-opt wait'
-rw-r--r--tools/commands.h2
-rw-r--r--tools/vgcreate.c20
2 files changed, 18 insertions, 4 deletions
diff --git a/tools/commands.h b/tools/commands.h
index 5bb3a69a4..86635883d 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -1136,7 +1136,7 @@ xx(vgcreate,
physicalextentsize_ARG, test_ARG, force_ARG, zero_ARG, labelsector_ARG,
metadatasize_ARG, pvmetadatacopies_ARG, metadatacopies_ARG,
vgmetadatacopies_ARG, dataalignment_ARG, dataalignmentoffset_ARG,
- systemid_ARG, locktype_ARG)
+ systemid_ARG, locktype_ARG, lockopt_ARG)
xx(vgdisplay,
"Display volume group information",
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 5fe9687aa..a3a9b6eea 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -140,10 +140,24 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
clustered_message, *clustered_message ? 'v' : 'V', vg->name,
vg->system_id ? " with system ID " : "", vg->system_id ? : "");
- /* Start the VG lockspace because it will likely be used right away. */
- if (!lockd_start_vg(cmd, vg))
- log_error("Failed to start locking");
+ /*
+ * Start the VG lockspace because it will likely be used right away.
+ * Optionally wait for the start to complete so the VG can be fully
+ * used after this command completes (otherwise, the VG can only be
+ * read without locks until the lockspace is done starting.)
+ */
+ if (is_lockd_type(vg->lock_type)) {
+ const char *start_opt = arg_str_value(cmd, lockopt_ARG, NULL);
+
+ if (!lockd_start_vg(cmd, vg)) {
+ log_error("Failed to start locking");
+ goto out;
+ }
+ if (start_opt && !strcmp(start_opt, "wait"))
+ lockd_start_wait(cmd);
+ }
+out:
release_vg(vg);
return ECMD_PROCESSED;