mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_03_13-vdo-support-vdo_pool_header_size.patch

4aaf76
 conf/example.conf.in             |  5 +++++
4aaf76
 lib/config/config_settings.h     |  3 +++
4aaf76
 lib/config/defaults.h            |  3 +--
4aaf76
 lib/metadata/lv_manip.c          |  3 ++-
4aaf76
 lib/metadata/metadata-exported.h |  5 ++++-
4aaf76
 lib/metadata/vdo_manip.c         | 13 ++++++++-----
4aaf76
 tools/lvconvert.c                |  6 ++++--
4aaf76
 tools/lvcreate.c                 |  2 +-
4aaf76
 8 files changed, 28 insertions(+), 12 deletions(-)
4aaf76
4aaf76
diff --git a/conf/example.conf.in b/conf/example.conf.in
4aaf76
index aaf73a4..78547a6 100644
4aaf76
--- a/conf/example.conf.in
4aaf76
+++ b/conf/example.conf.in
4aaf76
@@ -734,6 +734,11 @@ allocation {
4aaf76
 	# The default and minimum is 1. The maximum is UINT_MAX / 4096.
4aaf76
 	# This configuration option has an automatic default value.
4aaf76
 	# vdo_max_discard = 1
4aaf76
+
4aaf76
+	# Configuration option allocation/vdo_pool_header_size.
4aaf76
+	# Specified the emptry header size in KiB at the front and end of vdo pool device.
4aaf76
+	# This configuration option has an automatic default value.
4aaf76
+	# vdo_pool_header_size = 512
4aaf76
 }
4aaf76
 
4aaf76
 # Configuration section log.
4aaf76
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
4aaf76
index f5dac4d..5217da8 100644
4aaf76
--- a/lib/config/config_settings.h
4aaf76
+++ b/lib/config/config_settings.h
4aaf76
@@ -816,6 +816,9 @@ cfg(allocation_vdo_max_discard_CFG, "vdo_max_discard", allocation_CFG_SECTION, C
4aaf76
 	"increased latency for the individual discard requests.\n"
4aaf76
 	"The default and minimum is 1. The maximum is UINT_MAX / 4096.\n")
4aaf76
 
4aaf76
+cfg(allocation_vdo_pool_header_size_CFG, "vdo_pool_header_size", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_VDO_POOL_HEADER_SIZE_KB, vsn(2, 3, 12), NULL, 0, NULL,
4aaf76
+	"Specified the emptry header size in KiB at the front and end of vdo pool device.\n")
4aaf76
+
4aaf76
 cfg(log_report_command_log_CFG, "report_command_log", log_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED | CFG_DISALLOW_INTERACTIVE, CFG_TYPE_BOOL, DEFAULT_COMMAND_LOG_REPORT, vsn(2, 2, 158), NULL, 0, NULL,
4aaf76
 	"Enable or disable LVM log reporting.\n"
4aaf76
 	"If enabled, LVM will collect a log of operations, messages,\n"
4aaf76
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
4aaf76
index 2870dee..d5e5b3b 100644
4aaf76
--- a/lib/config/defaults.h
4aaf76
+++ b/lib/config/defaults.h
4aaf76
@@ -181,8 +181,7 @@
4aaf76
  * VDO pool will reverve some sectors in the front and the back of pool device to avoid
4aaf76
  * seeing same device twice in the system.
4aaf76
  */
4aaf76
-#define DEFAULT_VDO_POOL_HEADER_SIZE  (1024)   // 512KiB
4aaf76
-
4aaf76
+#define DEFAULT_VDO_POOL_HEADER_SIZE_KB  (512)
4aaf76
 
4aaf76
 
4aaf76
 #define DEFAULT_FSADM_PATH FSADM_PATH
4aaf76
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
4aaf76
index 37dd361..43af474 100644
4aaf76
--- a/lib/metadata/lv_manip.c
4aaf76
+++ b/lib/metadata/lv_manip.c
4aaf76
@@ -8766,7 +8766,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
4aaf76
 	}
4aaf76
 
