diff --git a/SOURCES/lvm2-2_03_12-dev_get_primary_dev-fix-invalid-path-check.patch b/SOURCES/lvm2-2_03_12-dev_get_primary_dev-fix-invalid-path-check.patch new file mode 100644 index 0000000..add3525 --- /dev/null +++ b/SOURCES/lvm2-2_03_12-dev_get_primary_dev-fix-invalid-path-check.patch @@ -0,0 +1,48 @@ +From b3719266bd5e3a9e6737d6bda60e543121ddf343 Mon Sep 17 00:00:00 2001 +From: David Teigland +Date: Tue, 9 Feb 2021 09:47:08 -0600 +Subject: [PATCH] dev_get_primary_dev: fix invalid path check + +Fix commit bee9f4efdd81 "filter-mpath: work with nvme devices" +which removed setting the path for readlink. + +(cherry picked from commit f74f94c2ddb1d33d75d325c959344a566a621fd5) + +Conflicts: + lib/device/dev-type.c +--- + lib/device/dev-type.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c +index 379afa8..1342e97 100644 +--- a/lib/device/dev-type.c ++++ b/lib/device/dev-type.c +@@ -434,7 +434,7 @@ static int _has_sys_partition(struct device *dev) + int minor = (int) MINOR(dev->dev); + + /* check if dev is a partition */ +- if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d/partition", ++ if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/partition", + dm_sysfs_dir(), major, minor) < 0) { + log_error("dm_snprintf partition failed"); + return 0; +@@ -660,8 +660,13 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result) + * - basename ../../block/md0/md0 = md0 + * Parent's 'dev' sysfs attribute = /sys/block/md0/dev + */ +- if ((size = readlink(dirname(path), temp_path, sizeof(temp_path) - 1)) < 0) { +- log_sys_error("readlink", path); ++ if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d", ++ dm_sysfs_dir(), major, minor) < 0) { ++ log_warn("WARNING: %s: major:minor sysfs path is too long.", dev_name(dev)); ++ return 0; ++ } ++ if ((size = readlink(path, temp_path, sizeof(temp_path) - 1)) < 0) { ++ log_warn("WARNING: Readlink of %s failed.", path); + goto out; + } + +-- +1.8.3.1 + diff --git a/SPECS/lvm2.spec b/SPECS/lvm2.spec index 6d97f19..04ee8b3 100644 --- a/SPECS/lvm2.spec +++ b/SPECS/lvm2.spec @@ -57,7 +57,7 @@ Name: lvm2 Epoch: %{rhel} %endif Version: 2.03.11 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 URL: http://sourceware.org/lvm2 Source0: ftp://sourceware.org/pub/lvm2/releases/LVM2.%{version}.tgz @@ -92,6 +92,8 @@ Patch20: lvm2-2_03_12-lvcreate-use-lv_passes_readonly_filter.patch Patch21: lvm2-2_03_12-test-check-read_only_volume_list-tagging-works.patch # BZ 1859659: Patch22: lvm2-2_03_12-filter-mpath-work-with-nvme-devices.patch +# BZ 1925871: +Patch23: lvm2-2_03_12-dev_get_primary_dev-fix-invalid-path-check.patch BuildRequires: gcc %if %{enable_testsuite} @@ -170,6 +172,7 @@ or more physical volumes and creating one or more logical volumes %patch20 -p1 -b .backup20 %patch21 -p1 -b .backup21 %patch22 -p1 -b .backup22 +%patch23 -p1 -b .backup23 %build %global _default_pid_dir /run @@ -774,6 +777,9 @@ An extensive functional testsuite for LVM2. %endif %changelog +* Thu Feb 11 2021 Marian Csontos - 2.03.11-4 +- Fix "Failed to get primary device" for NVMe devices. + * Wed Feb 03 2021 Marian Csontos - 2.03.11-3 - Fix mpath filtering of NVMe devices. - Check if lvcreate passes read_only_volume_list with tags and skips zeroing.