1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cache: reuse code for metadata min_max

Use update_pool_metadata_min_max() which is shared with
thin-pool metadata min-max updating.

Gives improved messages when converting volumes to metadata.
This commit is contained in:
Zdenek Kabelac 2021-01-30 16:32:51 +01:00
parent f96b455506
commit abc9265a06
4 changed files with 18 additions and 27 deletions

View File

@ -204,6 +204,7 @@ int update_cache_pool_params(struct cmd_context *cmd,
unsigned attr, unsigned attr,
uint32_t pool_data_extents, uint32_t pool_data_extents,
uint32_t *pool_metadata_extents, uint32_t *pool_metadata_extents,
struct logical_volume *metadata_lv,
int *chunk_size_calc_method, uint32_t *chunk_size) int *chunk_size_calc_method, uint32_t *chunk_size)
{ {
uint64_t min_meta_size; uint64_t min_meta_size;
@ -252,39 +253,26 @@ int update_cache_pool_params(struct cmd_context *cmd,
if (!validate_cache_chunk_size(cmd, *chunk_size)) if (!validate_cache_chunk_size(cmd, *chunk_size))
return_0; return_0;
min_meta_size = _cache_min_metadata_size((uint64_t) pool_data_extents * extent_size, *chunk_size);
/* Round up to extent size */
if (min_meta_size % extent_size)
min_meta_size += extent_size - min_meta_size % extent_size;
if (!pool_metadata_size)
pool_metadata_size = min_meta_size;
if (pool_metadata_size > (2 * DEFAULT_CACHE_POOL_MAX_METADATA_SIZE)) {
pool_metadata_size = 2 * DEFAULT_CACHE_POOL_MAX_METADATA_SIZE;
if (*pool_metadata_extents)
log_warn("WARNING: Maximum supported pool metadata size is %s.",
display_size(cmd, pool_metadata_size));
} else if (pool_metadata_size < min_meta_size) {
if (*pool_metadata_extents)
log_warn("WARNING: Minimum required pool metadata size is %s "
"(needs extra %s).",
display_size(cmd, min_meta_size),
display_size(cmd, min_meta_size - pool_metadata_size));
pool_metadata_size = min_meta_size;
}
if (!(*pool_metadata_extents =
extents_from_size(cmd, pool_metadata_size, extent_size)))
return_0;
if ((uint64_t) *chunk_size > (uint64_t) pool_data_extents * extent_size) { if ((uint64_t) *chunk_size > (uint64_t) pool_data_extents * extent_size) {
log_error("Size of %s data volume cannot be smaller than chunk size %s.", log_error("Size of %s data volume cannot be smaller than chunk size %s.",
segtype->name, display_size(cmd, *chunk_size)); segtype->name, display_size(cmd, *chunk_size));
return 0; return 0;
} }
min_meta_size = _cache_min_metadata_size((uint64_t) pool_data_extents * extent_size, *chunk_size);
min_meta_size = dm_round_up(min_meta_size, extent_size);
if (!pool_metadata_size)
pool_metadata_size = min_meta_size;
if (!update_pool_metadata_min_max(cmd, extent_size,
min_meta_size,
(2 * DEFAULT_CACHE_POOL_MAX_METADATA_SIZE),
&pool_metadata_size,
metadata_lv,
pool_metadata_extents))
return_0;
log_verbose("Preferred pool metadata size %s.", log_verbose("Preferred pool metadata size %s.",
display_size(cmd, (uint64_t)*pool_metadata_extents * extent_size)); display_size(cmd, (uint64_t)*pool_metadata_extents * extent_size));

View File

@ -1320,6 +1320,7 @@ int update_cache_pool_params(struct cmd_context *cmd,
unsigned attr, unsigned attr,
uint32_t pool_data_extents, uint32_t pool_data_extents,
uint32_t *pool_metadata_extents, uint32_t *pool_metadata_extents,
struct logical_volume *metadata_lv,
int *chunk_size_calc_method, uint32_t *chunk_size); int *chunk_size_calc_method, uint32_t *chunk_size);
int validate_lv_cache_chunk_size(struct logical_volume *pool_lv, uint32_t chunk_size); int validate_lv_cache_chunk_size(struct logical_volume *pool_lv, uint32_t chunk_size);
int validate_lv_cache_create_pool(const struct logical_volume *pool_lv); int validate_lv_cache_create_pool(const struct logical_volume *pool_lv);

View File

@ -3189,6 +3189,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
pool_segtype, target_attr, pool_segtype, target_attr,
lv->le_count, lv->le_count,
&meta_extents, &meta_extents,
metadata_lv,
&chunk_calc, &chunk_calc,
&chunk_size)) &chunk_size))
goto_bad; goto_bad;

View File

@ -403,6 +403,7 @@ static int _update_extents_params(struct volume_group *vg,
lp->segtype, lp->target_attr, lp->segtype, lp->target_attr,
lp->extents, lp->extents,
&lp->pool_metadata_extents, &lp->pool_metadata_extents,
NULL,
&lp->thin_chunk_size_calc_policy, &lp->thin_chunk_size_calc_policy,
&lp->chunk_size)) &lp->chunk_size))
return_0; return_0;