Skip to contentSkip to conversation

main - vdo: fix and enhance vdo constain checking

PATCH Zdenek Kabelac 1 participant 1 message Jan 16, 2023

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2451bc568feb9b3d0cb4d7c15e3c723f4d0c8cc9
Commit:        2451bc568feb9b3d0cb4d7c15e3c723f4d0c8cc9
Parent:        1bed2cafe83096cf01cfff5cd2cd64ecb32b7d78
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Sun Jan 15 21:27:37 2023 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Jan 16 12:37:40 2023 +0100

vdo: fix and enhance vdo constain checking

Enhance checking vdo constains so it also handles changes of active VDO LVs where only added difference is considered now.

For this also the reported informational message about used memory was improved to only list consuming RAM blocks.

---
 WHATS_NEW                        |  1 +
 lib/metadata/metadata-exported.h |  4 +--
 lib/metadata/vdo_manip.c         | 77 ++++++++++++++++++++++++++++++----------
 lib/vdo/vdo.c                    | 24 +++++++++++--
 tools/lvcreate.c                 |  8 +++--
 5 files changed, 89 insertions(+), 25 deletions(-)
WHATS_NEW +1 -0
index 357203a4d..191338868 100644
@@ -1,5 +1,6 @@
 version 2.03.19 - 
 ====================================
+  Fix and improve runtime memory size detection for VDO volumes.
 
 version 2.03.18 - 22nd december 2022
 ====================================
lib/metadata/metadata-exported.h +2 -2
index 7c481905a..a27345781 100644
@@ -1382,8 +1382,8 @@ struct vdo_pool_size_config {
 	uint32_t block_map_cache_size_mb;
 	uint32_t index_memory_size_mb;
 };
-int check_vdo_constrains(struct cmd_context *cmd, uint64_t physical_size,
-			 uint64_t virtual_size, struct dm_vdo_target_params *vtp);
+
+int check_vdo_constrains(struct cmd_context *cmd, const struct vdo_pool_size_config *cfg);
 /* --  metadata/vdo_manip.c */
 
 struct logical_volume *find_pvmove_lv(struct volume_group *vg,
lib/metadata/vdo_manip.c +58 -19

110 lines not on this page · raw message

lib/vdo/vdo.c +22 -2
index d2d14d146..133678ae7 100644
@@ -355,6 +355,27 @@ static int _vdo_pool_target_status_compatible(const char *type)
 	return (strcmp(type, TARGET_NAME_VDO) == 0);
 }
 
+static int _vdo_check(struct cmd_context *cmd, const struct lv_segment *seg)
+{
+
+	struct vdo_pool_size_config cfg = { 0 };
+
+	if (!lv_vdo_pool_size_config(seg->lv, &cfg))
+		return_0;
+
+	/* Check if we are just adding more size to the already running vdo pool */
+	if (seg->lv->size >= cfg.physical_size)
+		cfg.physical_size = seg->lv->size - cfg.physical_size;
+	if (get_vdo_pool_virtual_size(seg) >= cfg.virtual_size)
+		cfg.virtual_size = get_vdo_pool_virtual_size(seg) - cfg.virtual_size;
+	if (seg->vdo_params.block_map_cache_size_mb >= cfg.block_map_cache_size_mb)
+		cfg.block_map_cache_size_mb = seg->vdo_params.block_map_cache_size_mb - cfg.block_map_cache_size_mb;
+	if (seg->vdo_params.index_memory_size_mb >= cfg.index_memory_size_mb)
+		cfg.index_memory_size_mb = seg->vdo_params.index_memory_size_mb - cfg.index_memory_size_mb;
+
+	return check_vdo_constrains(cmd, &cfg);
+}
+
 static int _vdo_pool_add_target_line(struct dev_manager *dm,
 				     struct dm_pool *mem,
 				     struct cmd_context *cmd,
@@ -375,8 +396,7 @@ static int _vdo_pool_add_target_line(struct dev_manager *dm,
 		return 0;
 	}
 
-	if (!critical_section() &&
-	    !check_vdo_constrains(cmd, seg->lv->size, get_vdo_pool_virtual_size(seg), &seg->vdo_params))
+	if (!critical_section() && !_vdo_check(cmd, seg))
 		return_0;
 
 	if (!(vdo_pool_name = dm_build_dm_name(mem, seg->lv->vg->name, seg->lv->name, lv_layer(seg->lv))))
tools/lvcreate.c +6 -2
index 3c89fd2c1..06d24430f 100644
@@ -1762,8 +1762,12 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name,
 	if (!_update_extents_params(vg, lp, lcp))
 		goto_out;
 
-	if (seg_is_vdo(lp) && !check_vdo_constrains(cmd, (uint64_t)lp->extents * vg->extent_size,
-						    lcp->virtual_size, &lp->vdo_params))
+	if (seg_is_vdo(lp) &&
+	    !check_vdo_constrains(cmd, &(struct vdo_pool_size_config) {
+				  .physical_size = (uint64_t)lp->extents * vg->extent_size,
+				  .virtual_size = lcp->virtual_size,
+				  .block_map_cache_size_mb = lp->vdo_params.block_map_cache_size_mb,
+				  .index_memory_size_mb = lp->vdo_params.index_memory_size_mb }))
 		goto_out;
 
 	if (seg_is_thin(lp) && !_validate_internal_thin_processing(lp))