4aaf76
 	if (seg_is_vdo_pool(lp)) {
4aaf76
-		if (!convert_vdo_pool_lv(lv, &lp->vdo_params, &lp->virtual_extents, 1)) {
4aaf76
+		if (!convert_vdo_pool_lv(lv, &lp->vdo_params, &lp->virtual_extents,
4aaf76
+					 1, lp->vdo_pool_header_size)) {
4aaf76
 			stack;
4aaf76
 			goto deactivate_and_revert_new_lv;
4aaf76
 		}
4aaf76
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
4aaf76
index 54bc0d0..adbbe76 100644
4aaf76
--- a/lib/metadata/metadata-exported.h
4aaf76
+++ b/lib/metadata/metadata-exported.h
4aaf76
@@ -1033,6 +1033,7 @@ struct lvcreate_params {
4aaf76
 	int approx_alloc;     /* all */
4aaf76
 	alloc_policy_t alloc; /* all */
4aaf76
 	struct dm_vdo_target_params vdo_params; /* vdo */
4aaf76
+	uint64_t vdo_pool_header_size; /* VDO */
4aaf76
 
4aaf76
 	int raidintegrity;
4aaf76
 	const char *raidintegritymode;
4aaf76
@@ -1367,10 +1368,12 @@ int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_
4aaf76
 struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
4aaf76
 					   const struct dm_vdo_target_params *vtp,
4aaf76
 					   uint32_t *virtual_extents,
4aaf76
-					   int format);
4aaf76
+					   int format,
4aaf76
+					   uint64_t vdo_pool_header_size);
4aaf76
 int set_vdo_write_policy(enum dm_vdo_write_policy *vwp, const char *policy);
4aaf76
 int fill_vdo_target_params(struct cmd_context *cmd,
4aaf76
 			   struct dm_vdo_target_params *vtp,
4aaf76
+			   uint64_t *vdo_pool_header_size,
4aaf76
 			   struct profile *profile);
4aaf76
 /* --  metadata/vdo_manip.c */
4aaf76
 
4aaf76
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
4aaf76
index afc513a..3f2de1a 100644
4aaf76
--- a/lib/metadata/vdo_manip.c
4aaf76
+++ b/lib/metadata/vdo_manip.c
4aaf76
@@ -356,9 +356,9 @@ static int _format_vdo_pool_data_lv(struct logical_volume *data_lv,
4aaf76
 struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
4aaf76
 					   const struct dm_vdo_target_params *vtp,
4aaf76
 					   uint32_t *virtual_extents,
4aaf76
-					   int format)
4aaf76
+					   int format,
4aaf76
+					   uint64_t vdo_pool_header_size)
4aaf76
 {
4aaf76
-	const uint64_t header_size = DEFAULT_VDO_POOL_HEADER_SIZE;
4aaf76
 	const uint32_t extent_size = data_lv->vg->extent_size;
4aaf76
 	struct cmd_context *cmd = data_lv->vg->cmd;
4aaf76
 	struct logical_volume *vdo_pool_lv = data_lv;
4aaf76
@@ -379,7 +379,7 @@ struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
4aaf76
 
4aaf76
 	if (*virtual_extents)
4aaf76
 		vdo_logical_size =
4aaf76
-			_get_virtual_size(*virtual_extents, extent_size, header_size);
4aaf76
+			_get_virtual_size(*virtual_extents, extent_size, vdo_pool_header_size);
4aaf76
 
4aaf76
 	if (!dm_vdo_validate_target_params(vtp, vdo_logical_size))
4aaf76
 		return_0;
4aaf76
@@ -403,7 +403,7 @@ struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
4aaf76
 		return NULL;
4aaf76
 	}
4aaf76
 
4aaf76
-	vdo_logical_size -= 2 * header_size;
4aaf76
+	vdo_logical_size -= 2 * vdo_pool_header_size;
4aaf76
 
