From aa7f2ac9546bc95dcdbee21a6b78d05e485b125d Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 31 Aug 2023 18:44:53 +0200 Subject: [PATCH] lvconvert: thin conversion accept passed PVs When creating thin pool or check pool there is allocated LV for metadata and for such allocation user should be able to specify list of PVs on cmdline. Also fix unused passed list of PV for thick to thin conversion, where the code was using whole PV set from a VG (but since it's been not enabled on cmdline, user could not hit this issue). Also remove unneeded initialization of use_pvh. --- tools/command-lines.in | 6 ++++++ tools/lvconvert.c | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/command-lines.in b/tools/command-lines.in index f660314dd..f093b895e 100644 --- a/tools/command-lines.in +++ b/tools/command-lines.in @@ -456,6 +456,7 @@ FLAGS: SECONDARY_SYNTAX lvconvert --type thin --thinpool LV LV_linear_striped_raid_cache_thin_error_zero OO: --thin, --originname LV_new, OO_LVCONVERT_POOL, OO_LVCONVERT +OP: PV ... ID: lvconvert_to_thin_with_external DESC: Convert LV to a thin LV, using the original LV as an external origin. RULE: all and lv_is_visible @@ -465,6 +466,7 @@ RULE: --poolmetadata not --readahead --stripesize --stripes_long # alternate form of lvconvert --type thin lvconvert --thin --thinpool LV LV_linear_striped_raid_cache_thin_error_zero OO: --originname LV_new, OO_LVCONVERT_POOL, OO_LVCONVERT +OP: PV ... ID: lvconvert_to_thin_with_external DESC: Convert LV to a thin LV, using the original LV as an external origin. FLAGS: SECONDARY_SYNTAX @@ -476,6 +478,7 @@ RULE: --poolmetadata not --readahead --stripesize --stripes_long # Convert to thin volume lvconvert --type thin LV_linear_striped_raid_cache_writecache_vdo_error_zero OO: --thin, OO_LVCONVERT_POOL, OO_LVCONVERT +OP: PV ... ID: lvconvert_to_thin_with_data DESC: Convert LV to a thin LV, using LV as thin-pool data volume. RULE: all and lv_is_visible @@ -485,6 +488,7 @@ RULE: --poolmetadata not --readahead --stripesize --stripes_long # Convert to thin volume lvconvert --thin LV_linear_striped_raid_cache_writecache_vdo_error_zero OO: OO_LVCONVERT_POOL, OO_LVCONVERT +OP: PV ... ID: lvconvert_to_thin_with_data DESC: Convert LV to a thin LV, using LV as thin-pool data volume. FLAGS: SECONDARY_SYNTAX @@ -497,6 +501,7 @@ RULE: --poolmetadata not --readahead --stripesize --stripes_long lvconvert --type cache --cachepool LV LV_linear_striped_raid_thinpool_vdo_vdopool_vdopooldata_thin_error_zero OO: --cache, OO_LVCONVERT_CACHE, OO_LVCONVERT_POOL, OO_LVCONVERT +OP: PV ... ID: lvconvert_to_cache_with_cachepool DESC: Attach a cache pool to an LV, converts the LV to type cache. RULE: all not lv_is_locked lv_is_merging_origin lv_is_merging_cow lv_is_cow @@ -505,6 +510,7 @@ RULE: --poolmetadata not --readahead --stripesize --stripes_long # alternate form of lvconvert --type cache lvconvert --cache --cachepool LV LV_linear_striped_raid_thinpool_vdo_vdopool_vdopooldata_thin_error_zero OO: OO_LVCONVERT_CACHE, OO_LVCONVERT_POOL, OO_LVCONVERT +OP: PV ... ID: lvconvert_to_cache_with_cachepool DESC: Attach a cache pool to an LV. RULE: all not lv_is_locked lv_is_merging_origin lv_is_merging_cow lv_is_cow diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 9471f2516..70672e37a 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -4773,8 +4773,7 @@ static int _lvconvert_to_thin_with_data(struct cmd_context *cmd, struct logical_volume *lv, struct processing_handle *handle) { - struct volume_group *vg = lv->vg; - struct dm_list *use_pvh = NULL; + struct dm_list *use_pvh; if (cmd->position_argc > 1) { /* First pos arg is required LV, remaining are optional PVs. */ @@ -4784,7 +4783,7 @@ static int _lvconvert_to_thin_with_data(struct cmd_context *cmd, } else use_pvh = &lv->vg->pvs; - if (!_lvconvert_to_pool(cmd, lv, lv, 1, 0, 1, &vg->pvs)) { + if (!_lvconvert_to_pool(cmd, lv, lv, 1, 0, 1, use_pvh)) { log_error("LV %s could not be converted to a thin volume.", display_lvname(lv)); return ECMD_FAILED;