From 60d2a63368686d309c01f1e59d695d0ee8ec9153 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 6 Oct 2014 13:44:59 +0200 Subject: [PATCH] lvconvert: cache and thin conversion validation More test for supported conversion. --- WHATS_NEW | 1 + tools/lvconvert.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 980809c4e..5fc42d669 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.112 - ===================================== + Fix detection of unsupported cache and thin pool lvconversions. Fix detection of unsupported lvconversion of cache to snapshot. Improve code for creation of cache and cache pool volumes. Check cluster-wide (not local) active status before removing LV. diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 1a5d55997..36fafbeaf 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -2802,13 +2802,18 @@ static int _lvconvert_pool(struct cmd_context *cmd, } if (lv_is_thin_pool(pool_lv) && (segtype_is_cache_pool(lp->segtype) || lp->cache)) { - log_error("Cannot convert thin pool volume %s as cache pool data volume.", + log_error("Can't convert thin pool LV %s.", display_lvname(pool_lv)); + return 0; + } + + if (lv_is_cache(pool_lv) && !segtype_is_thin_pool(lp->segtype)) { + log_error("Cached LV %s could be only converted into a thin pool volume.", display_lvname(pool_lv)); return 0; } if (lv_is_cache_pool(pool_lv) && (segtype_is_thin_pool(lp->segtype) || lp->thin)) { - log_error("Cannot convert cache pool %s as thin pool data volume.", + log_error("Cannot convert cache pool %s as pool data volume.", display_lvname(pool_lv)); return 0; } @@ -3250,6 +3255,25 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv, return ECMD_PROCESSED; } + if (lp->cache) { + if (lv_is_thin_pool(lv)) + lv = seg_lv(first_seg(lv), 0); /* cache _tdata */ + if (!validate_lv_cache_create(NULL, lv)) + return_ECMD_FAILED; + } + + if (lp->thin) { + if (lv_is_cache_type(lv) || + lv_is_pool(lv) || + lv_is_thin_pool_data(lv) || + lv_is_thin_pool_metadata(lv)) { + log_error("Can't convert %s %s to external origin.", + first_seg(lv)->segtype->name, + display_lvname(lv)); + return ECMD_FAILED; + } + } + if (arg_count(cmd, repair_ARG)) { if (lv_is_pool(lv)) { if (!_lvconvert_pool_repair(cmd, lv, lp)) -- 2.43.5