mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_03_12-alloc-enhance-estimation-of-sufficient_pes_free.patch

31f061
 WHATS_NEW               | 10 ++++++++--
31f061
 lib/metadata/lv_manip.c | 10 +++++++---
31f061
 2 files changed, 11 insertions(+), 3 deletions(-)
31f061
31f061
diff --git a/WHATS_NEW b/WHATS_NEW
31f061
index 452a631..fe347f7 100644
31f061
--- a/WHATS_NEW
31f061
+++ b/WHATS_NEW
31f061
@@ -1,3 +1,7 @@
31f061
+Version 2.03.12 - 
31f061
+===================================
31f061
+  Fix corner case allocation for thin-pools.
31f061
+
31f061
 Version 2.03.11 - 08th January 2021
31f061
 ===================================
31f061
   Fix pvck handling MDA at offset different from 4096.
31f061
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
31f061
index 7046436..443d32c 100644
31f061
--- a/lib/metadata/lv_manip.c
31f061
+++ b/lib/metadata/lv_manip.c
31f061
@@ -1850,11 +1850,13 @@ static uint32_t _mirror_log_extents(uint32_t region_size, uint32_t pe_size, uint
31f061
 
31f061
 /* Is there enough total space or should we give up immediately? */
31f061
 static int _sufficient_pes_free(struct alloc_handle *ah, struct dm_list *pvms,
31f061
-				uint32_t allocated, uint32_t extents_still_needed)
31f061
+				uint32_t allocated, uint32_t log_still_needed,
31f061
+				uint32_t extents_still_needed)
31f061
 {
31f061
 	uint32_t area_extents_needed = (extents_still_needed - allocated) * ah->area_count / ah->area_multiple;
31f061
 	uint32_t parity_extents_needed = (extents_still_needed - allocated) * ah->parity_count / ah->area_multiple;
31f061
-	uint32_t metadata_extents_needed = ah->alloc_and_split_meta ? 0 : ah->metadata_area_count * RAID_METADATA_AREA_LEN + ah->log_len; /* One each */
31f061
+	uint32_t metadata_extents_needed = (ah->alloc_and_split_meta ? 0 : ah->metadata_area_count * RAID_METADATA_AREA_LEN) +
31f061
+	    (log_still_needed ? ah->log_len : 0); /* One each */
31f061
 	uint64_t total_extents_needed = (uint64_t)area_extents_needed + parity_extents_needed + metadata_extents_needed;
31f061
 	uint32_t free_pes = pv_maps_size(pvms);
31f061
 
31f061
@@ -3359,7 +3361,9 @@ static int _allocate(struct alloc_handle *ah,
31f061
 		old_allocated = alloc_state.allocated;
31f061
 		log_debug_alloc("Trying allocation using %s policy.", get_alloc_string(alloc));
31f061
 
31f061
-		if (!ah->approx_alloc && !_sufficient_pes_free(ah, pvms, alloc_state.allocated, ah->new_extents))
31f061
+		if (!ah->approx_alloc && !_sufficient_pes_free(ah, pvms, alloc_state.allocated,
31f061
+							       alloc_state.log_area_count_still_needed,
31f061
+							       ah->new_extents))
31f061
 			goto_out;
31f061
 
31f061
 		_init_alloc_parms(ah, &alloc_parms, alloc, prev_lvseg,