Skip to contentSkip to conversation

master - lvconvert: update for thin a cache

PATCH Zdenek Kabelac 1 participant 1 message Jul 11, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=970989655ff5cd9ca960bf3113b7bfdf6f575d78
Commit:        970989655ff5cd9ca960bf3113b7bfdf6f575d78
Parent:        fe3ea94e5846f48baf3b00d0f6b913f585b4404e
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Fri Jul 11 12:15:23 2014 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Fri Jul 11 13:32:22 2014 +0200

lvconvert: update for thin a cache

Major update of lvconvert code to handle cache and thin. related targets.

Code tries to unify handling of cache and thin pools. Better supports lvm2 syntax:

lvconvert --type cache --cachepool vg/pool vg/cache lvconvert --type thin --thinpool vg/pool vg/extorg lvconvert --type cache-pool vg/pool lvconvert --type thin-pool vg/pool

as well as:

lvconvert --cache --cachepool vg/pool vg/cache lvconvert --thin --thinpool vg/pool vg/extorg lvconvert --cachepool vg/pool
lvconvert --thinpool vg/pool

While catching much more command line errors. (Yet couple paths still needs more tests)

Detects as much cmdline errors prior opening VG.

Uses single lvconvert_name_params to convert LV names.

Detects as much incompatibilies in VG prior prompting.

Uses single prompt to confirm whole conversion.

TODO: still the code needs fixes...

---
 WHATS_NEW         |    1 +
 tools/lvconvert.c |  992 ++++++++++++++++++++++++++++-------------------------
 tools/toollib.c   |   22 +-
 3 files changed, 539 insertions(+), 476 deletions(-)
WHATS_NEW +1 -0
index 6cbf221..a81fddb 100644
@@ -1,5 +1,6 @@
 Version 2.02.108 -
 =================================
+  Enhance lvconvert thin, thinpool, cache and cachepool command line support.
   Display 'C' only for cache and cache-pool target types in lvs.
   Prompt for confirmation before change LV into a snapshot exception store.
   Return proper error codes for some failing lvconvert funtions.
tools/lvconvert.c +533 -459

1,330 lines not on this page · raw message

tools/toollib.c +5 -17
index b4e02d6..312a76d 100644
@@ -1661,18 +1661,9 @@ int get_pool_params(struct cmd_context *cmd,
 {
 	int cache_pool = 0;
 
-	if (!strcmp("cache-pool", arg_str_value(cmd, type_ARG, "none")))
+	if (!strcmp("cache-pool", arg_str_value(cmd, type_ARG, "")))
 		cache_pool = 1;
 
-	if (!cache_pool && !arg_count(cmd, thinpool_ARG)) {
-		/* Check for arguments that should only go with pools */
-		if (arg_count(cmd, poolmetadata_ARG)) {
-			log_error("'--poolmetadata' argument is only valid when"
-				  " converting to pool LVs.");
-			return_0;
-		}
-	}
-
 	*passed_args = 0;
 	if (!cache_pool && arg_count(cmd, zero_ARG)) {
 		*passed_args |= PASS_ARG_ZERO;
@@ -1706,14 +1697,11 @@ int get_pool_params(struct cmd_context *cmd,
 		return_0;
 
 	if (arg_count(cmd, poolmetadatasize_ARG)) {
-		if (arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
-			log_error("Negative pool metadata size is invalid.");
-			return 0;
-		}
 		*passed_args |= PASS_ARG_POOL_METADATA_SIZE;
-	}
-	*pool_metadata_size = arg_uint64_value(cmd, poolmetadatasize_ARG,
-					       UINT64_C(0));
+		*pool_metadata_size = arg_uint64_value(cmd, poolmetadatasize_ARG,
+						       UINT64_C(0));
+	} else if (arg_count(cmd, poolmetadata_ARG))
+		*passed_args |= PASS_ARG_POOL_METADATA_SIZE; /* fixed size */
 
 	return 1;
 }