Blob Blame History Raw
 WHATS_NEW               |  4 ++++
 lib/metadata/lv_manip.c | 23 ++++++++++++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/WHATS_NEW b/WHATS_NEW
index 1718c29..0fa6bb6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,7 @@
+Version 2.02.133 - 
+======================================
+  Check for enough space in thin-pool in command before creating new thin.
+
 Version 2.02.131 - 
 =====================================
   Fix vgimportclone cache_dir path name (2.02.115).
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 88c516b..32aa666 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7038,12 +7038,25 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
 			}
 		}
 
-		if (seg_is_thin_volume(lp) &&
-		    lv_is_new_thin_pool(pool_lv)) {
+		if (seg_is_thin_volume(lp)) {
 			thin_pool_was_active = lv_is_active(pool_lv);
-			if (!check_new_thin_pool(pool_lv))
-				return_NULL;
-			/* New pool is now inactive */
+			if (lv_is_new_thin_pool(pool_lv)) {
+				if (!check_new_thin_pool(pool_lv))
+					return_NULL;
+				/* New pool is now inactive */
+			} else {
+				if (!activate_lv_excl_local(cmd, pool_lv)) {
+					log_error("Aborting. Failed to locally activate thin pool %s.",
+						  display_lvname(pool_lv));
+					return 0;
+				}
+				if (!pool_below_threshold(first_seg(pool_lv))) {
+					log_error("Cannot create new thin volume, free space in "
+						  "thin pool %s reached threshold.",
+						  display_lvname(pool_lv));
+					return NULL;
+				}
+			}
 		}
 
 		if (seg_is_cache(lp) &&