master - man lvmconfig: refer to typeconfig option name
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=50e0345f9d245c...
Commit: 50e0345f9d245cdcb29e4988760e788defa5e88e
Parent: 10cb8e0ec08d430d697fb8a58caaefb5aea32928
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Feb 17 14:46:10 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Feb 17 14:46:10 2017 -0600
man lvmconfig: refer to typeconfig option name
---
tools/args.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index 1f3ace7..0575a2f 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -546,7 +546,7 @@ arg(shared_ARG, '\0', "shared", 0, 0, 0,
arg(sinceversion_ARG, '\0', "sinceversion", string_VAL, 0, 0,
"Specify an LVM version in x.y.z format where x is the major version,\n"
"the y is the minor version and z is the patchlevel (e.g. 2.2.106).\n"
- "This option is currently applicable only with --type new\n"
+ "This option is currently applicable only with --typeconfig new\n"
"to display all configuration settings introduced since given version.\n")
arg(splitcache_ARG, '\0', "splitcache", 0, 0, 0,
@@ -1024,7 +1024,7 @@ arg(list_ARG, 'l', "list", 0, 0, 0,
"#dumpconfig\n"
"#config\n"
"List config settings with summarizing comment. This is the same as using\n"
- "options --type list --withsummary.\n"
+ "options --typeconfig list --withsummary.\n"
"#vgcfgrestore\n"
"List metadata backup and archive files pertaining to the VG.\n"
"May be used with --file. Does not restore the VG.\n"
7 years, 3 months
master - man/help: show recently added r|R unit
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=10cb8e0ec08d43...
Commit: 10cb8e0ec08d430d697fb8a58caaefb5aea32928
Parent: 3cf394389896a1bd6b3780671e6a6654a925bdd3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Feb 17 14:02:13 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Feb 17 14:44:11 2017 -0600
man/help: show recently added r|R unit
---
tools/args.h | 11 +++++++----
tools/vals.h | 2 +-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index 149b5f6..1f3ace7 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -672,10 +672,13 @@ arg(unconfigured_ARG, '\0', "unconfigured", 0, 0, 0,
"Internal option used for generating config file during build.\n")
arg(units_ARG, '\0', "units", units_VAL, 0, 0,
- "All sizes are output in these units: (h)uman-readable, (b)ytes, (s)ectors,\n"
- "(k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (p)etabytes, (e)xabytes.\n"
- "Capitalise to use multiples of 1000 (S.I.) instead of 1024. Can also specify\n"
- "custom units e.g. --units 3M.\n")
+ "All sizes are output in these units:\n"
+ "human-(r)eadable with rounding,\n"
+ "(h)uman-readable, (b)ytes, (s)ectors, (k)ilobytes, (m)egabytes,\n"
+ "(g)igabytes, (t)erabytes, (p)etabytes, (e)xabytes.\n"
+ "Capitalise to use multiples of 1000 (S.I.) instead of 1024.\n"
+ "Custom units can be specified, e.g. --units 3M.\n"
+ "r|R rounds numbers and displays the '<' prefix before rounded values.\n")
arg(unquoted_ARG, '\0', "unquoted", 0, 0, 0,
"When used with --nameprefixes, output values in the field=value\n"
diff --git a/tools/vals.h b/tools/vals.h
index d9b0064..88c446e 100644
--- a/tools/vals.h
+++ b/tools/vals.h
@@ -122,7 +122,7 @@ val(numsigned_VAL, int_arg_with_sign, "SNumber", "[+|-]Number")
val(numsignedper_VAL, int_arg_with_sign_and_percent, "SNumberP", "[+|-]Number[%VG|%PVS|%FREE]")
val(permission_VAL, permission_arg, "Permission", "rw|r")
val(metadatatype_VAL, metadatatype_arg, "MetadataType", "lvm2|lvm1")
-val(units_VAL, string_arg, "Units", "h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E")
+val(units_VAL, string_arg, "Units", "r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E")
val(segtype_VAL, segtype_arg, "SegType", "linear|striped|snapshot|mirror|raid*|thin|cache|thin-pool|cache-pool")
val(alloc_VAL, alloc_arg, "Alloc", "contiguous|cling|cling_by_tags|normal|anywhere|inherit")
val(locktype_VAL, locktype_arg, "LockType", "sanlock|dlm|none")
7 years, 3 months
master - args: in yes option mention qq for auto-no
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3cf394389896a1...
Commit: 3cf394389896a1bd6b3780671e6a6654a925bdd3
Parent: f88ce5fb9954721b41fa1fc19c53abc18006c395
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Feb 17 14:42:13 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Feb 17 14:44:11 2017 -0600
args: in yes option mention qq for auto-no
---
tools/args.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index 06595a6..149b5f6 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -1369,7 +1369,8 @@ arg(resizeable_ARG, 'x', "resizeable", bool_VAL, 0, 0,
arg(yes_ARG, 'y', "yes", 0, 0, 0,
"Do not prompt for confirmation interactively but always assume the\n"
- "answer yes. Use with extreme caution.\n")
+ "answer yes. Use with extreme caution.\n"
+ "(For automatic no, see -qq.)\n")
arg(zero_ARG, 'Z', "zero", bool_VAL, 0, 0,
"#lvchange\n"
7 years, 3 months
master - lvconvert: include swap behavior in generic pool syntax
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f88ce5fb995472...
Commit: f88ce5fb9954721b41fa1fc19c53abc18006c395
Parent: 56deed9d54c9070cc586f040264a8e1985b19bdc
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Feb 17 11:45:13 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Feb 17 13:20:15 2017 -0600
lvconvert: include swap behavior in generic pool syntax
For this syntax:
lvconvert --thinpool LV1 --poolmetadata LV2
lvconvert --cachepool LV1 --poolmetadata LV2
Restore the metadata swapping behavior in addition to
the pool creation behavior. When LV1 is already a pool,
the metadata LV will be swapped with LV2.
When LV1 is not a pool, it will be converted to a
pool using the specified LV for metadata.
This syntax is no longer advertised because of the
ambiguous behavior. The primary syntaxes for pool
creation and metadata swapping will be the advertised
methods.
---
man/lvconvert.8.end | 21 +++++++
man/lvmthin.7.in | 16 ------
tools/args.h | 9 ++-
tools/command-lines.in | 66 ++++++++++++++++++-----
tools/command.c | 5 ++
tools/command.h | 3 +-
tools/lvconvert.c | 136 ++++++++++++++++++++++++++----------------------
tools/lvmcmdline.c | 7 ++-
tools/tools.h | 2 +-
9 files changed, 166 insertions(+), 99 deletions(-)
diff --git a/man/lvconvert.8.end b/man/lvconvert.8.end
index fa8cc1d..5a3d475 100644
--- a/man/lvconvert.8.end
+++ b/man/lvconvert.8.end
@@ -1,3 +1,24 @@
+.SH NOTES
+
+This previous command syntax would perform two different operations:
+.br
+\fBlvconvert --thinpool\fP \fILV1\fP \fB--poolmetadata\fP \fILV2\fP
+.br
+If LV1 was not a thin pool, the command would convert LV1 to
+a thin pool, optionally using a specified LV for metadata.
+But, if LV1 was already a thin pool, the command would swap
+the current metadata LV with LV2 (for repair purposes.)
+
+In the same way, this previous command syntax would perform two different
+operations:
+.br
+\fBlvconvert --cachepool\fP \fILV1\fP \fB--poolmetadata\fP \fILV2\fP
+.br
+If LV1 was not a cache pool, the command would convert LV1 to
+a cache pool, optionally using a specified LV for metadata.
+But, if LV1 was already a cache pool, the command would swap
+the current metadata LV with LV2 (for repair purposes.)
+
.SH EXAMPLES
Convert a linear LV to a two-way mirror LV.
diff --git a/man/lvmthin.7.in b/man/lvmthin.7.in
index 714233e..f6f8548 100644
--- a/man/lvmthin.7.in
+++ b/man/lvmthin.7.in
@@ -278,22 +278,6 @@ or vgchange to activate thin snapshots with the "k" attribute.
\&
-.SS Alternate syntax for specifying type thin\-pool
-
-\&
-
-The fully specified syntax for creating a thin pool LV shown above is:
-
-.B lvconvert \-\-type thin-pool \-\-poolmetadata VG/ThinMetaLV VG/ThinDataLV
-
-An alternate syntax may be used for the same operation:
-
-.B lvconvert \-\-thinpool VG/ThinDataLV \-\-poolmetadata VG/ThinMetaLV
-
-The thin-pool type is inferred by lvm; the \-\-thinpool option is not an
-alias for \-\-type thin\-pool.
-
-
.SS Automatic pool metadata LV
\&
diff --git a/tools/args.h b/tools/args.h
index f64b126..06595a6 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -589,9 +589,12 @@ arg(stripes_long_ARG, '\0', "stripes", number_VAL, 0, 0,
"existing allocated space, only newly allocated space can be striped.\n")
arg(swapmetadata_ARG, '\0', "swapmetadata", 0, 0, 0,
- "Remove the metadata LV in a pool and replace it with another specified LV.\n"
- "The removed LV is preserved and given the name of the LV that replaced it.\n"
- "Used for repair only.\n")
+ "Extracts the metadata LV from a pool and replaces it with another specified LV.\n"
+ "The extracted LV is preserved and given the name of the LV that replaced it.\n"
+ "Use for repair only. When the metadata LV is swapped out of the pool, it can\n"
+ "be activated directly and used with thin provisioning tools:\n"
+ "\\fBcache_dump\\fP(8), \\fBcache_repair\\fP(8), \\fBcache_restore\\fP(8),\n"
+ "\\fBthin_dump\\fP(8), \\fBthin_repair\\fP(8), \\fBthin_restore\\fP(8).\n")
arg(syncaction_ARG, '\0', "syncaction", syncaction_VAL, 0, 0,
"Initiate different types of RAID synchronization.\n"
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 377e536..aed38e7 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -454,17 +454,36 @@ DESC: Convert LV to type thin-pool.
RULE: all and lv_is_visible
RULE: all not lv_is_locked lv_is_origin lv_is_merging_origin lv_is_external_origin lv_is_virtual
-# alternate form of lvconvert --type thin-pool
-# deprecated because of non-standard syntax (missing positional arg)
-# Commands in this form are converted to standard form so that
-# the validation of LV types and rules specified above will apply.
-lvconvert --thinpool LV_linear_striped_raid_cache
+# This command syntax has two different meanings depending on
+# whether the LV pos arg is already a thin pool or not.
+#
+# 1. When the LV arg is not a pool, this command converts
+# the LV into a pool, optionally using a specified meta LV.
+# This is an alternate form of the primary command:
+# lvconvert --type thin-pool LV
+#
+# 2. When the LV is is already a pool and a meta LV is specified,
+# the meta LV is swapped. Swapping a meta LV is a very specialized
+# operation that users should never use.
+# This is an alternate form of the primary command:
+# lvconvert --swapmetadata --poolmetadata LV LV
+#
+# The command def cannot include --poolmetadata as a required
+# option, otherwise 1 would not pass, so the validation of
+# this option cannot be done by the command defs, but has to
+# be done ad hoc in the lvconvert implementation.
+#
+# This command syntax is deprecated, and the primary forms
+# of creating a pool or swapping metadata should be used.
+
+lvconvert --thinpool LV_linear_striped_raid_cache_thinpool
OO: --type thin-pool, --stripes_long Number, --stripesize SizeKB,
--discards Discards, --zero Bool, OO_LVCONVERT_POOL, OO_LVCONVERT
OP: PV ...
-ID: lvconvert_to_thinpool_noarg
+ID: lvconvert_to_thinpool_or_swap_metadata
DESC: Convert LV to type thin-pool (variant, use --type thin-pool).
-FLAGS: SECONDARY_SYNTAX
+DESC: Swap metadata LV in a thin pool (variant, use --swapmetadata).
+FLAGS: PREVIOUS_SYNTAX
---
@@ -475,17 +494,36 @@ OP: PV ...
ID: lvconvert_to_cachepool
DESC: Convert LV to type cache-pool.
-# alternate form of lvconvert --type cache-pool
-# deprecated because of non-standard syntax (missing positional arg)
-# Commands in this form are converted to standard form so that
-# the validation of LV types and rules specified above will apply.
-lvconvert --cachepool LV_linear_striped_raid
+# This command syntax has two different meanings depending on
+# whether the LV pos arg is already a cache pool or not.
+#
+# 1. When the LV arg is not a pool, this command converts
+# the LV into a pool, optionally using a specified meta LV.
+# This is an alternate form of the primary command:
+# lvconvert --type cache-pool LV
+#
+# 2. When the LV is is already a pool and a meta LV is specified,
+# the meta LV is swapped. Swapping a meta LV is a very specialized
+# operation that users should never use.
+# This is an alternate form of the primary command:
+# lvconvert --swapmetadata --poolmetadata LV LV
+#
+# The command def cannot include --poolmetadata as a required
+# option, otherwise 1 would not pass, so the validation of
+# this option cannot be done by the command defs, but has to
+# be done ad hoc in the lvconvert implementation.
+#
+# This command syntax is deprecated, and the primary forms
+# of creating a pool or swapping metadata should be used.
+
+lvconvert --cachepool LV_linear_striped_raid_cachepool
OO: --type cache-pool, OO_LVCONVERT_POOL, OO_LVCONVERT,
--cachemode CacheMode, --cachepolicy String, --cachesettings String
OP: PV ...
-ID: lvconvert_to_cachepool_noarg
+ID: lvconvert_to_cachepool_or_swap_metadata
DESC: Convert LV to type cache-pool (variant, use --type cache-pool).
-FLAGS: SECONDARY_SYNTAX
+DESC: Swap metadata LV in a cache pool (variant, use --swapmetadata).
+FLAGS: PREVIOUS_SYNTAX
---
diff --git a/tools/command.c b/tools/command.c
index 6cd4d68..2897c65 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1128,6 +1128,8 @@ static void add_flags(struct command *cmd, char *line)
{
if (strstr(line, "SECONDARY_SYNTAX"))
cmd->cmd_flags |= CMD_FLAG_SECONDARY_SYNTAX;
+ if (strstr(line, "PREVIOUS_SYNTAX"))
+ cmd->cmd_flags |= CMD_FLAG_PREVIOUS_SYNTAX;
}
#define MAX_RULE_OPTS 64
@@ -2659,6 +2661,9 @@ void print_man(char *name, char *des_file, int include_primary, int include_seco
prev_cmd = NULL;
}
+ if (cmd->cmd_flags & CMD_FLAG_PREVIOUS_SYNTAX)
+ continue;
+
if ((cmd->cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !include_secondary)
continue;
diff --git a/tools/command.h b/tools/command.h
index fcf0ccb..95bd797 100644
--- a/tools/command.h
+++ b/tools/command.h
@@ -166,7 +166,8 @@ struct cmd_rule {
*/
#define CMD_FLAG_ONE_REQUIRED_OPT 1 /* lvchange/vgchage require one item from required_opt_args */
#define CMD_FLAG_SECONDARY_SYNTAX 2 /* allows syntax variants to be suppressed in certain output */
-#define CMD_FLAG_PARSE_ERROR 4 /* error parsing command-lines.in def */
+#define CMD_FLAG_PREVIOUS_SYNTAX 4 /* allows syntax variants to not be advertised in output */
+#define CMD_FLAG_PARSE_ERROR 8 /* error parsing command-lines.in def */
/* a register of the lvm commands */
struct command {
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index a2ad115..b9e0665 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3790,51 +3790,6 @@ int lvconvert_to_pool_cmd(struct cmd_context *cmd, int argc, char **argv)
NULL, NULL, &_lvconvert_to_pool_single);
}
-/*
- * Reformats non-standard command form into standard command form.
- *
- * In the command variants with no position LV arg, the LV arg is taken from
- * the --thinpool/--cachepool arg, and the position args are modified to match
- * the standard command form.
- */
-
-int lvconvert_to_pool_noarg_cmd(struct cmd_context *cmd, int argc, char **argv)
-{
- struct command *new_command;
- char *pool_data_name;
- int i, p;
-
- switch (cmd->command->command_enum) {
- case lvconvert_to_thinpool_noarg_CMD:
- pool_data_name = (char *)arg_str_value(cmd, thinpool_ARG, NULL);
- new_command = get_command(lvconvert_to_thinpool_CMD);
- break;
- case lvconvert_to_cachepool_noarg_CMD:
- pool_data_name = (char *)arg_str_value(cmd, cachepool_ARG, NULL);
- new_command = get_command(lvconvert_to_cachepool_CMD);
- break;
- default:
- log_error(INTERNAL_ERROR "Unknown pool conversion.");
- return 0;
- };
-
- log_debug("Changing command %d:%s to standard form %d:%s",
- cmd->command->command_index, cmd->command->command_id,
- new_command->command_index, new_command->command_id);
-
- /* Make the LV the first position arg. */
-
- p = cmd->position_argc;
- for (i = 0; i < cmd->position_argc; i++)
- cmd->position_argv[p] = cmd->position_argv[p-1];
-
- cmd->position_argv[0] = pool_data_name;
- cmd->position_argc++;
- cmd->command = new_command;
-
- return lvconvert_to_pool_cmd(cmd, argc, argv);
-}
-
static int _lvconvert_to_cache_vol_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
@@ -4077,39 +4032,96 @@ int lvconvert_swap_pool_metadata_cmd(struct cmd_context *cmd, int argc, char **a
NULL, NULL, &_lvconvert_swap_pool_metadata_single);
}
-#if 0
-int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, char **argv)
+static int _lvconvert_to_pool_or_swap_metadata_single(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ struct processing_handle *handle)
{
- struct command *new_command;
- char *pool_name;
+ struct dm_list *use_pvh = NULL;
+ int to_thinpool = 0;
+ int to_cachepool = 0;
switch (cmd->command->command_enum) {
- case lvconvert_swap_thinpool_metadata_CMD:
- pool_name = (char *)arg_str_value(cmd, thinpool_ARG, NULL);
+ case lvconvert_to_thinpool_or_swap_metadata_CMD:
+ to_thinpool = 1;
break;
- case lvconvert_swap_cachepool_metadata_CMD:
- pool_name = (char *)arg_str_value(cmd, cachepool_ARG, NULL);
+ case lvconvert_to_cachepool_or_swap_metadata_CMD:
+ to_cachepool = 1;
break;
default:
- log_error(INTERNAL_ERROR "Unknown pool conversion.");
+ log_error(INTERNAL_ERROR "Invalid lvconvert pool command");
return 0;
};
- new_command = get_command(lvconvert_swap_pool_metadata_CMD);
+ if (cmd->position_argc > 1) {
+ /* First pos arg is required LV, remaining are optional PVs. */
+ if (!(use_pvh = create_pv_list(cmd->mem, lv->vg, cmd->position_argc - 1, cmd->position_argv + 1, 0)))
+ return_ECMD_FAILED;
+ } else
+ use_pvh = &lv->vg->pvs;
+
+ /*
+ * We can finally determine if this command is supposed to create
+ * a pool or swap the metadata in an existing pool.
+ *
+ * This allows the ambiguous command:
+ * 'lvconvert --thinpool LV1 --poolmetadata LV2' to mean either:
+ * 1. convert LV2 to a pool using the specified meta LV2
+ * 2. swap the meta lv in LV1 with LV2
+ *
+ * In case 2, the poolmetadata option is required, but in case 1
+ * it is optional. So, the command def is not able to validate
+ * the required/optional option, and we have to check here
+ * for missing poolmetadata in case 2.
+ */
+ if (lv_is_pool(lv)) {
+ if (!arg_is_set(cmd, poolmetadata_ARG)) {
+ log_error("The --poolmetadata option is required to swap metadata.");
+ return ECMD_FAILED;
+ }
+ return _lvconvert_swap_pool_metadata_single(cmd, lv, handle);
+ }
+
+ if (!_lvconvert_to_pool(cmd, lv, to_thinpool, to_cachepool, use_pvh))
+ return_ECMD_FAILED;
+
+ return ECMD_PROCESSED;
+}
+
+/*
+ * In the command variants with no position LV arg, the LV arg is taken from
+ * the --thinpool/--cachepool arg, and the position args are modified to match
+ * the standard command form.
+ */
+
+int lvconvert_to_pool_or_swap_metadata_cmd(struct cmd_context *cmd, int argc, char **argv)
+{
+ char *pool_data_name;
+ int i, p;
- log_debug("Changing command %d:%s to standard form %d:%s",
- cmd->command->command_index, cmd->command->command_id,
- new_command->command_index, new_command->command_id);
+ switch (cmd->command->command_enum) {
+ case lvconvert_to_thinpool_or_swap_metadata_CMD:
+ pool_data_name = (char *)arg_str_value(cmd, thinpool_ARG, NULL);
+ break;
+ case lvconvert_to_cachepool_or_swap_metadata_CMD:
+ pool_data_name = (char *)arg_str_value(cmd, cachepool_ARG, NULL);
+ break;
+ default:
+ log_error(INTERNAL_ERROR "Unknown pool conversion.");
+ return 0;
+ };
/* Make the LV the first position arg. */
- cmd->position_argv[0] = pool_name;
+ p = cmd->position_argc;
+ for (i = 0; i < cmd->position_argc; i++)
+ cmd->position_argv[p] = cmd->position_argv[p-1];
+
+ cmd->position_argv[0] = pool_data_name;
cmd->position_argc++;
- cmd->command = new_command;
- return lvconvert_swap_pool_metadata_cmd(cmd, argc, argv);
+ return process_each_lv(cmd, 1, cmd->position_argv, NULL, NULL, READ_FOR_UPDATE,
+ NULL, NULL, &_lvconvert_to_pool_or_swap_metadata_single);
}
-#endif
static int _lvconvert_merge_thin_single(struct cmd_context *cmd,
struct logical_volume *lv,
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 7e50d05..26f7476 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -135,12 +135,12 @@ struct command_function command_functions[CMD_COUNT] = {
/* lvconvert utilities for creating/maintaining thin and cache objects. */
{ lvconvert_to_thinpool_CMD, lvconvert_to_pool_cmd },
- { lvconvert_to_thinpool_noarg_CMD, lvconvert_to_pool_noarg_cmd },
{ lvconvert_to_cachepool_CMD, lvconvert_to_pool_cmd },
- { lvconvert_to_cachepool_noarg_CMD, lvconvert_to_pool_noarg_cmd },
{ lvconvert_to_thin_with_external_CMD, lvconvert_to_thin_with_external_cmd },
{ lvconvert_to_cache_vol_CMD, lvconvert_to_cache_vol_cmd },
{ lvconvert_swap_pool_metadata_CMD, lvconvert_swap_pool_metadata_cmd },
+ { lvconvert_to_thinpool_or_swap_metadata_CMD, lvconvert_to_pool_or_swap_metadata_cmd },
+ { lvconvert_to_cachepool_or_swap_metadata_CMD, lvconvert_to_pool_or_swap_metadata_cmd },
{ lvconvert_merge_thin_CMD, lvconvert_merge_thin_cmd },
{ lvconvert_split_and_keep_cachepool_CMD, lvconvert_split_cachepool_cmd },
{ lvconvert_split_and_remove_cachepool_CMD, lvconvert_split_cachepool_cmd },
@@ -1727,6 +1727,9 @@ static int _usage(const char *name, int longhelp)
if (strcmp(_cmdline.commands[i].name, name))
continue;
+ if (_cmdline.commands[i].cmd_flags & CMD_FLAG_PREVIOUS_SYNTAX)
+ continue;
+
if ((_cmdline.commands[i].cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !longhelp)
continue;
diff --git a/tools/tools.h b/tools/tools.h
index b3858a0..62db506 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -274,10 +274,10 @@ int lvconvert_combine_split_snapshot_cmd(struct cmd_context *cmd, int argc, char
int lvconvert_start_poll_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_pool_cmd(struct cmd_context *cmd, int argc, char **argv);
-int lvconvert_to_pool_noarg_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_cache_vol_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_thin_with_external_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_swap_pool_metadata_cmd(struct cmd_context *cmd, int argc, char **argv);
+int lvconvert_to_pool_or_swap_metadata_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_merge_thin_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_split_cachepool_cmd(struct cmd_context *cmd, int argc, char **argv);
7 years, 3 months
master - commands: compensate --uuid
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=56deed9d54c907...
Commit: 56deed9d54c9070cc586f040264a8e1985b19bdc
Parent: 00f299b93265ea2a9a930f26c68d887b8708da5a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 17 13:57:59 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Feb 17 13:57:59 2017 +0100
commands: compensate --uuid
As we now user binary search - it's nondeterministict
which of the same 'args' will be give - so duplicates
need 'extra' care.
So provide same hack for output for --uuidstr_ARG as
for input.
Solves 'pvscan -u'.
---
tools/command.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index 1abac20..6cd4d68 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -866,6 +866,11 @@ static void add_opt_arg(struct command *cmd, char *str, int *takes_arg, int requ
}
opt = opt_str_to_num(cmd, str);
+
+ /* If the binary-search finds uuidstr_ARG switch to uuid_ARG */
+ if (opt == uuidstr_ARG)
+ opt = uuid_ARG;
+
skip:
if (required > 0)
cmd->required_opt_args[cmd->ro_count++].opt = opt;
7 years, 3 months
master - commands: some more dm wrappers
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=00f299b93265ea...
Commit: 00f299b93265ea2a9a930f26c68d887b8708da5a
Parent: 238a79aac41fcba65e7ac9c75f05275ab5915de6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 17 13:36:57 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Feb 17 13:36:57 2017 +0100
commands: some more dm wrappers
As man-generator is not liked with libdm as of now - some more wrappers.
---
tools/command.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index a4139f0..1abac20 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -48,6 +48,18 @@ do { \
#define dm_malloc malloc
#define dm_free free
#define dm_strdup strdup
+#define dm_snprintf snprintf
+
+static int dm_strncpy(char *dest, const char *src, size_t n)
+{
+ if (memccpy(dest, src, 0, n))
+ return 1;
+
+ if (n > 0)
+ dest[n - 1] = '\0';
+
+ return 0;
+}
/* needed to include args.h */
#define ARG_COUNTABLE 0x00000001
7 years, 3 months
master - cleanup: unused uninit vars
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=238a79aac41fcb...
Commit: 238a79aac41fcba65e7ac9c75f05275ab5915de6
Parent: 995f7aa92fb4a80ccb3bb9f78a396be15932baf3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 17 13:16:27 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Feb 17 13:20:55 2017 +0100
cleanup: unused uninit vars
---
tools/command.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index cdea72c..a4139f0 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1326,7 +1326,7 @@ static int copy_line(char *line, int max_line, int *position)
int define_commands(char *run_name)
{
- struct command *cmd;
+ struct command *cmd = NULL;
char line[MAX_LINE];
char line_orig[MAX_LINE];
char *line_argv[MAX_LINE_ARGC];
@@ -1824,7 +1824,6 @@ static void print_def_man(struct arg_def *def, int usage)
int val_enum;
int lvt_enum;
int sep = 0;
- int i;
for (val_enum = 0; val_enum < VAL_COUNT; val_enum++) {
if (def->val_bits & val_enum_to_bit(val_enum)) {
@@ -1927,7 +1926,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
{
struct command_name *cname;
int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
- int i, sep, ro, rp, oo, op, opt_enum;
+ int sep, ro, rp, oo, op, opt_enum;
int need_ro_indent_end = 0;
if (!(cname = find_command_name(cmd->name)))
7 years, 3 months
master - cleanup: use strchr for 1-byte lookup
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=995f7aa92fb4a8...
Commit: 995f7aa92fb4a80ccb3bb9f78a396be15932baf3
Parent: 46d6c7d3ad0f5a4151960202635f3805dc0e3f15
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 17 13:09:06 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Feb 17 13:20:55 2017 +0100
cleanup: use strchr for 1-byte lookup
---
tools/command.c | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index 5342ba2..cdea72c 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -337,7 +337,7 @@ static int val_str_to_num(char *str)
/* compare the name before any suffix like _new or _<lvtype> */
dm_strncpy(name, str, sizeof(name));
- if ((new = strstr(name, "_")))
+ if ((new = strchr(name, '_')))
*new = '\0';
for (i = 0; i < VAL_COUNT; i++) {
@@ -561,7 +561,7 @@ static int is_pos_name(char *str)
static int is_oo_definition(char *str)
{
- if (!strncmp(str, "OO_", 3) && strstr(str, ":"))
+ if (!strncmp(str, "OO_", 3) && strchr(str, ':'))
return 1;
return 0;
}
@@ -644,7 +644,7 @@ static void set_pos_def(struct command *cmd, char *str, struct arg_def *def)
def->val_bits |= val_enum_to_bit(val_enum);
- if ((val_enum == lv_VAL) && strstr(name, "_"))
+ if ((val_enum == lv_VAL) && strchr(name, '_'))
def->lvt_bits = lv_to_bits(cmd, name);
if (strstr(name, "_new")) {
@@ -702,7 +702,7 @@ static void set_opt_def(struct command *cmd, char *str, struct arg_def *def)
def->str = dm_strdup(name);
if (val_enum == lv_VAL) {
- if (strstr(name, "_"))
+ if (strchr(name, '_'))
def->lvt_bits = lv_to_bits(cmd, name);
}
@@ -735,7 +735,7 @@ static void add_oo_definition_line(struct command *cmd, const char *name, const
oo = &oo_lines[oo_line_count++];
oo->name = dm_strdup(name);
- if ((colon = strstr(oo->name, ":")))
+ if ((colon = strchr(oo->name, ':')))
*colon = '\0';
else {
log_error("Parsing command defs: invalid OO definition");
@@ -743,7 +743,7 @@ static void add_oo_definition_line(struct command *cmd, const char *name, const
return;
}
- start = strstr(line, ":") + 2;
+ start = strchr(line, ':') + 2;
oo->line = dm_strdup(start);
}
@@ -786,9 +786,9 @@ static char *get_oo_line(const char *str)
int i;
dm_strncpy(str2, str, sizeof(str2));
- if ((end = strstr(str2, ":")))
+ if ((end = strchr(str2, ':')))
*end = '\0';
- if ((end = strstr(str2, ",")))
+ if ((end = strchr(str2, ',')))
*end = '\0';
for (i = 0; i < oo_line_count; i++) {
@@ -840,7 +840,7 @@ static void add_opt_arg(struct command *cmd, char *str, int *takes_arg, int requ
/* opt_arg.opt set here */
/* opt_arg.def will be set in update_prev_opt_arg() if needed */
- if ((comma = strstr(str, ",")))
+ if ((comma = strchr(str, ',')))
*comma = '\0';
/*
@@ -884,7 +884,7 @@ static void update_prev_opt_arg(struct command *cmd, char *str, int required)
/* opt_arg.def set here */
/* opt_arg.opt was previously set in add_opt_arg() when --foo was read */
- if ((comma = strstr(str, ",")))
+ if ((comma = strchr(str, ',')))
*comma = '\0';
set_opt_def(cmd, str, &def);
@@ -1792,7 +1792,7 @@ static void print_val_man(const char *str)
return;
}
- if (strstr(str, "|")) {
+ if (strchr(str, '|')) {
int len = strlen(str);
line = dm_strdup(str);
split_line(line, &line_argc, line_argv, '|');
7 years, 3 months
master - cleanup: add comment for longer macro
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=46d6c7d3ad0f5a...
Commit: 46d6c7d3ad0f5a4151960202635f3805dc0e3f15
Parent: 772834e40aef44a8f7bc884050e1b88087073706
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 17 11:51:24 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Feb 17 13:20:55 2017 +0100
cleanup: add comment for longer macro
---
tools/command.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index b202878..5342ba2 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -145,11 +145,11 @@ enum {
#undef lvt
};
-#else
+#else /* MAN_PAGE_GENERATOR */
#include "tools.h"
-#endif
+#endif /* MAN_PAGE_GENERATOR */
#include "command.h" /* defines struct command */
#include "command-count.h" /* defines COMMAND_COUNT */
7 years, 3 months
master - commands: optimize binary search
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=772834e40aef44...
Commit: 772834e40aef44a8f7bc884050e1b88087073706
Parent: 582a272b3f401e1bb6eafaa52d0ed1d318d04a9f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 17 10:00:43 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Feb 17 13:20:55 2017 +0100
commands: optimize binary search
Since there is a lot of options and lot of searches,
use binary search to keep strcmp at minimum.
The interesting part is - alphabetically sorted array contains
duplicates and some of them are not the 'right anwer', so
after we find matching string but not matching long_ARG,
we may need to check if the surrouding strings are the right matching
one.
The single loops is used also for strictly define --foo_long
(i.e. --stripes) and just differs at final part.
TODO1: replace strstr call with some flag (just like short_opt).
TODO2: drop '--' from being stored and tests by strcmp.
---
tools/command.c | 79 +++++++++++++++++++++++++++++++-----------------------
1 files changed, 45 insertions(+), 34 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index e5a4640..b202878 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -359,46 +359,57 @@ static int opt_str_to_num(struct command *cmd, char *str)
char long_name[MAX_LONG_OPT_NAME_LEN];
char *p;
int i;
+ int first = 0, last = ARG_COUNT - 1, middle;
- /*
- * --foo_long means there are two args entries
- * for --foo, one with a short option and one
- * without, and we want the one without the
- * short option.
- */
- if (strstr(str, "_long")) {
- memset(long_name, 0, sizeof(long_name));
- strncpy(long_name, str, MAX_LONG_OPT_NAME_LEN-1);
- if ((p = strstr(long_name, "_long")))
- *p = '\0';
-
- for (i = 0; i < ARG_COUNT; i++) {
- if (!opt_names[i].long_opt)
- continue;
- /* skip anything with a short opt */
- if (opt_names[i].short_opt)
- continue;
- if (!strcmp(opt_names[i].long_opt, long_name))
- return opt_names[i].opt_enum;
- }
+ dm_strncpy(long_name, str, sizeof(long_name));
- log_error("Parsing command defs: unknown opt str: %s %s", str, long_name);
- cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
- return ARG_UNUSED;
- }
+ if ((p = strstr(long_name, "_long")))
+ /*
+ * --foo_long means there are two args entries
+ * for --foo, one with a short option and one
+ * without, and we want the one without the
+ * short option (== 0).
+ */
+ *p = '\0';
- for (i = 0; i < ARG_COUNT; i++) {
- if (!opt_names[i].long_opt)
- continue;
- /* These are only selected using --foo_long */
- if (strstr(opt_names[i].name, "_long_ARG"))
- continue;
- if (!strcmp(opt_names[i].long_opt, str))
- return opt_names[i].opt_enum;
+ /* Binary search in sorted array of long options (with duplicates) */
+ while (first <= last) {
+ middle = first + (last - first) / 2;
+ if ((i = strcmp(opt_names_alpha[middle]->long_opt, long_name)) < 0)
+ first = middle + 1;
+ else if (i > 0)
+ last = middle - 1;
+ else {
+ /* Matching long option string found.
+ * As sorted array contains duplicates, we need to also
+ * check left & right side for possible match
+ */
+ for (i = middle;;) {
+ if ((!p && !strstr(opt_names_alpha[i]->name, "_long_ARG")) ||
+ (p && !opt_names_alpha[i]->short_opt))
+ return opt_names_alpha[i]->opt_enum; /* Found */
+ /* Check if there is something on the 'left-side' */
+ if ((i <= first) || strcmp(opt_names_alpha[--i]->long_opt, long_name))
+ break;
+ }
+
+ /* Nothing on the left, so look on the 'right-side' */
+ for (i = middle + 1; i <= last; ++i) {
+ if (strcmp(opt_names_alpha[i]->long_opt, long_name))
+ break;
+ if ((!p && !strstr(opt_names_alpha[i]->name, "_long_ARG")) ||
+ (p && !opt_names_alpha[i]->short_opt))
+ return opt_names_alpha[i]->opt_enum; /* Found */
+ }
+
+ break; /* Nothing... */
+ }
}
- log_error("Parsing command defs: unknown opt str: \"%s\"", str);
+ log_error("Parsing command defs: unknown opt str: \"%s\"%s%s.",
+ str, p ? " ": "", p ? long_name : "");
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
+
return ARG_UNUSED;
}
7 years, 3 months