Blame SOURCES/0058-devices-file-fix-pvcreate-uuid-matching-pvid-entry-w.patch

8342e7
From 87904fbbb84c10e6f733db1c5ba447537d1cf08c Mon Sep 17 00:00:00 2001
8342e7
From: David Teigland <teigland@redhat.com>
8342e7
Date: Fri, 19 Aug 2022 13:31:22 -0500
8342e7
Subject: [PATCH 1/6] devices file: fix pvcreate --uuid matching pvid entry
8342e7
 with no device id
8342e7
8342e7
pvcreate with --uuid would segfault if a devices file entry matched
8342e7
the specified pvid, but the devices file entry had no device_id, which
8342e7
could happen if the entry has a devname idtype.
8342e7
---
8342e7
 lib/device/device_id.c            |  7 ++++---
8342e7
 test/shell/devicesfile-devname.sh | 13 +++++++++++++
8342e7
 2 files changed, 17 insertions(+), 3 deletions(-)
8342e7
8342e7
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
8342e7
index 4d8fa5c9c..c3816a66c 100644
8342e7
--- a/lib/device/device_id.c
8342e7
+++ b/lib/device/device_id.c
8342e7
@@ -1142,8 +1142,9 @@ id_done:
8342e7
 			  du_devname->devname);
8342e7
 
8342e7
 	if (du_pvid && (du_pvid->dev != dev))
8342e7
-		log_warn("WARNING: adding device %s with PVID %s which is already used for %s.",
8342e7
-			 dev_name(dev), pvid, du_pvid->dev ? dev_name(du_pvid->dev) : "missing device");
8342e7
+		log_warn("WARNING: adding device %s with PVID %s which is already used for %s device_id %s.",
8342e7
+			 dev_name(dev), pvid, du_pvid->dev ? dev_name(du_pvid->dev) : "missing device",
8342e7
+			 du_pvid->idname ?: "none");
8342e7
 
8342e7
 	if (du_devid && (du_devid->dev != dev)) {
8342e7
 		if (!du_devid->dev) {
8342e7
@@ -1189,7 +1190,7 @@ id_done:
8342e7
 		else
8342e7
 			check_idname = device_id_system_read(cmd, dev, du_pvid->idtype);
8342e7
 
8342e7
-		if (check_idname && !strcmp(check_idname, du_pvid->idname)) {
8342e7
+		if (!du_pvid->idname || (check_idname && !strcmp(check_idname, du_pvid->idname))) {
8342e7
 			update_du = du_pvid;
8342e7
 			dm_list_del(&update_du->list);
8342e7
 			update_matching_kind = "PVID";
8342e7
diff --git a/test/shell/devicesfile-devname.sh b/test/shell/devicesfile-devname.sh
8342e7
index 338637275..211f4dbed 100644
8342e7
--- a/test/shell/devicesfile-devname.sh
8342e7
+++ b/test/shell/devicesfile-devname.sh
8342e7
@@ -550,6 +550,19 @@ vgchange -an $vg2
8342e7
 vgremove -ff $vg1
8342e7
 vgremove -ff $vg2
8342e7
 
8342e7
+# bz 2119473
8342e7
+
8342e7
+aux lvmconf "devices/search_for_devnames = \"none\""
8342e7
+sed -e "s|DEVNAME=$dev1|DEVNAME=.|" "$ORIG" > tmp1.devices
8342e7
+sed -e "s|IDNAME=$dev1|IDNAME=.|" tmp1.devices > "$DF"
8342e7
+pvs
8342e7
+lvmdevices
8342e7
+pvcreate -ff --yes --uuid "$PVID1" --norestorefile $dev1
8342e7
+grep "$PVID1" "$DF" |tee out
8342e7
+grep "DEVNAME=$dev1" out
8342e7
+grep "IDNAME=$dev1" out
8342e7
+aux lvmconf "devices/search_for_devnames = \"auto\""
8342e7
+
8342e7
 # devnames change so the new devname now refers to a filtered device,
8342e7
 # e.g. an mpath or md component, which is not scanned
8342e7
 
8342e7
-- 
8342e7
2.38.1
8342e7