Skip to contentSkip to conversation

master - lvconvert: Disallow mixing of cache and thin pools.

PATCH Alasdair Kergon 1 participant 1 message Sep 17, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a2a869afc8f55409fca0f2079facaf57f2539f24
Commit:        a2a869afc8f55409fca0f2079facaf57f2539f24
Parent:        bdb05cc05e3a0eac72b0921cb5eb500891346e12
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Wed Sep 17 17:11:01 2014 +0100
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Wed Sep 17 17:11:01 2014 +0100

lvconvert: Disallow mixing of cache and thin pools.

--cachepool can't take a thin pool and --thinpool can't take a cache pool.

---
 tools/lvconvert.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
tools/lvconvert.c +12 -0
index 295a4e5..eb96bc4 100644
@@ -2733,6 +2733,18 @@ static int _lvconvert_pool(struct cmd_context *cmd,
 	if (lv_is_pool(pool_lv)) {
 		lp->pool_data_lv = pool_lv;
 
+		if (arg_is_set(cmd, cachepool_ARG) && lv_is_thin_pool(pool_lv)) {
+			log_error("--cachepool requires a cache pool.  %s is a thin pool.",
+				  display_lvname(pool_lv));
+			return 0;
+		}
+
+		if (arg_is_set(cmd, thinpool_ARG) && lv_is_cache_pool(pool_lv)) {
+			log_error("--thinpool requires a thin pool.  %s is a cache pool.",
+				  display_lvname(pool_lv));
+			return 0;
+		}
+
 		if (!metadata_lv) {
 			if (arg_from_list_is_set(cmd, "is invalid with existing pool",
 						 cachemode_ARG,chunksize_ARG, discards_ARG,