Additional patches for 9.3.0 lvm2

Resolves: #2188718 #2191683 #2179430
This commit is contained in:
Marian Csontos 2023-05-24 19:31:50 +02:00
parent bdbd4e7363
commit bbbc6d1c14
7 changed files with 331 additions and 1 deletions

View File

@ -0,0 +1,26 @@
From 1835574e39e9417b3800469fe80ce47d2210b9a7 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Sun, 23 Apr 2023 12:49:37 +0200
Subject: [PATCH 3/8] lvmdbus: preserve PATH envvar
(cherry picked from commit afc02ae6e7234e1190cedf5c74ca3d6367efd7d1)
---
daemons/lvmdbusd/lvm_shell_proxy.py.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in
index b8c8fa565..02a776e1d 100755
--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in
+++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in
@@ -154,6 +154,8 @@ class LVMShellProxy(object):
# If any env variables contain LVM we will propagate them too
for k, v in os.environ.items():
+ if "PATH" in k:
+ local_env[k] = v
if "LVM" in k:
local_env[k] = v
--
2.40.1

View File

@ -0,0 +1,43 @@
From 80b73e2901d470fd3d1f45664626980167091f02 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 25 Apr 2023 14:46:36 -0500
Subject: [PATCH 4/8] lvmcache: fix valgrind error when dropping md duplicate
When lvmcache info is dropped because it's an md component,
then the lvmcache vginfo can also be dropped, but the list
iterator was still using the list head in vginfo, so break
from the loop earlier to avoid it.
(cherry picked from commit 6d262eaf640dead7861c1a7716e216b9bcea75e5)
---
lib/cache/lvmcache.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index b8a9eac25..127d29229 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1503,6 +1503,9 @@ void lvmcache_extra_md_component_checks(struct cmd_context *cmd)
*/
dm_list_iterate_items_safe(vginfo, vginfo2, &_vginfos) {
+ char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ memcpy(vgid, vginfo->vgid, ID_LEN);
+
dm_list_iterate_items_safe(info, info2, &vginfo->infos) {
dev = info->dev;
device_hint = _get_pvsummary_device_hint(dev->pvid);
@@ -1557,6 +1560,10 @@ void lvmcache_extra_md_component_checks(struct cmd_context *cmd)
/* lvmcache_del will also delete vginfo if info was last one */
lvmcache_del(info);
cmd->filter->wipe(cmd, cmd->filter, dev, NULL);
+
+ /* If vginfo was deleted don't continue using vginfo->infos */
+ if (!_search_vginfos_list(NULL, vgid))
+ break;
}
}
}
--
2.40.1

View File

