Blame SOURCES/lvm2-2_03_12-pool-limit-pmspare-to-16GiB.patch

abb29f
 lib/metadata/pool_manip.c | 10 +++++++++-
abb29f
 1 file changed, 9 insertions(+), 1 deletion(-)
abb29f
abb29f
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
abb29f
index b67882e..1975cb4 100644
abb29f
--- a/lib/metadata/pool_manip.c
abb29f
+++ b/lib/metadata/pool_manip.c
abb29f
@@ -697,6 +697,8 @@ static struct logical_volume *_alloc_pool_metadata_spare(struct volume_group *vg
abb29f
 int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
abb29f
 			       struct dm_list *pvh, int poolmetadataspare)
abb29f
 {
abb29f
+	/* Max usable size of any spare volume is currently 16GiB rouned to extent size */
abb29f
+	const uint64_t MAX_SIZE = (UINT64_C(2 * 16) * 1024 * 1024 + vg->extent_size - 1) / vg->extent_size;
abb29f
 	struct logical_volume *lv = vg->pool_metadata_spare_lv;
abb29f
 	uint32_t seg_mirrors;
abb29f
 	struct lv_segment *seg;
abb29f
@@ -706,8 +708,11 @@ int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
abb29f
 		/* Find maximal size of metadata LV */
abb29f
 		dm_list_iterate_items(lvl, &vg->lvs)
abb29f
 			if (lv_is_pool_metadata(lvl->lv) &&
abb29f
-			    (lvl->lv->le_count > extents))
abb29f
+			    (lvl->lv->le_count > extents)) {
abb29f
 				extents = lvl->lv->le_count;
abb29f
+				if (extents >= MAX_SIZE)
abb29f
+					break;
abb29f
+			}
abb29f
 
abb29f
 	if (!poolmetadataspare) {
abb29f
 		/* TODO: Not showing when lvm.conf would define 'n' ? */
abb29f
@@ -718,6 +723,9 @@ int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
abb29f
 		return 1;
abb29f
 	}
abb29f
 
abb29f
+	if (extents > MAX_SIZE)
abb29f
+		extents = MAX_SIZE;
abb29f
+
abb29f
 	if (!lv) {
abb29f
 		if (!_alloc_pool_metadata_spare(vg, extents, pvh))
abb29f
 			return_0;