master - thin: support unaligned size of external origin and thin pool
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a3e0d830bde952a83da3ba60936fff2fa7b40966 Commit: a3e0d830bde952a83da3ba60936fff2fa7b40966 Parent: 6f2a617c318d3e7b4535563b72ddcaad67da62ed Author: Zdenek Kabelac <[email protected]> AuthorDate: Thu Jun 18 14:38:57 2015 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Thu Jun 18 18:50:36 2015 +0200
thin: support unaligned size of external origin and thin pool
With thin-pool kernel target module 1.13 it's now support usage of external origin with sizes which are not 'alligned' with chunk size of thin-pool.
Enable lvm2 support for this and also fix reporting of data_percent usage for case sizes are not alligned.
--- WHATS_NEW | 1 + lib/metadata/thin_manip.c | 9 +-- lib/thin/thin.c | 10 ++- test/shell/lvcreate-thin-external-size.sh | 90 +++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 8 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.122 - ================================= + Support thins with size of external origin unaligned with thin pool chunk. Allow to extend reduced thin volumes with external origins. Consider snapshot and origin LV as unusable if its component is suspended. Fix lvmconfig segfault on settings with undefined default value (2.02.120).
lib/metadata/thin_manip.c +4 -5
@@ -243,12 +243,11 @@ int pool_supports_external_origin(const struct lv_segment *pool_seg, const struc {uint32_t csize = pool_seg->chunk_size; -if ((external_lv->size < csize) || (external_lv->size % csize)) { -/* TODO: Validate with thin feature flag once, it will be supported */ -log_error ("Can't use \"%s/%s\" as external origin with \"%s/%s\" pool. " +if (((external_lv->size < csize) || (external_lv->size % csize)) && + !thin_pool_feature_supported (pool_seg->lv,THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND )) { +log_error ("Can't use \"%s\" as external origin with \"%s\" pool. " "Size %s is not a multiple of pool's chunk size %s." , - external_lv->vg->name, external_lv->name, - pool_seg->lv->vg->name, pool_seg->lv->name, +display_lvname (external_lv),display_lvname (pool_seg->lv),display_size (external_lv->vg->cmd, external_lv->size),display_size (external_lv->vg->cmd, csize));return 0 ;
lib/thin/thin.c +7 -3
@@ -609,14 +609,18 @@ static int _thin_target_percent(void **target_state __attribute__((unused)), uint64_t *total_denominator) {struct dm_status_thin *s; +uint64_t csize;/* Status for thin device is in sectors */ if (!dm_get_status_thin (mem, params, &s)) return_0;if (seg) { - *percent =dm_make_percent (s->mapped_sectors, seg->lv->size); - *total_denominator += seg->lv->size; +/* Pool allocates whole chunk so round-up to nearest one */ + csize =first_seg (seg->pool_lv)->chunk_size; + csize = ((seg->lv->size + csize -1 ) / csize) * csize; + *percent =dm_make_percent (s->mapped_sectors, csize); + *total_denominator += csize; }else {/* No lv_segment info here */ *percent =DM_PERCENT_INVALID ;
@@ -645,8 +649,8 @@ static int _thin_target_present(struct cmd_context *cmd, { 1, 4, THIN_FEATURE_BLOCK_SIZE, "block_size" }, { 1, 5, THIN_FEATURE_DISCARDS_NON_POWER_2, "discards_non_power_2" }, { 1, 10, THIN_FEATURE_METADATA_RESIZE, "metadata_resize" }, - { 9, 11, THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND, "external_origin_extend" }, { 1, 10, THIN_FEATURE_ERROR_IF_NO_SPACE, "error_if_no_space" }, + { 1, 13, THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND, "external_origin_extend" }, };static const char _lvmconf[] ="global/thin_disabled_features" ;
test/shell/lvcreate-thin-external-size.sh new file +90 -0
90 lines not on this page · raw message