1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

cache: add validate_lv_cache_chunk_size

This commit is contained in:
Zdenek Kabelac 2016-05-03 21:50:04 +02:00
parent 00dfca034c
commit ae805eea50
2 changed files with 20 additions and 0 deletions

View File

@ -183,6 +183,25 @@ int update_cache_pool_params(const struct segment_type *segtype,
return 1; return 1;
} }
/*
* Validate if existing cache-pool can be used with given chunk size
* i.e. cache-pool metadata size fits all info.
*/
int validate_lv_cache_chunk_size(struct logical_volume *pool_lv, uint32_t chunk_size)
{
uint64_t min_size = _cache_min_metadata_size(pool_lv->size, chunk_size);
if (min_size > first_seg(pool_lv)->metadata_lv->size) {
log_error("Cannot use chunk size %s with cache pool %s. "
"Minimal required size for metadata is %s.",
display_size(pool_lv->vg->cmd, chunk_size),
display_lvname(pool_lv),
display_size(pool_lv->vg->cmd, min_size));
return 0;
}
return 1;
}
/* /*
* Validate arguments for converting origin into cached volume with given cache pool. * Validate arguments for converting origin into cached volume with given cache pool.
* *

View File

@ -1222,6 +1222,7 @@ int update_cache_pool_params(const struct segment_type *segtype,
int passed_args, uint32_t pool_data_extents, int passed_args, uint32_t pool_data_extents,
uint32_t *pool_metadata_extents, uint32_t *pool_metadata_extents,
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_create_pool(const struct logical_volume *pool_lv); int validate_lv_cache_create_pool(const struct logical_volume *pool_lv);
int validate_lv_cache_create_origin(const struct logical_volume *origin_lv); int validate_lv_cache_create_origin(const struct logical_volume *origin_lv);
struct logical_volume *lv_cache_create(struct logical_volume *pool, struct logical_volume *lv_cache_create(struct logical_volume *pool,