Additional patches for 9.6.0 lvm2

Resolves: RHEL-53866 RHEL-65845 RHEL-60943
This commit is contained in:
Marian Csontos 2025-01-09 17:56:51 +01:00
parent 3201fed437
commit 4857646a28
9 changed files with 475 additions and 1 deletions

View File

@ -0,0 +1,52 @@
From 4627ca20dc6314aa382aa21e22aacd32a81a50a2 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 19 Dec 2024 14:47:16 +0100
Subject: [PATCH 20/27] thin: deactivate converted volume early
Deactivate converted volume to pool early, so the conversion
exits early and does not leave some already created metadata
volumes that needed manual cleanup by user after command
aborted its conversion operation when the converted volume
was actually in-use (i.e. when user tried to convert
a mounted LV into a thin-pool, 2 extra volumes needed removal).
(cherry picked from commit 6326d0093730fe945eeb4748738ddda55bf8a3c9)
---
tools/lvconvert.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 8dd8eea1b..d15e01fd7 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3154,6 +3154,13 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
activate_pool = to_thinpool && is_active;
+ /* Before the conversion starts, make sure the volume is unused and can be deactivated
+ * (as it needs to change target type) */
+ if (is_active && !to_thin && !deactivate_lv(cmd, lv)) {
+ log_error("Cannot convert logical volume %s.", display_lvname(lv));
+ return 0;
+ }
+
/* Wipe metadata_lv by default, but allow skipping this for cache pools. */
zero_metadata = (to_cachepool) ? arg_int_value(cmd, zero_ARG, 1) : 1;
@@ -3405,13 +3412,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
if (!(pool_lv = _lvconvert_insert_thin_layer(lv)))
goto_bad;
} else {
- /* Deactivate the data LV (changing target type) */
- if (!deactivate_lv(cmd, lv)) {
- log_error("Aborting. Failed to deactivate logical volume %s.",
- display_lvname(lv));
- goto bad;
- }
-
if (data_vdo) {
if (lv_is_vdo(lv)) {
if ((seg = first_seg(lv)))
--
2.47.1

View File

@ -0,0 +1,51 @@
From 41aaea4349ff2ef9b80de285e72ba7b94adfcf1a Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 19 Dec 2024 14:50:32 +0100
Subject: [PATCH 21/27] tests: check conversion of in-use volume
Thin-pool conversion fails early when trying to convert
volume which is in use (simulated by sleep <)
(cherry picked from commit 3e641578d80bc7a28bcb451115b06da87d232b3a)
---
test/shell/lvconvert-thin-vdo.sh | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/test/shell/lvconvert-thin-vdo.sh b/test/shell/lvconvert-thin-vdo.sh
index d61126276..5b4fe9d97 100644
--- a/test/shell/lvconvert-thin-vdo.sh
+++ b/test/shell/lvconvert-thin-vdo.sh
@@ -34,11 +34,29 @@ which mkfs.ext4 || skip
aux prepare_vg 4 6400
-# convert to thin-pool with VDO backend from existing VG/LV
+# Convert to thin-pool with VDO backend from existing VG/LV
lvcreate -L5G --name $lv1 $vg
+
+# Keep volume in use for 6 seconds
+# - lvm retries for ~5sec to deactivate
+sleep 6 < "$DM_DEV_DIR/$vg/$lv1" &
+
+# Volume in use cannot be converted
+fail lvconvert -y --type thin-pool $vg/$lv1 --pooldatavdo y
+
+# Wait for sleep to not use LV anymore
+wait
+
+# No extra volume should appear in VG after failure
+test "$(get vg_field $vg lv_count)" -eq "1"
+
mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
# Conversion caught present filesystem and should fail
fail lvconvert -Wy --type thin-pool -c 256K --deduplication n --pooldatavdo y $vg/$lv1
+
+# No extra volume should appear in VG after failure
+test "$(get vg_field $vg lv_count)" -eq "1"
+
# With --yes it should work over prompt
lvconvert --yes -Wy --type thin-pool -c 256K --deduplication n --pooldatavdo y $vg/$lv1
--
2.47.1

View File

@ -0,0 +1,25 @@
From 93aed329721d82d3110014f3f3b1b2803a60f50c Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 19 Dec 2024 14:57:43 +0100
Subject: [PATCH 22/27] WHATS_NEW: update
(cherry picked from commit 5ef958704c82c45a6bd8215d920e4366c0c5e1bd)
---
WHATS_NEW | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index bea47f154..e63dfc393 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,7 @@
+Version 2.03.30 -
+==================
+ lvconvert detects early volume in use when converting it to a pool.
+
Version 2.03.29 -
==================
Fix renaming of raid sub LVs when converting a volume to raid (2.03.28).
--
2.47.1

View File

@ -0,0 +1,176 @@
From 9d9c8b8676b4fe21a0ff69e4c5d9e4a4a861f76e Mon Sep 17 00:00:00 2001
From: Peter Rajnoha <prajnoha@redhat.com>
Date: Fri, 3 Jan 2025 10:52:47 +0100
Subject: [PATCH 23/27] lv_manip: check fs resize is supported before LV
extension
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This avoids a situation where we would extend an LV and then we would
not do anything to the FS on it because the FS info check failed for some
reason, like the type was not supported (e.g. swap) or we could not resize
the FS unless being in some supported state (e.g. XFS to be mounted for
the xfs_growfs to work).
Before this patch (LV resized, FS not resized):
lvextend --fs resize -L+4M vg/swap
Size of logical volume vg/swap changed from 32.00 MiB (8 extents) to 36.00 MiB (9 extents).
File system extend is not supported (swap).
File system extend error.
Logical volume vg/swap successfully resized.
With this patch (LV not resized, FS not resized):
lvextend --fs resize -L+4M vg/swap
File system extend is not supported (swap).
(cherry picked from commit 5f53ecda3600834e920eef14065d35cd0fb6c59b)
---
lib/metadata/lv_manip.c | 71 +++++++++++++++++++++--------------------
1 file changed, 36 insertions(+), 35 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 15a7f3c9a..dab160234 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6550,23 +6550,18 @@ static int _fs_reduce(struct cmd_context *cmd, struct logical_volume *lv,
return ret;
}
-static int _fs_extend(struct cmd_context *cmd, struct logical_volume *lv,
- struct lvresize_params *lp)
+static int _fs_extend_check_fsinfo(struct cmd_context *cmd, struct logical_volume *lv, struct lvresize_params *lp,
+ struct fs_info *fsinfo, uint64_t *newsize_bytes_fs)
{
- struct fs_info fsinfo;
uint64_t newsize_bytes_lv;
- uint64_t newsize_bytes_fs;
- int ret = 0;
- memset(&fsinfo, 0, sizeof(fsinfo));
+ memset(fsinfo, 0, sizeof(*fsinfo));
- if (!fs_get_info(cmd, lv, &fsinfo, 1))
- goto_out;
+ if (!fs_get_info(cmd, lv, fsinfo, 1))
+ return 0;
- if (fsinfo.nofs) {
- ret = 1;
- goto_out;
- }
+ if (fsinfo->nofs)
+ return 1;
/*
* Note: here in the case of extend, newsize_bytes_lv/newsize_bytes_fs
@@ -6577,40 +6572,43 @@ static int _fs_extend(struct cmd_context *cmd, struct logical_volume *lv,
/* extent_size units is SECTOR_SIZE (512) */
newsize_bytes_lv = (uint64_t) lp->extents * lv->vg->extent_size * SECTOR_SIZE;
- newsize_bytes_fs = newsize_bytes_lv;
- if (fsinfo.needs_crypt) {
- newsize_bytes_fs -= fsinfo.crypt_offset_bytes;
+ *newsize_bytes_fs = newsize_bytes_lv;
+ if (fsinfo->needs_crypt) {
+ *newsize_bytes_fs -= fsinfo->crypt_offset_bytes;
log_print_unless_silent("File system size %llub is adjusted for crypt data offset %ub.",
- (unsigned long long)newsize_bytes_fs, fsinfo.crypt_offset_bytes);
+ (unsigned long long)*newsize_bytes_fs, fsinfo->crypt_offset_bytes);
}
/*
* Decide if fs should be extended based on the --fs option,
* the fs type and the mount state.
*/
- if (!_fs_extend_allow(cmd, lv, lp, &fsinfo))
- goto_out;
+ if (!_fs_extend_allow(cmd, lv, lp, fsinfo))
+ return 0;
+
+ return 1;
+}
+static int _fs_extend(struct cmd_context *cmd, struct logical_volume *lv,
+ struct lvresize_params *lp, struct fs_info *fsinfo, uint64_t newsize_bytes_fs)
+{
/*
* fs extend is not needed
*/
- if (!fsinfo.needs_extend) {
- ret = 1;
- goto_out;
- }
+ if (!fsinfo->needs_extend)
+ return 1;
if (test_mode()) {
- if (fsinfo.needs_unmount)
+ if (fsinfo->needs_unmount)
log_print_unless_silent("Skip unmount in test mode.");
- if (fsinfo.needs_fsck)
+ if (fsinfo->needs_fsck)
log_print_unless_silent("Skip fsck in test mode.");
- if (fsinfo.needs_mount)
+ if (fsinfo->needs_mount)
log_print_unless_silent("Skip mount in test mode.");
- if (fsinfo.needs_crypt)
+ if (fsinfo->needs_crypt)
log_print_unless_silent("Skip cryptsetup in test mode.");
log_print_unless_silent("Skip fs extend in test mode.");
- ret = 1;
- goto out;
+ return 1;
}
/*
@@ -6621,12 +6619,7 @@ static int _fs_extend(struct cmd_context *cmd, struct logical_volume *lv,
*/
unlock_vg(cmd, lv->vg, lv->vg->name);
- if (!fs_extend_script(cmd, lv, &fsinfo, newsize_bytes_fs, lp->fsmode))
- goto_out;
-
- ret = 1;
- out:
- return ret;
+ return fs_extend_script(cmd, lv, fsinfo, newsize_bytes_fs, lp->fsmode);
}
int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
@@ -6640,6 +6633,8 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
struct logical_volume *lv_meta = NULL;
struct logical_volume *lv_main_layer = NULL;
struct logical_volume *lv_meta_layer = NULL;
+ struct fs_info fsinfo;
+ uint64_t newsize_bytes_fs;
int main_size_matches = 0;
int meta_size_matches = 0;
int is_extend = (lp->resize == LV_EXTEND);
@@ -7100,6 +7095,12 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
if (!lv_main)
goto end_main;
+
+ if (is_extend && lp->fsopt[0] && strcmp(lp->fsopt, "resize_fsadm")) {
+ if (!_fs_extend_check_fsinfo(cmd, lv_top, lp, &fsinfo, &newsize_bytes_fs))
+ goto_out;
+ }
+
if (!_lv_resize_volume(lv_main, lp, lp->pvh))
goto_out;
if (!lp->size_changed) {
@@ -7145,7 +7146,7 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
}
} else {
/* New approach to fs handling using fs info. */
- if (!_fs_extend(cmd, lv_top, lp)) {
+ if (!_fs_extend(cmd, lv_top, lp, &fsinfo, newsize_bytes_fs)) {
log_error("File system extend error.");
lp->extend_fs_error = 1;
goto out;
--
2.47.1

View File

@ -0,0 +1,65 @@
From 97713c89cfa6d13488ecffa4eb66457619aa294a Mon Sep 17 00:00:00 2001
From: Peter Rajnoha <prajnoha@redhat.com>
Date: Fri, 3 Jan 2025 15:26:27 +0100
Subject: [PATCH 24/27] tests: adjust lvresize-xfs tests for recent lvextend
changes
Because now, we are doing the fsinfo check before extending an LV and if
that check fails, we do not proceed to the LV extension itself and the
lvextend command bails out immediatelly.
(cherry picked from commit e86a75b4fe5873f563c930a575f54143ddca7c7c)
---
test/shell/lvresize-xfs.sh | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/test/shell/lvresize-xfs.sh b/test/shell/lvresize-xfs.sh
index 87fbf6f9d..17bc6fba3 100644
--- a/test/shell/lvresize-xfs.sh
+++ b/test/shell/lvresize-xfs.sh
@@ -104,13 +104,12 @@ lvremove -f $vg/$lv
####################
# lvextend, xfs, active, mounted, --fs resize --fsmode offline
-lvcreate -n $lv -L 300M $vg
+lvcreate -n $lv -L 320M $vg
mkfs.xfs "$DM_DEV_DIR/$vg/$lv"
mount "$DM_DEV_DIR/$vg/$lv" "$mount_dir_space"
df --output=size "$mount_dir_space" |tee df1
dd if=/dev/zero of="$mount_dir_space/zeros1" bs=1M count=20 oflag=direct
-# xfs_growfs requires the fs to be mounted, so extending the lv is
-# succeeds, then the xfs extend fails because it cannot be done unmounted
+# xfs_growfs requires the fs to be mounted, so the lvextend fails here
not lvextend --fs resize --fsmode offline -L+20M $vg/$lv
check lv_field $vg/$lv lv_size "320.00m"
df | tee dfa
@@ -136,7 +135,7 @@ umount "$mount_dir_space"
# xfs_growfs requires the fs to be mounted to grow, so --fsmode nochange
# with an unmounted fs fails
not lvextend --fs resize --fsmode nochange -L+20M $vg/$lv
-check lv_field $vg/$lv lv_size "380.00m"
+check lv_field $vg/$lv lv_size "360.00m"
mount "$DM_DEV_DIR/$vg/$lv" "$mount_dir_space"
df --output=size "$mount_dir_space" |tee df4
# fs not extended so fs size not changed
@@ -147,7 +146,7 @@ umount "$mount_dir_space"
# --yes needed because mount changes are required and plain "resize"
# fsopt did not specify if the user wants to change mount state
lvextend --yes --fs resize -L+10M $vg/$lv
-check lv_field $vg/$lv lv_size "390.00m"
+check lv_field $vg/$lv lv_size "370.00m"
mount "$DM_DEV_DIR/$vg/$lv" "$mount_dir_space"
df --output=size "$mount_dir_space" |tee df5
not diff df4 df5
@@ -155,7 +154,7 @@ umount "$mount_dir_space"
# lvextend, xfs, active, unmounted, --fs resize_fsadm
lvextend --fs resize_fsadm -L+10M $vg/$lv
-check lv_field $vg/$lv lv_size "400.00m"
+check lv_field $vg/$lv lv_size "380.00m"
mount "$DM_DEV_DIR/$vg/$lv" "$mount_dir_space"
df --output=size "$mount_dir_space" |tee df6
not diff df5 df6
--
2.47.1

View File

@ -0,0 +1,24 @@
From 7027d3897aba329a735998e3022482a1b7447ec1 Mon Sep 17 00:00:00 2001
From: Peter Rajnoha <prajnoha@redhat.com>
Date: Mon, 6 Jan 2025 15:35:44 +0100
Subject: [PATCH 25/27] WHATS_NEW: update
(cherry picked from commit 1576273273b84bc8d3d330f113ffb1ac67f2c0a2)
---
WHATS_NEW | 1 +
1 file changed, 1 insertion(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index e63dfc393..40c6c2cd0 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.30 -
==================
+ Do not extend an LV if FS resize unsupported and '--fs resize' used.
lvconvert detects early volume in use when converting it to a pool.
Version 2.03.29 -
--
2.47.1

View File

@ -0,0 +1,42 @@
From f3eb858a302ec27801ee8bbe90030c0c2f8cc3fe Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 8 Jan 2025 17:48:53 +0100
Subject: [PATCH 26/27] memlock: check for proper reserved size
Fix regression introduced with commit:
964012fdb924076e9ab97fabe00e759ddbf7c3bd
that effectively disabled memory locking before suspending volumes.
From merging/testing there remained wrong condition
as we really want to check for 0 memory reservation value
for both checked settings.
(cherry picked from commit 4ef211a187dac348fa1857d577f5c17c9dace190)
---
lib/mm/memlock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index e28044df6..e7b0b4f7a 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -517,7 +517,7 @@ static void _restore_priority_if_possible(struct cmd_context *cmd)
/* Stop memory getting swapped out */
static void _lock_mem(struct cmd_context *cmd)
{
- if (!_size_stack || _size_malloc_tmp) {
+ if (!_size_stack || !_size_malloc_tmp) {
log_debug_mem("Skipping memory locking (reserved memory: "
FMTsize_t " stack: " FMTsize_t ").",
_size_malloc_tmp, _size_stack);
@@ -564,7 +564,7 @@ static void _unlock_mem(struct cmd_context *cmd)
{
size_t unlock_mstats = 0;
- if (!_size_stack || _size_malloc_tmp) {
+ if (!_size_stack || !_size_malloc_tmp) {
log_debug_mem("Skipping memory unlocking (reserved memory: "
FMTsize_t " stack: " FMTsize_t ").",
_size_malloc_tmp, _size_stack);
--
2.47.1

View File

@ -0,0 +1,23 @@
From a468c4028a2a996e5651feaf728d4c126698d478 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Thu, 9 Jan 2025 15:59:48 +0100
Subject: [PATCH 27/27] WHATS_NEW: update
---
WHATS_NEW | 1 +
1 file changed, 1 insertion(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index 40c6c2cd0..07493831f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.30 -
==================
+ Fix support for disabling memory locking (2.03.27).
Do not extend an LV if FS resize unsupported and '--fs resize' used.
lvconvert detects early volume in use when converting it to a pool.
--
2.47.1

View File

@ -54,7 +54,7 @@ Version: 2.03.28
%if 0%{?from_snapshot} %if 0%{?from_snapshot}
Release: 0.1.20211115git%{shortcommit}%{?dist}%{?rel_suffix} Release: 0.1.20211115git%{shortcommit}%{?dist}%{?rel_suffix}
%else %else
Release: 4%{?dist}%{?rel_suffix} Release: 5%{?dist}%{?rel_suffix}
%endif %endif
License: GPL-2.0-only License: GPL-2.0-only
URL: https://sourceware.org/lvm2 URL: https://sourceware.org/lvm2
@ -82,6 +82,17 @@ Patch16: 0016-WHATS_NEW-update.patch
Patch17: 0017-device_id-nvme-devices-may-use-alternate-wwids.patch Patch17: 0017-device_id-nvme-devices-may-use-alternate-wwids.patch
Patch18: 0018-configure.ac-add-support-for-libnvme.patch Patch18: 0018-configure.ac-add-support-for-libnvme.patch
Patch19: 0019-configure-autoreconf.patch Patch19: 0019-configure-autoreconf.patch
# RHEL-53866:
Patch20: 0020-thin-deactivate-converted-volume-early.patch
Patch21: 0021-tests-check-conversion-of-in-use-volume.patch
Patch22: 0022-WHATS_NEW-update.patch
# RHEL-65845:
Patch23: 0023-lv_manip-check-fs-resize-is-supported-before-LV-exte.patch
Patch24: 0024-tests-adjust-lvresize-xfs-tests-for-recent-lvextend-.patch
Patch25: 0025-WHATS_NEW-update.patch
# RHEL-60943:
Patch26: 0026-memlock-check-for-proper-reserved-size.patch
Patch27: 0027-WHATS_NEW-update.patch
BuildRequires: make BuildRequires: make
BuildRequires: gcc BuildRequires: gcc
@ -713,6 +724,11 @@ An extensive functional testsuite for LVM2.
%endif %endif
%changelog %changelog
* Fri Jan 10 2025 Marian Csontos <mcsontos@redhat.com> - 2.03.28-5
- Fix temporary LVs not cleaned when converting in use LV to a thin pool.
- Check FS resize is supported before extending LV.
- Fix issue affecting memory locking before suspend (2.03.27).
* Tue Dec 17 2024 Marian Csontos <mcsontos@redhat.com> - 2.03.28-4 * Tue Dec 17 2024 Marian Csontos <mcsontos@redhat.com> - 2.03.28-4
- Workaround for NVMe WWID changing after kernel update. - Workaround for NVMe WWID changing after kernel update.