From 7544b9fc10eaa7a6d32cadc2a579b0e488ed1bbd Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 14 Dec 2023 14:09:55 +0100 Subject: [PATCH] vdo: refactor vdo_params passing Introduce vdo_convert_params and use vdo_params from this structure also with lvcreate_params. Later we will use this for convertion of thin-pool data volume to VDO. --- lib/metadata/lv_manip.c | 2 +- lib/metadata/metadata-exported.h | 13 ++++++++++++- tools/lvcreate.c | 14 +++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 3ecb58b2c..5d0eebfa3 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -9718,7 +9718,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, } if (seg_is_vdo_pool(lp)) { - if (!convert_vdo_pool_lv(lv, &lp->vdo_params, &lp->virtual_extents, + if (!convert_vdo_pool_lv(lv, &lp->vcp.vdo_params, &lp->virtual_extents, 1, lp->vdo_pool_header_size)) { stack; goto deactivate_and_revert_new_lv; diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index de447fffa..22bb1f305 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -976,6 +976,17 @@ static inline int is_change_activating(activation_change_t change) return ((change != CHANGE_AN) && (change != CHANGE_ALN)); } +struct vdo_convert_params { + struct dm_vdo_target_params vdo_params; /* VDO parameters for vdoformat */ + const char *lv_name; + uint32_t virtual_extents; + activation_change_t activate; + int do_zero; + int do_wipe_signatures; /* Used for wiping VDO backend volume */ + force_t force; + int yes; +}; + /* FIXME: refactor and reduce the size of this struct! */ struct lvcreate_params { /* flags */ @@ -1050,7 +1061,7 @@ struct lvcreate_params { uint32_t read_ahead; /* all */ int approx_alloc; /* all */ alloc_policy_t alloc; /* all */ - struct dm_vdo_target_params vdo_params; /* vdo */ + struct vdo_convert_params vcp; uint64_t vdo_pool_header_size; /* VDO */ int raidintegrity; diff --git a/tools/lvcreate.c b/tools/lvcreate.c index add2d6971..bbe8bde03 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -324,19 +324,19 @@ static int _update_extents_params(struct volume_group *vg, } if (seg_is_vdo(lp)) { - vdo_pool_max_extents = get_vdo_pool_max_extents(&lp->vdo_params, vg->extent_size); + vdo_pool_max_extents = get_vdo_pool_max_extents(&lp->vcp.vdo_params, vg->extent_size); if (extents > vdo_pool_max_extents) { if (lcp->percent == PERCENT_NONE) { log_error("Can't use %s size. Maximal supported VDO POOL volume size with slab size %s is %s.", display_size(vg->cmd, (uint64_t)vg->extent_size * extents), - display_size(vg->cmd, (uint64_t)lp->vdo_params.slab_size_mb << (20 - SECTOR_SHIFT)), + display_size(vg->cmd, (uint64_t)lp->vcp.vdo_params.slab_size_mb << (20 - SECTOR_SHIFT)), display_size(vg->cmd, (uint64_t)vg->extent_size * vdo_pool_max_extents)); return 0; } extents = vdo_pool_max_extents; log_verbose("Using maximal supported VDO POOL volume size %s (with slab size %s).", display_size(vg->cmd, (uint64_t)vg->extent_size * extents), - display_size(vg->cmd, (uint64_t)lp->vdo_params.slab_size_mb << (20 - SECTOR_SHIFT))); + display_size(vg->cmd, (uint64_t)lp->vcp.vdo_params.slab_size_mb << (20 - SECTOR_SHIFT))); } } @@ -724,7 +724,7 @@ static int _read_vdo_params(struct cmd_context *cmd, return 1; // prefiling settings here - if (!fill_vdo_target_params(cmd, &lp->vdo_params, &lp->vdo_pool_header_size, NULL)) + if (!fill_vdo_target_params(cmd, &lp->vcp.vdo_params, &lp->vdo_pool_header_size, NULL)) return_0; if ((lcp->virtual_size <= DM_VDO_LOGICAL_SIZE_MAXIMUM) && @@ -735,7 +735,7 @@ static int _read_vdo_params(struct cmd_context *cmd, } // override with optional vdo settings - if (!get_vdo_settings(cmd, &lp->vdo_params, NULL)) + if (!get_vdo_settings(cmd, &lp->vcp.vdo_params, NULL)) return_0; return 1; @@ -1767,8 +1767,8 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name, !check_vdo_constrains(cmd, &(struct vdo_pool_size_config) { .physical_size = (uint64_t)lp->extents * vg->extent_size, .virtual_size = lcp->virtual_size, - .block_map_cache_size_mb = lp->vdo_params.block_map_cache_size_mb, - .index_memory_size_mb = lp->vdo_params.index_memory_size_mb })) + .block_map_cache_size_mb = lp->vcp.vdo_params.block_map_cache_size_mb, + .index_memory_size_mb = lp->vcp.vdo_params.index_memory_size_mb })) goto_out; if (seg_is_thin(lp) && !_validate_internal_thin_processing(lp))