1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lv_manip: better work with PERCENT_VG modifier

When using 'lvcreate -l100%VG' and there is big disproportion between
real available space and requested setting - automatically fallback
to 100%FREE.

Difference can be seen when VG is big and already most space was
allocated, so the requestion 100%VG can end (and by spec for % modifier
it's correct) as LV with size of 1%VG.  Usually this is not a big
problem - buit in some cases - like cache-pool allocation, this
can result a big difference for chunksize selection.

With this patch it's more closely match common-sense logic without
the need of reitteration of too big changes in lvm2 core ATM.

TODO: in the future there should be allocator solving all allocations
in a single call.
This commit is contained in:
Zdenek Kabelac 2019-01-18 22:27:02 +01:00
parent 74ae1c5bc1
commit 022ebb0cfe
3 changed files with 13 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.03.02 -
===================================
Improve -lXXX%VG modifier which improves cache segment estimation.
Ensure migration_threshold for cache is at least 8 chunks.
Restore missing man info lvcreate --zero for thin-pools.
Drop misleadning comment for metadata minimum_io_size for VDO segment.

View File

@ -5028,6 +5028,12 @@ static int _lvresize_extents_from_percent(const struct logical_volume *lv,
case PERCENT_VG:
lp->extents = percent_of_extents(lp->extents, vg->extent_count,
(lp->sign != SIGN_MINUS));
if (lp->sign == SIGN_NONE && lp->extents > vg->free_count) {
lp->extents = vg->free_count;
log_print_unless_silent("Reducing %u%%VG to remaining free space %s in VG.",
old_extents,
display_size(vg->cmd, (uint64_t)vg->extent_size * lp->extents));
}
break;
case PERCENT_FREE:
lp->extents = percent_of_extents(lp->extents, vg->free_count,

View File

@ -278,6 +278,12 @@ static int _update_extents_params(struct volume_group *vg,
switch (lcp->percent) {
case PERCENT_VG:
extents = percent_of_extents(lp->extents, base_calc_extents = vg->extent_count, 0);
if (extents > vg->free_count) {
extents = vg->free_count;
log_print_unless_silent("Reducing %u%%VG to remaining free space %s in VG.",
lp->extents,
display_size(vg->cmd, (uint64_t)vg->extent_size * extents));
}
break;
case PERCENT_FREE:
extents = percent_of_extents(lp->extents, base_calc_extents = vg->free_count, 0);