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