master - cleanup: use extents to pass size to /lib
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=913f025d3e481fc4ffe6ab7b29f7e7b27c0f1b19 Commit: 913f025d3e481fc4ffe6ab7b29f7e7b27c0f1b19 Parent: d2e9802ba7eb48af8d78cee2420897201d57c406 Author: Zdenek Kabelac <[email protected]> AuthorDate: Thu Oct 30 13:04:06 2014 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Nov 3 14:19:33 2014 +0100
cleanup: use extents to pass size to /lib
Lib takes sizes in extens - do the same for pool_metadata.
--- lib/metadata/cache_manip.c | 27 +++++++++++++--------- lib/metadata/metadata-exported.h | 14 ++++++------ lib/metadata/pool_manip.c | 19 +++++++--------- lib/metadata/thin_manip.c | 44 +++++++++++++++++++++---------------- tools/lvconvert.c | 10 +++++++- tools/lvcreate.c | 10 +++++--- 6 files changed, 70 insertions(+), 54 deletions(-)
lib/metadata/cache_manip.c +16 -11
@@ -41,12 +41,13 @@ const char *get_cachepool_cachemode_name(const struct lv_segment *seg)int update_cache_pool_params (const struct segment_type *segtype,struct volume_group *vg,unsigned attr, -int passed_args,uint32_t data_extents, -uint64_t *pool_metadata_size, +int passed_args,uint32_t pool_data_extents, +uint32_t *pool_metadata_extents,int *chunk_size_calc_method,uint32_t *chunk_size) {uint64_t min_meta_size;uint32_t extent_size = vg->extent_size; +uint64_t pool_metadata_size = *pool_metadata_extents * vg->extent_size;if (!(passed_args &PASS_ARG_CHUNK_SIZE )) *chunk_size =DEFAULT_CACHE_POOL_CHUNK_SIZE *2 ;
@@ -58,7 +59,7 @@ int update_cache_pool_params(const struct segment_type *segtype,* Default meta size is: * (Overhead + mapping size + hint size) */ - min_meta_size = (uint64_t ) data_extents * extent_size / *chunk_size;/* nr_chunks */ + min_meta_size = (uint64_t ) pool_data_extents * extent_size / *chunk_size;/* nr_chunks */ min_meta_size *= (DM_BYTES_PER_BLOCK +DM_MAX_HINT_WIDTH +DM_HINT_OVERHEAD_PER_BLOCK ); min_meta_size = (min_meta_size + (SECTOR_SIZE -1 )) >>SECTOR_SHIFT ;/* in sectors */ min_meta_size +=DM_TRANSACTION_OVERHEAD * (1024 >>SECTOR_SHIFT );
@@ -67,23 +68,27 @@ int update_cache_pool_params(const struct segment_type *segtype,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) + 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_size > (2 *DEFAULT_CACHE_POOL_MAX_METADATA_SIZE )) { + pool_metadata_size =2 *DEFAULT_CACHE_POOL_MAX_METADATA_SIZE ;if (passed_args &PASS_ARG_POOL_METADATA_SIZE )log_warn ("WARNING: Maximum supported pool metadata size is %s." , -display_size (vg->cmd, *pool_metadata_size)); - }else if (*pool_metadata_size < min_meta_size) { +display_size (vg->cmd, pool_metadata_size)); + }else if (pool_metadata_size < min_meta_size) {if (passed_args &PASS_ARG_POOL_METADATA_SIZE )log_warn ("WARNING: Minimum required pool metadata size is %s " "(needs extra %s)." ,display_size (vg->cmd, min_meta_size), -display_size (vg->cmd, min_meta_size - *pool_metadata_size)); - *pool_metadata_size = min_meta_size; +display_size (vg->cmd, min_meta_size - pool_metadata_size)); + pool_metadata_size = min_meta_size; } +if (!(*pool_metadata_extents = +extents_from_size (vg->cmd, pool_metadata_size, extent_size))) + return_0; +return 1 ; }
lib/metadata/metadata-exported.h +7 -7
@@ -748,8 +748,8 @@ int validate_pool_chunk_size(struct cmd_context *cmd, const struct segment_typeint update_pool_lv (struct logical_volume *lv,int activate);int update_pool_params (const struct segment_type *segtype,struct volume_group *vg,unsigned target_attr, -int passed_args,uint32_t data_extents, -uint64_t *pool_metadata_size, +int passed_args,uint32_t pool_data_extents, +uint32_t *pool_metadata_extents,int *chunk_size_calc_policy,uint32_t *chunk_size,thin_discards_t *discards,int *zero); int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profile,
@@ -758,8 +758,8 @@ int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profi int *zero);int update_thin_pool_params (const struct segment_type *segtype,struct volume_group *vg,unsigned attr, -int passed_args,uint32_t data_extents, -uint64_t *pool_metadata_size, +int passed_args,uint32_t pool_data_extents, +uint32_t *pool_metadata_extents,int *chunk_size_calc_method,uint32_t *chunk_size,thin_discards_t *discards,int *zero);int get_pool_discards (const char *str,thin_discards_t *discards);
@@ -767,7 +767,7 @@ const char *get_pool_discards_name(thin_discards_t discards);struct logical_volume *alloc_pool_metadata (struct logical_volume *pool_lv,const char *name,uint32_t read_ahead,uint32_t stripes,uint32_t stripe_size, -uint64_t size,alloc_policy_t alloc, +uint32_t extents,alloc_policy_t alloc,struct dm_list *pvh);int handle_pool_metadata_spare (struct volume_group *vg,uint32_t extents,struct dm_list *pvh,int poolmetadataspare);
@@ -1090,8 +1090,8 @@ int partial_raid_lv_supports_degraded_activation(const struct logical_volume *lvconst char *get_cachepool_cachemode_name (const struct lv_segment *seg);int update_cache_pool_params (const struct segment_type *segtype,struct volume_group *vg,unsigned attr, -int passed_args,uint32_t data_extents, -uint64_t *pool_metadata_size, +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_create_pool (const struct logical_volume *pool_lv);int validate_lv_cache_create_origin (const struct logical_volume *origin_lv);
lib/metadata/pool_manip.c +8 -11
@@ -363,30 +363,30 @@ int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv,int update_pool_params (const struct segment_type *segtype,struct volume_group *vg,unsigned target_attr, -int passed_args,uint32_t data_extents, -uint64_t *pool_metadata_size, +int passed_args,uint32_t pool_data_extents, +uint32_t *pool_metadata_extents,int *chunk_size_calc_policy,uint32_t *chunk_size,thin_discards_t *discards,int *zero) {if (segtype_is_cache_pool (segtype) ||segtype_is_cache (segtype)) {if (!update_cache_pool_params (segtype, vg, target_attr, passed_args, - data_extents, pool_metadata_size, + pool_data_extents, pool_metadata_extents, chunk_size_calc_policy, chunk_size)) return_0; }else if (!update_thin_pool_params (segtype, vg, target_attr, passed_args, - data_extents, pool_metadata_size, + pool_data_extents, pool_metadata_extents, chunk_size_calc_policy, chunk_size, discards, zero))/* thin-pool */ return_0; -if ((uint64_t ) *chunk_size > (uint64_t ) data_extents * vg->extent_size) { +if ((uint64_t ) *chunk_size > (uint64_t ) pool_data_extents * vg->extent_size) {log_error ("Size of %s data volume cannot be smaller then chunk size %s." , segtype->name,display_size (vg->cmd, *chunk_size));return 0 ; }log_verbose ("Using pool metadata size %s." , -display_size (vg->cmd, *pool_metadata_size)); +display_size (vg->cmd, (uint64_t )*pool_metadata_extents * vg->extent_size));return 1 ; }
@@ -518,7 +518,7 @@ bad:struct logical_volume *alloc_pool_metadata (struct logical_volume *pool_lv,const char *name,uint32_t read_ahead,uint32_t stripes,uint32_t stripe_size, -uint64_t size,alloc_policy_t alloc, +uint32_t extents,alloc_policy_t alloc,struct dm_list *pvh) {struct logical_volume *metadata_lv;
@@ -526,6 +526,7 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,struct lvcreate_params lvc = { .activate =CHANGE_ALY , .alloc = alloc, + .extents = extents, .major =-1 , .minor =-1 , .permission =LVM_READ |LVM_WRITE ,
@@ -538,10 +539,6 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv, .zero = 1, }; -if (!(lvc.extents =extents_from_size (pool_lv->vg->cmd, size, - pool_lv->vg->extent_size))) - return_0; -if (!(lvc.segtype =get_segtype_from_string (pool_lv->vg->cmd,"striped" ))) return_0;
lib/metadata/thin_manip.c +25 -19
91 lines not on this page · raw message
tools/lvconvert.c +8 -2
@@ -65,6 +65,7 @@ struct lvconvert_params {struct logical_volume *lv_to_poll; +uint32_t pool_metadata_extents;int passed_args;uint64_t pool_metadata_size;const char *origin_name;
@@ -2743,12 +2744,17 @@ revert_new_lv:static int _lvconvert_update_pool_params (struct logical_volume *pool_lv,struct lvconvert_params *lp) { +if (lp->pool_metadata_size && + !(lp->pool_metadata_extents = +extents_from_size (pool_lv->vg->cmd, lp->pool_metadata_size, pool_lv->vg->extent_size))) + return_0; + return update_pool_params(lp->segtype, pool_lv->vg, lp->target_attr, lp->passed_args, pool_lv->le_count, - &lp->pool_metadata_size, + &lp->pool_metadata_extents, &lp->thin_chunk_size_calc_policy, &lp->chunk_size, &lp->discards,
@@ -3014,7 +3020,7 @@ static int _lvconvert_pool(struct cmd_context *cmd,if (!(metadata_lv =alloc_pool_metadata (pool_lv, metadata_name, lp->read_ahead, lp->stripes, lp->stripe_size, - lp->pool_metadata_size, + lp->pool_metadata_extents, lp->alloc, lp->pvh))) return_0; }else {
tools/lvcreate.c +6 -4
@@ -350,16 +350,18 @@ static int _update_extents_params(struct volume_group *vg, }if (lp->create_pool) { +if (lp->pool_metadata_size && + !(lp->pool_metadata_extents = +extents_from_size (vg->cmd, lp->pool_metadata_size, vg->extent_size))) + return_0; +if (!update_pool_params (lp->segtype, vg, lp->target_attr, lp->passed_args, lp->extents, - &lp->pool_metadata_size, + &lp->pool_metadata_extents, &lp->thin_chunk_size_calc_policy, &lp->chunk_size, &lp->discards, &lp->zero)) return_0; -if (!(lp->pool_metadata_extents = -extents_from_size (vg->cmd, lp->pool_metadata_size, vg->extent_size))) - return_0;if (lcp->percent ==PERCENT_FREE ) {if (lp->extents <= (2 * lp->pool_metadata_extents)) {log_error ("Not enough space for thin pool creation." );