From c6f3701a718ebfb34266c6cd116f519201dae632 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 11 Apr 2012 12:33:34 +0000 Subject: Support rounding downward for lvcreate and % If specifying size with % and we are reaching number of free extents - round downward with stripes. --- tools/lvcreate.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tools/lvcreate.c') diff --git a/tools/lvcreate.c b/tools/lvcreate.c index aa2d8075..28d4dbff 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -236,6 +236,8 @@ static int _update_extents_params(struct volume_group *vg, uint32_t pv_extent_count; struct logical_volume *origin = NULL; int changed = 0; + uint32_t size_rest; + uint32_t stripesize_extents; if (lcp->size && !(lp->extents = extents_from_size(vg->cmd, lcp->size, @@ -294,6 +296,18 @@ static int _update_extents_params(struct volume_group *vg, break; } + if (!(stripesize_extents = lp->stripe_size / vg->extent_size)) + stripesize_extents = 1; + + if ((lcp->percent != PERCENT_NONE) && lp->stripes && + (size_rest = lp->extents % (lp->stripes * stripesize_extents)) && + (vg->free_count < lp->extents - size_rest + (lp->stripes * stripesize_extents))) { + log_print("Rounding size (%d extents) down to stripe boundary " + "size (%d extents)", lp->extents, + lp->extents - size_rest); + lp->extents = lp->extents - size_rest; + } + if (lp->create_thin_pool) { if (!arg_count(vg->cmd, poolmetadatasize_ARG)) { /* Defaults to nr_pool_blocks * 64b */ -- cgit