From 558890ad0e3642182e27e0fb085413d9e17c2db0 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sun, 2 Jul 2023 11:21:15 +0200 Subject: [PATCH] pool: support passing data_lv for recalculation Support data_lv to be passed as parameter when it's not yet attached to the pool. --- lib/metadata/cache_manip.c | 1 + lib/metadata/lv_manip.c | 3 ++- lib/metadata/metadata-exported.h | 1 + lib/metadata/pool_manip.c | 3 +-- tools/lvconvert.c | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c index b717e8a36..4c5b37b60 100644 --- a/lib/metadata/cache_manip.c +++ b/lib/metadata/cache_manip.c @@ -1229,6 +1229,7 @@ int cache_set_params(struct lv_segment *seg, if (!pool_seg->chunk_size && /* TODO: some calc_policy solution for cache ? */ !recalculate_pool_chunk_size_with_dev_hints(pool_seg->lv, + seg_lv(pool_seg, 0), THIN_CHUNK_SIZE_CALC_METHOD_GENERIC)) return_0; } diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 4206ed20a..8a4fe8848 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -9457,7 +9457,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, first_seg(lv)->discards = lp->discards; if ((first_seg(lv)->crop_metadata = lp->crop_metadata) == THIN_CROP_METADATA_NO) lv->status |= LV_CROP_METADATA; - if (!recalculate_pool_chunk_size_with_dev_hints(lv, lp->thin_chunk_size_calc_policy)) { + if (!recalculate_pool_chunk_size_with_dev_hints(lv, seg_lv(first_seg(lv), 0), + lp->thin_chunk_size_calc_policy)) { stack; goto revert_new_lv; } diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 7cd194890..89c2cf3ec 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -885,6 +885,7 @@ int thin_pool_feature_supported(const struct logical_volume *lv, int feature); int update_thin_pool_lv(struct logical_volume *lv, int activate); int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv, + struct logical_volume *pool_data_lv, int chunk_size_calc_policy); int validate_cache_chunk_size(struct cmd_context *cmd, uint32_t chunk_size); int validate_thin_pool_chunk_size(struct cmd_context *cmd, uint32_t chunk_size); diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c index 8a908a58d..ba44553fb 100644 --- a/lib/metadata/pool_manip.c +++ b/lib/metadata/pool_manip.c @@ -416,9 +416,9 @@ int validate_pool_chunk_size(struct cmd_context *cmd, } int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv, + struct logical_volume *pool_data_lv, int chunk_size_calc_policy) { - struct logical_volume *pool_data_lv; struct lv_segment *seg; struct physical_volume *pv; struct cmd_context *cmd = pool_lv->vg->cmd; @@ -439,7 +439,6 @@ int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv, return 0; } - pool_data_lv = seg_lv(first_seg(pool_lv), 0); dm_list_iterate_items(seg, &pool_data_lv->segments) { switch (seg_type(seg, 0)) { case AREA_PV: diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 84659d3f4..c02948b03 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -3409,7 +3409,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd, seg->zero_new_blocks = zero_new_blocks; if (crop_metadata == THIN_CROP_METADATA_NO) pool_lv->status |= LV_CROP_METADATA; - if (!recalculate_pool_chunk_size_with_dev_hints(pool_lv, chunk_calc)) + if (!recalculate_pool_chunk_size_with_dev_hints(pool_lv, data_lv, chunk_calc)) goto_bad; /* Error when full */