Skip to contentSkip to conversation

master - lvconvert: include swap behavior in generic pool syntax

PATCH David Teigland 1 participant 1 message Feb 17, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f88ce5fb9954721b41fa1fc19c53abc18006c395
Commit:        f88ce5fb9954721b41fa1fc19c53abc18006c395
Parent:        56deed9d54c9070cc586f040264a8e1985b19bdc
Author:        David Teigland <[email protected]>
AuthorDate:    Fri Feb 17 11:45:13 2017 -0600
Committer:     David Teigland <[email protected]>
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(-)
man/lvconvert.8.end +21 -0
index fa8cc1d..5a3d475 100644
@@ -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.
man/lvmthin.7.in +0 -16
index 714233e..f6f8548 100644
@@ -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
 
 \&
tools/args.h +6 -3
index f64b126..06595a6 100644
@@ -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"
tools/command-lines.in +52 -14

86 lines not on this page · raw message

tools/command.c +5 -0
index 6cd4d68..2897c65 100644
@@ -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;
 
tools/command.h +2 -1
index fcf0ccb..95bd797 100644
@@ -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 {
tools/lvconvert.c +74 -62

164 lines not on this page · raw message

tools/lvmcmdline.c +5 -2
index 7e50d05..26f7476 100644
@@ -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;
 
tools/tools.h +1 -1
index b3858a0..62db506 100644
@@ -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);