1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

pool: support passing data_lv for recalculation

Support data_lv to be passed as parameter when it's not yet
attached to the pool.
This commit is contained in:
Zdenek Kabelac 2023-07-02 11:21:15 +02:00
parent 5175e87fda
commit 558890ad0e
5 changed files with 6 additions and 4 deletions

View File

@ -1229,6 +1229,7 @@ int cache_set_params(struct lv_segment *seg,
if (!pool_seg->chunk_size && if (!pool_seg->chunk_size &&
/* TODO: some calc_policy solution for cache ? */ /* TODO: some calc_policy solution for cache ? */
!recalculate_pool_chunk_size_with_dev_hints(pool_seg->lv, !recalculate_pool_chunk_size_with_dev_hints(pool_seg->lv,
seg_lv(pool_seg, 0),
THIN_CHUNK_SIZE_CALC_METHOD_GENERIC)) THIN_CHUNK_SIZE_CALC_METHOD_GENERIC))
return_0; return_0;
} }

View File

@ -9457,7 +9457,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
first_seg(lv)->discards = lp->discards; first_seg(lv)->discards = lp->discards;
if ((first_seg(lv)->crop_metadata = lp->crop_metadata) == THIN_CROP_METADATA_NO) if ((first_seg(lv)->crop_metadata = lp->crop_metadata) == THIN_CROP_METADATA_NO)
lv->status |= LV_CROP_METADATA; 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; stack;
goto revert_new_lv; goto revert_new_lv;
} }

View File

@ -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 update_thin_pool_lv(struct logical_volume *lv, int activate);
int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv, 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 chunk_size_calc_policy);
int validate_cache_chunk_size(struct cmd_context *cmd, uint32_t chunk_size); 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); int validate_thin_pool_chunk_size(struct cmd_context *cmd, uint32_t chunk_size);

View File

@ -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, 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 chunk_size_calc_policy)
{ {
struct logical_volume *pool_data_lv;
struct lv_segment *seg; struct lv_segment *seg;
struct physical_volume *pv; struct physical_volume *pv;
struct cmd_context *cmd = pool_lv->vg->cmd; 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; return 0;
} }
pool_data_lv = seg_lv(first_seg(pool_lv), 0);
dm_list_iterate_items(seg, &pool_data_lv->segments) { dm_list_iterate_items(seg, &pool_data_lv->segments) {
switch (seg_type(seg, 0)) { switch (seg_type(seg, 0)) {
case AREA_PV: case AREA_PV:

View File

@ -3409,7 +3409,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
seg->zero_new_blocks = zero_new_blocks; seg->zero_new_blocks = zero_new_blocks;
if (crop_metadata == THIN_CROP_METADATA_NO) if (crop_metadata == THIN_CROP_METADATA_NO)
pool_lv->status |= LV_CROP_METADATA; 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; goto_bad;
/* Error when full */ /* Error when full */