@ -0,0 +1,31 @@
From 0a9228807d0b3901be4ccf29311a955efba4877e Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Fri, 28 Apr 2023 13:31:39 -0500
Subject: [PATCH 5/8] pvck: improve error for write to existing file
(cherry picked from commit c4440b5b495a2d11ff541dd7e7791e2a83c83609)
---
tools/pvck.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/pvck.c b/tools/pvck.c
index 879810b76..0998caaf5 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -1444,8 +1444,13 @@ static int _dump_metadata(struct cmd_context *cmd, const char *dump, struct sett
int bad = 0;
if (arg_is_set(cmd, file_ARG)) {
+ struct stat sb;
if (!(tofile = arg_str_value(cmd, file_ARG, NULL)))
return 0;
+ if (!stat(tofile, &sb)) {
+ log_error("File already exists.");
+ return 0;
+ }
}
if (set->mda_num)
--
2.40.1

View File

@ -0,0 +1,87 @@
From 7702262444a5af924d0fc94ff956663aab3505df Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 2 May 2023 16:12:23 -0500
Subject: [PATCH 6/8] lvreduce: make _lvseg_get_stripes handle integrity layer
lvreduce uses _lvseg_get_stripes() which was unable to get raid stripe
info with an integrity layer present. This caused lvreduce on a
raid+integrity LV to fail prematurely when checking stripe parameters.
An unhelpful error message about stripe size would be printed.
(cherry picked from commit 368381fd4022dc99ffe551b30ed75c3ddbc5c5c8)
---
lib/metadata/lv_manip.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 2a4e0e88a..add9512ff 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5144,22 +5144,39 @@ int lv_extend_policy_calculate_percent(struct logical_volume *lv,
static uint32_t _lvseg_get_stripes(struct lv_segment *seg, uint32_t *stripesize)
{
- uint32_t s;
- struct lv_segment *seg_mirr;
+ uint32_t s, a;
+ struct lv_segment *seg_get, *seg_image, *seg_iorig;
+ struct logical_volume *lv_image, *lv_iorig;
/* If segment mirrored, check if images are striped */
- if (seg_is_mirrored(seg))
+ if (seg_is_mirrored(seg)) {
for (s = 0; s < seg->area_count; s++) {
if (seg_type(seg, s) != AREA_LV)
continue;
- seg_mirr = first_seg(seg_lv(seg, s));
- if (seg_is_striped(seg_mirr)) {
- seg = seg_mirr;
+ lv_image = seg_lv(seg, s);
+ seg_image = first_seg(lv_image);
+ seg_get = NULL;
+
+ if (seg_is_integrity(seg_image)) {
+ /* Get stripe values from the iorig layer. */
+ for (a = 0; a < seg_image->area_count; a++) {
+ lv_iorig = seg_lv(seg_image, a);
+ seg_iorig = first_seg(lv_iorig);
+ seg_get = seg_iorig;
+ break;
+ }
+ } else {
+ /* Get stripe values from the image layer. */
+ seg_get = seg_image;
+ }
+
+ if (seg_get && seg_is_striped(seg_get)) {
+ seg = seg_get;
break;
}
}
-
+ }
if (seg_is_striped(seg)) {
*stripesize = seg->stripe_size;
@@ -5168,7 +5185,7 @@ static uint32_t _lvseg_get_stripes(struct lv_segment *seg, uint32_t *stripesize)
if (seg_is_raid(seg)) {
*stripesize = seg->stripe_size;
- return _raid_stripes_count(seg);
+ return _raid_stripes_count(seg);
}
*stripesize = 0;
@@ -5593,7 +5610,7 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
seg_size /= seg_mirrors;
lp->extents = logical_extents_used + seg_size;
break;
- }
+ }
} else if (new_extents <= logical_extents_used + seg_logical_extents) {
seg_size = new_extents - logical_extents_used;
lp->extents = new_extents;
--
2.40.1

View File

@ -0,0 +1,96 @@
From 50bd94ca38177c18e6d761d012c56227591df68c Mon Sep 17 00:00:00 2001
From: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue, 16 May 2023 17:17:55 +0200
Subject: [PATCH 7/8] toollib: provide proper hint for referencing VG uuid in
case of duplicate VG names
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
vgrename does not support -S|--select, so do not provide a hint about
using it. Instead, provide a hint about using VG uuid directly.
vgs
WARNING: VG name vg1 is used by VGs DXjcSK-gWfu-5gLh-9Kbg-sG49-dtRr-GqXzGL and MVMfyM-sjOa-M2xV-AT4Y-JddR-h4SP-UO5Ttk.
Fix duplicate VG names with vgrename uuid, a device filter, or system IDs.
VG #PV #LV #SN Attr VSize VFree
vg1 1 0 0 wz--n- 124.00m 124.00m
vg1 1 0 0 wz--n- 124.00m 124.00m
(vgrename does not support -S|--select)
vgrename vg1 vg2
WARNING: VG name vg1 is used by VGs DXjcSK-gWfu-5gLh-9Kbg-sG49-dtRr-GqXzGL and MVMfyM-sjOa-M2xV-AT4Y-JddR-h4SP-UO5Ttk.
Fix duplicate VG names with vgrename uuid, a device filter, or system IDs.
Multiple VGs found with the same name: skipping vg1
Use VG uuid in place of the VG name.
(vgchange does support -S|--select)
vgchange --addtag a vg1
WARNING: VG name vg1 is used by VGs DXjcSK-gWfu-5gLh-9Kbg-sG49-dtRr-GqXzGL and MVMfyM-sjOa-M2xV-AT4Y-JddR-h4SP-UO5Ttk.
Fix duplicate VG names with vgrename uuid, a device filter, or system IDs.
Multiple VGs found with the same name: skipping vg1
Use --select vg_uuid=<uuid> in place of the VG name.
(cherry picked from commit 3b4e7d1625ddc48dd9393f03a59cc6b74113275a)
---
tools/lvmcmdline.c | 12 ++++++++++++
tools/toollib.c | 7 ++++++-
tools/tools.h | 1 +
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index a5bb6a5c5..6bbf1af26 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -179,6 +179,18 @@ static const struct command_function _command_functions[CMD_COUNT] = {
/* Command line args */
+int arg_is_valid_for_command(const struct cmd_context *cmd, int a)
+{
+ int i;
+
+ for (i = 0; i < cmd->cname->num_args; i++) {
+ if (cmd->cname->valid_args[i] == a)
+ return 1;
+ }
+
+ return 0;
+}
+
unsigned arg_count(const struct cmd_context *cmd, int a)
{
return cmd->opt_arg_values ? cmd->opt_arg_values[a].count : 0;
diff --git a/tools/toollib.c b/tools/toollib.c
index 43e628abf..e5ed8a857 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2313,7 +2313,12 @@ static int _resolve_duplicate_vgnames(struct cmd_context *cmd,
* is unknown.
*/
log_error("Multiple VGs found with the same name: skipping %s", sl->str);
- log_error("Use --select vg_uuid=<uuid> in place of the VG name.");
+
+ if (arg_is_valid_for_command(cmd, select_ARG))
+ log_error("Use --select vg_uuid=<uuid> in place of the VG name.");
+ else
+ log_error("Use VG uuid in place of the VG name.");
+
dm_list_del(&sl->list);
ret = ECMD_FAILED;
}
diff --git a/tools/tools.h b/tools/tools.h
index 36da3bc7e..60952a2aa 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -193,6 +193,7 @@ int repairtype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_v
int dumptype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
/* we use the enums to access the switches */
+int arg_is_valid_for_command(const struct cmd_context *cmd, int a);
unsigned arg_count(const struct cmd_context *cmd, int a);
unsigned arg_is_set(const struct cmd_context *cmd, int a);
int arg_from_list_is_set(const struct cmd_context *cmd, const char *err_found, ...);
--
2.40.1

View File

@ -0,0 +1,37 @@
From 41d16e42f88997fda991f86d598bffc19fcd937f Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 17 May 2023 11:10:45 -0500
Subject: [PATCH 8/8] tests: integrity: snapshots now work on raid+integrity
(cherry picked from commit 3a757047560d75a28d7e4c7d9a5253a72d786544)
---
test/shell/integrity.sh | 8 --------
1 file changed, 8 deletions(-)
diff --git a/test/shell/integrity.sh b/test/shell/integrity.sh
index a7dd5b565..d1683a08e 100644
--- a/test/shell/integrity.sh
+++ b/test/shell/integrity.sh
@@ -626,7 +626,6 @@ not lvconvert --splitmirrors 1 -n tmp -y $vg/$lv1
not lvconvert --splitmirrors 1 --trackchanges -y $vg/$lv1
not lvchange --syncaction repair $vg/$lv1
not lvreduce -L4M $vg/$lv1
-not lvcreate -s -n snap -L4M $vg/$lv1
not pvmove -n $vg/$lv1 "$dev1"
not pvmove "$dev1"
_verify_data_on_mnt
@@ -810,11 +809,4 @@ not lvconvert --raidintegrity y $vg/${lv2}_cpool_cdata
not lvconvert --raidintegrity y $vg/${lv2}_cpool_cmeta
lvremove -y $vg/$lv1
-# cannot add integrity to raid that has a snapshot
-
-lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
-lvcreate -s -n $lv2 -l 8 $vg/$lv1
-not lvconvert --raidintegrity y $vg/$lv1
-lvremove -y $vg/$lv1
-
vgremove -ff $vg
--
2.40.1

View File

@ -66,6 +66,16 @@ Source0: ftp://sourceware.org/pub/lvm2/releases/LVM2.%{version}.tgz
# BZ 2179430:
Patch1: 0001-fix-dev_name-use-in-add_areas_line.patch
Patch2: 0002-raidintegrity-allow-snapshots.patch
Patch3: 0003-lvmdbus-preserve-PATH-envvar.patch
Patch4: 0004-lvmcache-fix-valgrind-error-when-dropping-md-duplica.patch
# BZ 2188718
Patch5: 0005-pvck-improve-error-for-write-to-existing-file.patch
# BZ 2191683:
Patch6: 0006-lvreduce-make-_lvseg_get_stripes-handle-integrity-la.patch
# BZ 2188480:
#Patch7: 0007-toollib-provide-proper-hint-for-referencing-VG-uuid-.patch
# BZ 2179430:
Patch8: 0008-tests-integrity-snapshots-now-work-on-raid-integrity.patch
BuildRequires: make
BuildRequires: gcc
@ -693,7 +703,7 @@ An extensive functional testsuite for LVM2.
%endif
%changelog
* Wed May 17 2023 Marian Csontos <mcsontos@redhat.com> - 2.03.21-2
* Wed May 24 2023 Marian Csontos <mcsontos@redhat.com> - 2.03.21-2
- Allow snapshots over raid+integrity LV.
* Fri Apr 21 2023 Marian Csontos <mcsontos@redhat.com> - 2.03.21-1