4aaf76
 	if (vdo_logical_size < extent_size) {
4aaf76
 		if (!*virtual_extents)
4aaf76
@@ -426,7 +426,7 @@ struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
4aaf76
 	vdo_pool_seg = first_seg(vdo_pool_lv);
4aaf76
 	vdo_pool_seg->segtype = vdo_pool_segtype;
4aaf76
 	vdo_pool_seg->vdo_params = *vtp;
4aaf76
-	vdo_pool_seg->vdo_pool_header_size = DEFAULT_VDO_POOL_HEADER_SIZE;
4aaf76
+	vdo_pool_seg->vdo_pool_header_size = vdo_pool_header_size;
4aaf76
 	vdo_pool_seg->vdo_pool_virtual_extents = *virtual_extents;
4aaf76
 
4aaf76
 	vdo_pool_lv->status |= LV_VDO_POOL;
4aaf76
@@ -453,6 +453,7 @@ int set_vdo_write_policy(enum dm_vdo_write_policy *vwp, const char *policy)
4aaf76
 
4aaf76
 int fill_vdo_target_params(struct cmd_context *cmd,
4aaf76
 			   struct dm_vdo_target_params *vtp,
4aaf76
+			   uint64_t *vdo_pool_header_size,
4aaf76
 			   struct profile *profile)
4aaf76
 {
4aaf76
 	const char *policy;
4aaf76
@@ -501,5 +502,7 @@ int fill_vdo_target_params(struct cmd_context *cmd,
4aaf76
 	if (!set_vdo_write_policy(&vtp->write_policy, policy))
4aaf76
 		return_0;
4aaf76
 
4aaf76
+	*vdo_pool_header_size = 2 * find_config_tree_int64(cmd, allocation_vdo_pool_header_size_CFG, profile);
4aaf76
+
4aaf76
 	return 1;
4aaf76
 }
4aaf76
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
4aaf76
index 8488596..f87ee78 100644
4aaf76
--- a/tools/lvconvert.c
4aaf76
+++ b/tools/lvconvert.c
4aaf76
@@ -5439,6 +5439,7 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
4aaf76
 {
4aaf76
 	const char *vg_name = NULL;
4aaf76
 	unsigned int vdo_pool_zero;
4aaf76
+	uint64_t vdo_pool_header_size;
4aaf76
 	struct volume_group *vg = lv->vg;
4aaf76
 	struct logical_volume *vdo_lv;
4aaf76
 	struct dm_vdo_target_params vdo_params; /* vdo */
4aaf76
@@ -5481,7 +5482,7 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
4aaf76
 		goto out;
4aaf76
 	}
4aaf76
 
4aaf76
-	if (!fill_vdo_target_params(cmd, &vdo_params, vg->profile))
4aaf76
+	if (!fill_vdo_target_params(cmd, &vdo_params, &vdo_pool_header_size, vg->profile))
4aaf76
 		goto_out;
4aaf76
 
4aaf76
 	if (arg_is_set(cmd, compression_ARG))
4aaf76
@@ -5526,7 +5527,8 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
4aaf76
 	if (!archive(vg))
4aaf76
 		goto_out;
4aaf76
 
4aaf76
-	if (!convert_vdo_pool_lv(lv, &vdo_params, &lvc.virtual_extents, vdo_pool_zero))
4aaf76
+	if (!convert_vdo_pool_lv(lv, &vdo_params, &lvc.virtual_extents,
4aaf76
+				 vdo_pool_zero, vdo_pool_header_size))
4aaf76
 		goto_out;
4aaf76
 
4aaf76
 	dm_list_init(&lvc.tags);
4aaf76
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
4aaf76
index a28f093..0def236 100644
4aaf76
--- a/tools/lvcreate.c
4aaf76
+++ b/tools/lvcreate.c
4aaf76
@@ -1097,7 +1097,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
4aaf76
 
4aaf76
 		// FIXME: prefiling here - this is wrong place
4aaf76
 		// but will work for this moment
4aaf76
-		if (!fill_vdo_target_params(cmd, &lp->vdo_params, NULL))
4aaf76
+		if (!fill_vdo_target_params(cmd, &lp->vdo_params, &lp->vdo_pool_header_size, NULL))
4aaf76
 			return_0;
4aaf76
 
4aaf76
 		if (arg_is_set(cmd, compression_ARG))