master - cache: add validate_lv_cache_chunk_size
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ae805eea50b1033115a18b8a0c9931c2c917b8b2 Commit: ae805eea50b1033115a18b8a0c9931c2c917b8b2 Parent: 00dfca034c7478b88874d43bc36633e3176d1866 Author: Zdenek Kabelac <[email protected]> AuthorDate: Tue May 3 21:50:04 2016 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Thu May 5 23:30:49 2016 +0200
cache: add validate_lv_cache_chunk_size
--- lib/metadata/cache_manip.c | 19 +++++++++++++++++++ lib/metadata/metadata-exported.h | 1 + 2 files changed, 20 insertions(+), 0 deletions(-)
lib/metadata/cache_manip.c +19 -0
@@ -184,6 +184,25 @@ int update_cache_pool_params(const struct segment_type *segtype, }/* +* 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. * * Always validates origin_lv, and when it is known also cache pool_lv
lib/metadata/metadata-exported.h +1 -0
@@ -1222,6 +1222,7 @@ int update_cache_pool_params(const struct segment_type *segtype, int passed_args, uint32_t pool_data_extents, uint32_t *pool_metadata_extents, 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_origin (const struct logical_volume *origin_lv); struct logical_volume *lv_cache_create(struct logical_volume *pool,