Skip to contentSkip to conversation

master - lv_manip: better work with PERCENT_VG modifier with lvresize

PATCH Zdenek Kabelac 1 participant 1 message Jan 21, 2019

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=105a8edea1c4a77cc3681a7cc46a6a5c02656c5c
Commit:        105a8edea1c4a77cc3681a7cc46a6a5c02656c5c
Parent:        e689bfb5d5a9983205efbccf1e554fde52a0376a
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Mon Jan 21 15:37:51 2019 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Jan 21 15:39:24 2019 +0100

lv_manip: better work with PERCENT_VG modifier with lvresize

Fixing recent commit 022ebb0cfebee4ac8fdbe4e0c61e85db1038a115 Resize already has size that needs to be counted with, otherwise upsizing operation could turn into size reduction one.

---
 lib/metadata/lv_manip.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
lib/metadata/lv_manip.c +2 -2
index 8c9a933..00039ef 100644
@@ -5053,8 +5053,8 @@ 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;
+			if ((lp->sign == SIGN_NONE) && (lp->extents > (lv->le_count + vg->free_count))) {
+				lp->extents = lv->le_count + 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));