Additional patches for 10.0.0 lvm2

Resolves: RHEL-77815
This commit is contained in:
Marian Csontos 2025-02-04 14:45:23 +01:00
parent c9ad936c7d
commit 02a3c6b57c
4 changed files with 146 additions and 0 deletions

View File

@ -0,0 +1,60 @@
From d1a433e2168f433f53058e5665c31ece061009af Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Tue, 28 Jan 2025 12:45:39 +0100
Subject: [PATCH 22/24] 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 4a511ac7689bbd0c95e17d9d4f4779cf34317531 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 23 Jan 2025 14:32:39 +0100
Subject: [PATCH 23/24] 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 c879775b03a0f92c900e66f73ddaad01bbb6a82a Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 30 Jan 2025 19:55:21 +0100
Subject: [PATCH 24/24] 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

@ -71,6 +71,10 @@ Patch19: 0019-WHATS_NEW-update.patch
# RHEL-75629: # RHEL-75629:
Patch20: 0020-memlock-check-for-proper-reserved-size.patch Patch20: 0020-memlock-check-for-proper-reserved-size.patch
Patch21: 0021-WHATS_NEW-update.patch Patch21: 0021-WHATS_NEW-update.patch
# RHEL-77815:
Patch22: 0022-vg_read-rescanning-DM-cache-after-taking-lock.patch
Patch23: 0023-vg_read-matching-missed-empty-cache.patch
Patch24: 0024-vg_read-correct-error-path-for-DM-cache-update.patch
BuildRequires: make BuildRequires: make
BuildRequires: gcc BuildRequires: gcc
@ -672,6 +676,9 @@ An extensive functional testsuite for LVM2.
%endif %endif
%changelog %changelog
* Tue Feb 04 2025 Marian Csontos <mcsontos@redhat.com> - 2.03.28-6
- Fix race causing lvm2 not recognizing active devices.
* Thu Jan 23 2025 Marian Csontos <mcsontos@redhat.com> - 2.03.28-5 * Thu Jan 23 2025 Marian Csontos <mcsontos@redhat.com> - 2.03.28-5
- Add libnvme dependency to really fix the NVMe issue. - Add libnvme dependency to really fix the NVMe issue.