From 90423c12001e9b7a8bf8ee3b56d5858c0a563867 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 5 Mar 2012 14:19:13 +0000 Subject: [PATCH] Fit thin pool metadata into 128MB If the lvcreate may decide some automagical values for a user, try to keep the pool metadata size into 128MB range for optimal perfomance (as suggested by Joe). So if the pool metadata size and chunk_size were not specified, try to select such values they would fit into 128MB size. --- WHATS_NEW | 1 + lib/config/defaults.h | 1 + tools/lvcreate.c | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index e7074b898..1fbea5a25 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.95 - ================================ + Try to fit thin pool metadata size into 128MB. Print just warning on thin pool check callback path for failing check. Use 64bit math for verification of thin pool and snapshot chunk size. Validate udev structures in _insert_udev_dir(). diff --git a/lib/config/defaults.h b/lib/config/defaults.h index cdb8757d1..4eb2f485c 100644 --- a/lib/config/defaults.h +++ b/lib/config/defaults.h @@ -68,6 +68,7 @@ #define DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS 0 #define DEFAULT_THIN_POOL_MAX_METADATA_SIZE (16 * 1024 * 1024) /* KB */ #define DEFAULT_THIN_POOL_MIN_METADATA_SIZE 2048 /* KB */ +#define DEFAULT_THIN_POOL_OPTIMAL_SIZE (128 * 1024 * 1024) /* KB */ #define DEFAULT_UMASK 0077 diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 4d3ccfe7c..ea5111bd7 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -235,6 +235,7 @@ static int _update_extents_params(struct volume_group *vg, { uint32_t pv_extent_count; struct logical_volume *origin = NULL; + int changed = 0; if (lcp->size && !(lp->extents = extents_from_size(vg->cmd, lcp->size, @@ -294,11 +295,26 @@ static int _update_extents_params(struct volume_group *vg, } if (lp->create_thin_pool) { - if (!arg_count(vg->cmd, poolmetadatasize_ARG)) + if (!arg_count(vg->cmd, poolmetadatasize_ARG)) { /* Defaults to nr_pool_blocks * 64b */ lp->poolmetadatasize = (uint64_t) lp->extents * vg->extent_size / (uint64_t) (lp->chunk_size * (SECTOR_SIZE / UINT64_C(64))); + /* Check if we could eventually use bigger chunk size */ + if (!arg_count(vg->cmd, chunksize_ARG)) { + while ((lp->poolmetadatasize > + (DEFAULT_THIN_POOL_OPTIMAL_SIZE / SECTOR_SIZE)) && + (lp->chunk_size < DM_THIN_MAX_DATA_BLOCK_SIZE)) { + lp->chunk_size <<= 1; + lp->poolmetadatasize >>= 1; + changed++; + } + if (changed) + log_verbose("Changed chunksize to %u sectors.", + lp->chunk_size); + } + } + if (lp->poolmetadatasize > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) { if (arg_count(vg->cmd, poolmetadatasize_ARG)) log_warn("WARNING: Maximum supported pool metadata size is 16GB."); -- 2.43.5