Additional patches for 9.6.0 lvm2

Resolves: RHEL-76039
This commit is contained in:
Marian Csontos 2025-02-03 13:00:26 +01:00
parent 4857646a28
commit 250afac13f
4 changed files with 148 additions and 1 deletions

View File

@ -0,0 +1,60 @@
From 4587190f41855d8549dc41486c0ee8eb0bedd4e4 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Tue, 28 Jan 2025 12:45:39 +0100
Subject: [PATCH 28/30] vg_read: rescanning DM cache after taking lock
Since we started to use DM cache now also for basic checks
whether the DM devices is present in DM table, this cache
now needs to be actually refreshed when the LOCK is taken.
This hiddenly happend if there was enabled 'scan_lvs' however
still not at the right place.
Move this explicit cache update call right after the moment
vg_read grabs the lock.
TODO: in the optimal case, we should mark the 'cache invalid'
and later refresh this cache, when the first reader appears,
but since this would be large patch, do this little fix step patch
first and improve performance later.
(cherry picked from commit dd09127608be1b390cf028508d448442b6347551)
---
lib/device/dev-cache.c | 2 --
lib/metadata/metadata.c | 8 ++++++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 97d86a142..947995fb1 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1394,8 +1394,6 @@ void dm_devs_cache_label_invalidate(struct cmd_context *cmd)
struct dm_active_device *dm_dev;
struct device *dev;
- dm_devs_cache_update();
-
dm_list_iterate_items(dm_dev, _cache.dm_devs) {
if (dm_dev->uuid &&
strncmp(dm_dev->uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1) == 0) {
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 511ebd8ae..14f54db23 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -5031,6 +5031,14 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, const
goto_bad;
}
+ /* Update DM cache after grabbing lock
+ * TODO: do a lazy-update of this cache, only when it's really used */
+ if (dm_devs_cache_use()) {
+ log_debug_cache("Rescanning DM cache.");
+ if (!dm_devs_cache_update())
+ return_0;
+ }
+
/*
* vgchange -ay (no vgname arg) will activate multiple local VGs with the same
* name, but if the vgs have the same lv name, activating those lvs will fail.
--
2.48.1

View File

@ -0,0 +1,44 @@
From ce545519e0f5d3d8b50deb3accbeffe41ef55f1d Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 23 Jan 2025 14:32:39 +0100
Subject: [PATCH 29/30] vg_read: matching missed empty cache
lvm2 is caching DM nodes with the use of DM_LIST_DEVICES ioctl().
And tried to preserve the cached structure for the same list,
however there was 1 case where cache was empty, and new LIST ioctl
returned some elements - if this DM table change has happened
in the moment of 'scanning' and locking - lvm2 has then continued
to use 'invalid' empty cache.
Fix by capturing this missed case and update cache properly.
TODO: we could possibly use plain memcmp() with previous ioctl result.
(cherry picked from commit b32c0bb9c5474f39abffd9609ed486074ace6a2b)
---
lib/device/dev-cache.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 947995fb1..52f8804c4 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1314,7 +1314,7 @@ int dm_devs_cache_update(void)
unsigned devs_features;
uint32_t d;
struct dm_list *dm_devs_new, *l;
- int cache_changed = 0;
+ int cache_changed;
if (!get_dm_active_devices(NULL, &dm_devs_new, &devs_features))
return 1;
@@ -1329,6 +1329,7 @@ int dm_devs_cache_update(void)
/* Compare existing cached list with a new one.
* When there is any mismatch, just rebuild whole cache */
if ((l = dm_list_first(dm_devs_new))) {
+ cache_changed = dm_list_empty(_cache.dm_devs); // 1 for empty cache and new list has entries */
dm_list_iterate_items(dm_dev, _cache.dm_devs) {
dm_dev_new = dm_list_item(l, struct dm_active_device);
if ((dm_dev->devno != dm_dev_new->devno) ||
--
2.48.1

View File

@ -0,0 +1,35 @@
From 2b249a6ee51a79a5c28ffa591069158fd2c50e53 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 30 Jan 2025 19:55:21 +0100
Subject: [PATCH 30/30] vg_read: correct error path for DM cache update
New code for updating DM cache traveled through couple destination
however in this place only 'return_0' is missing unlocking in
error path.
(cherry picked from commit 46a48f1320c9d436286743461cd6e12d38ec45e0)
---
lib/metadata/metadata.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 14f54db23..b4da74247 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -5035,8 +5035,11 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, const
* TODO: do a lazy-update of this cache, only when it's really used */
if (dm_devs_cache_use()) {
log_debug_cache("Rescanning DM cache.");
- if (!dm_devs_cache_update())
- return_0;
+ if (!dm_devs_cache_update()) {
+ log_error("Can't allocate DM cache memory for VG %s.", vg_name);
+ failure |= FAILED_ALLOCATION;
+ goto bad;
+ }
}
/*
--
2.48.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: 5%{?dist}%{?rel_suffix} Release: 6%{?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
@ -79,6 +79,7 @@ Patch13: 0013-tests-check-vdo-minimum_io_size.patch
Patch14: 0014-raid-fix-name-rotation.patch Patch14: 0014-raid-fix-name-rotation.patch
Patch15: 0015-tests-check-_tdata-conversion-to-raid1.patch Patch15: 0015-tests-check-_tdata-conversion-to-raid1.patch
Patch16: 0016-WHATS_NEW-update.patch Patch16: 0016-WHATS_NEW-update.patch
# RHEL-68982:
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
@ -93,6 +94,10 @@ Patch25: 0025-WHATS_NEW-update.patch
# RHEL-60943: # RHEL-60943:
Patch26: 0026-memlock-check-for-proper-reserved-size.patch Patch26: 0026-memlock-check-for-proper-reserved-size.patch
Patch27: 0027-WHATS_NEW-update.patch Patch27: 0027-WHATS_NEW-update.patch
# RHEL-76039:
Patch28: 0028-vg_read-rescanning-DM-cache-after-taking-lock.patch
Patch29: 0029-vg_read-matching-missed-empty-cache.patch
Patch30: 0030-vg_read-correct-error-path-for-DM-cache-update.patch
BuildRequires: make BuildRequires: make
BuildRequires: gcc BuildRequires: gcc
@ -724,6 +729,9 @@ An extensive functional testsuite for LVM2.
%endif %endif
%changelog %changelog
* Mon Feb 03 2025 Marian Csontos <mcsontos@redhat.com> - 2.03.28-6
- Fix race causing lvm2 not recognizing active devices.
* Fri Jan 10 2025 Marian Csontos <mcsontos@redhat.com> - 2.03.28-5 * 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. - Fix temporary LVs not cleaned when converting in use LV to a thin pool.
- Check FS resize is supported before extending LV. - Check FS resize is supported before extending LV.