80 lines
2.6 KiB
Diff
80 lines
2.6 KiB
Diff
|
From d2a2720ccb88d99c76423ebd5c3bb1f13dc60ab1 Mon Sep 17 00:00:00 2001
|
||
|
From: Zdenek Kabelac <zkabelac@redhat.com>
|
||
|
Date: Sat, 9 Jul 2022 00:42:01 +0200
|
||
|
Subject: [PATCH 077/115] vdo: add reformating to extent size aligned virtual
|
||
|
size
|
||
|
|
||
|
Newer VDO kernel target require to have matching virtual size - this
|
||
|
however cause incompatiblity when lvcreate is let to format VDO data
|
||
|
device and read the usable size from vdoformat.
|
||
|
Altough this is a kernel regression and will likely get fixed,
|
||
|
lvm2 can actually reformat VDO device to use properly aligned VDO LV
|
||
|
size to make this problem disappear.
|
||
|
|
||
|
(cherry picked from commit a477490e812639fed3be495f215fcf1a7b65b7ee)
|
||
|
---
|
||
|
lib/metadata/vdo_manip.c | 22 +++++++++++++++++++---
|
||
|
1 file changed, 19 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
|
||
|
index 9f449ef8b..f3a4a9534 100644
|
||
|
--- a/lib/metadata/vdo_manip.c
|
||
|
+++ b/lib/metadata/vdo_manip.c
|
||
|
@@ -227,10 +227,11 @@ static int _format_vdo_pool_data_lv(struct logical_volume *data_lv,
|
||
|
const struct dm_vdo_target_params *vtp,
|
||
|
uint64_t *logical_size)
|
||
|
{
|
||
|
- char *dpath;
|
||
|
+ char *dpath, *c;
|
||
|
const struct dm_config_node *cn;
|
||
|
const struct dm_config_value *cv;
|
||
|
struct pipe_data pdata;
|
||
|
+ uint64_t logical_size_aligned = 1;
|
||
|
FILE *f;
|
||
|
uint64_t lb;
|
||
|
unsigned slabbits;
|
||
|
@@ -247,7 +248,9 @@ static int _format_vdo_pool_data_lv(struct logical_volume *data_lv,
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
+reformat:
|
||
|
if (*logical_size) {
|
||
|
+ logical_size_aligned = 0;
|
||
|
if (dm_snprintf(buf_args[args], sizeof(buf_args[0]), "--logical-size=" FMTu64 "K",
|
||
|
(*logical_size / 2)) < 0)
|
||
|
return_0;
|
||
|
@@ -332,8 +335,8 @@ static int _format_vdo_pool_data_lv(struct logical_volume *data_lv,
|
||
|
log_verbose("Available VDO logical blocks " FMTu64 " (%s).",
|
||
|
lb, display_size(data_lv->vg->cmd, *logical_size));
|
||
|
}
|
||
|
- if ((dpath = strchr(buf, '\n')))
|
||
|
- *dpath = 0; /* cut last '\n' away */
|
||
|
+ if ((c = strchr(buf, '\n')))
|
||
|
+ *c = 0; /* cut last '\n' away */
|
||
|
if (buf[0])
|
||
|
log_print(" %s", buf); /* Print vdo_format messages */
|
||
|
}
|
||
|
@@ -348,6 +351,19 @@ static int _format_vdo_pool_data_lv(struct logical_volume *data_lv,
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
+ if (logical_size_aligned) {
|
||
|
+ // align obtained size to extent size
|
||
|
+ logical_size_aligned = *logical_size / data_lv->vg->extent_size * data_lv->vg->extent_size;
|
||
|
+ if (*logical_size != logical_size_aligned) {
|
||
|
+ *logical_size = logical_size_aligned;
|
||
|
+ argv[1] = (char*) "--force";
|
||
|
+ args = 2;
|
||
|
+ log_verbose("Reformating VDO to align virtual size %s by extent size.",
|
||
|
+ display_size(data_lv->vg->cmd, *logical_size));
|
||
|
+ goto reformat;
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
--
|
||
|
2.41.0
|
||
|
|