lvm2/SOURCES/0086-dev_manager-accept-misalined-vdo-pools.patch
2023-11-14 20:01:16 +00:00

79 lines
3.1 KiB
Diff

From 13ce88a2b204e9b05206b624bbcca00446312ebb Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 26 Oct 2022 14:38:29 +0200
Subject: [PATCH 086/115] dev_manager: accept misalined vdo pools.
Since lvm2 may create VDO pool virtual size aligned only on extent size
while VDO itself is just 4K aligned - we need to support such misalign.
(cherry picked from commit 2e79b005c2013fb03d8a48a3cfd8e70a982dd65b)
---
lib/activate/dev_manager.c | 8 +++++---
lib/metadata/vdo_manip.c | 10 ++--------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 9058510e4..5b72bf772 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -263,7 +263,7 @@ static int _info_run(const char *dlid, struct dm_info *dminfo,
int dmtask;
int with_flush; /* TODO: arg for _info_run */
void *target = NULL;
- uint64_t target_start, target_length, start, length, length_crop = 0;
+ uint64_t target_start, target_length, start, extent_size, length, length_crop = 0;
char *target_name, *target_params;
const char *devname;
@@ -292,8 +292,8 @@ static int _info_run(const char *dlid, struct dm_info *dminfo,
/* Query status only for active device */
if (seg_status && dminfo->exists) {
- start = length = seg_status->seg->lv->vg->extent_size;
- start *= seg_status->seg->le;
+ extent_size = length = seg_status->seg->lv->vg->extent_size;
+ start = extent_size * seg_status->seg->le;
length *= _seg_len(seg_status->seg);
/* Uses max DM_THIN_MAX_METADATA_SIZE sectors for metadata device */
@@ -314,6 +314,8 @@ static int _info_run(const char *dlid, struct dm_info *dminfo,
if ((start == target_start) &&
((length == target_length) ||
+ ((lv_is_vdo_pool(seg_status->seg->lv)) && /* should fit within extent size */
+ (length < target_length) && ((length + extent_size) > target_length)) ||
(length_crop && (length_crop == target_length))))
break; /* Keep target_params when matching segment is found */
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index 0db401537..1cd2130a7 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -263,7 +263,6 @@ 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",
@@ -374,13 +373,8 @@ reformat:
// 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;
- reformating = 1;
- log_verbose("Reformating VDO to align virtual size %s by extent size.",
- display_size(data_lv->vg->cmd, *logical_size));
- goto reformat;
+ log_debug("Using bigger VDO virtual size unaligned on extent size by %s.",
+ display_size(data_lv->vg->cmd, *logical_size - logical_size_aligned));
}
}
--
2.41.0