Blame SOURCES/0011-device_id-searched_devnames-improvements.patch

b6fb8c
From 39adf3e513ac7b1cbbbf0189f973573ade3c8939 Mon Sep 17 00:00:00 2001
b6fb8c
From: David Teigland <teigland@redhat.com>
b6fb8c
Date: Tue, 16 Nov 2021 11:26:41 -0600
38b7b2
Subject: [PATCH 11/54] device_id: searched_devnames improvements
b6fb8c
b6fb8c
Remove the searched_devnames file in a couple more places:
b6fb8c
. When hints need refreshing it's possible that a missing
b6fb8c
  devices file entry could be found by searching devices
b6fb8c
  again.
b6fb8c
. When a devices file entry devname is first found to be
b6fb8c
  incorrect, a new search for missing entries may be
b6fb8c
  useful.
b6fb8c
---
b6fb8c
 lib/device/device_id.c | 28 ++++++++++++++++++++++++++--
b6fb8c
 lib/label/hints.c      | 10 ++++++++++
b6fb8c
 2 files changed, 36 insertions(+), 2 deletions(-)
b6fb8c
b6fb8c
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
b6fb8c
index 48f1682a3..ce7ded154 100644
b6fb8c
--- a/lib/device/device_id.c
b6fb8c
+++ b/lib/device/device_id.c
b6fb8c
@@ -74,6 +74,8 @@ void unlink_searched_devnames(struct cmd_context *cmd)
b6fb8c
 
b6fb8c
 	if (unlink(_searched_file))
b6fb8c
 		log_debug("unlink %s errno %d", _searched_file, errno);
b6fb8c
+	else
b6fb8c
+		log_debug("unlink %s", _searched_file);
b6fb8c
 }
b6fb8c
 
b6fb8c
 static int _searched_devnames_exists(struct cmd_context *cmd)
b6fb8c
@@ -780,7 +782,7 @@ static void _device_ids_update_try(struct cmd_context *cmd)
b6fb8c
 
b6fb8c
 	/* Defer updates to non-pvscan-cache commands. */
b6fb8c
 	if (cmd->pvscan_cache_single) {
b6fb8c
-		log_print("pvscan[%d] skip updating devices file.", getpid());
b6fb8c
+		log_print("Devices file update skipped."); 
b6fb8c
 		return;
b6fb8c
 	}
b6fb8c
 
b6fb8c
@@ -1441,8 +1443,22 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct
b6fb8c
 	const char *idname;
b6fb8c
 	int part;
b6fb8c
 
b6fb8c
-	if (!du->idname || !du->idtype)
b6fb8c
+	/*
b6fb8c
+	 * The idname will be removed from an entry with devname type when the
b6fb8c
+	 * devname is read and found to hold a different PVID than the PVID in
b6fb8c
+	 * the entry.  At that point we only have the PVID and no known
b6fb8c
+	 * location for it.
b6fb8c
+	 */
b6fb8c
+	if (!du->idname || !du->idtype) {
b6fb8c
+		/*
b6fb8c
+		log_debug("Mismatch device_id %s %s %s to %s",
b6fb8c
+			  du->idtype ? idtype_to_str(du->idtype) : "idtype_missing",
b6fb8c
+			  du->idname ? du->idname : "idname_missing",
b6fb8c
+			  du->devname ? du->devname : "devname_missing",
b6fb8c
+			  dev_name(dev));
b6fb8c
+		*/
b6fb8c
 		return 0;
b6fb8c
+	}
b6fb8c
 
b6fb8c
 	/*
b6fb8c
 	 * Some idtypes can only match devices with a specific major number,
b6fb8c
@@ -1957,6 +1973,14 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs,
b6fb8c
 			*device_ids_invalid = 1;
b6fb8c
 	}
b6fb8c
 
b6fb8c
+	/*
b6fb8c
+	 * When a new devname/pvid mismatch is discovered, a new search for the
b6fb8c
+	 * pvid should be permitted (searched_devnames may exist to suppress
b6fb8c
+	 * searching for other pvids.)
b6fb8c
+	 */
b6fb8c
+	if (update_file)
b6fb8c
+		unlink_searched_devnames(cmd);
b6fb8c
+
b6fb8c
 	/* FIXME: for wrong devname cases, wait to write new until device_ids_find_renamed_devs? */
b6fb8c
 
b6fb8c
 	/*
b6fb8c
diff --git a/lib/label/hints.c b/lib/label/hints.c
b6fb8c
index e444a0c82..3ce9634f2 100644
b6fb8c
--- a/lib/label/hints.c
b6fb8c
+++ b/lib/label/hints.c
b6fb8c
@@ -1390,6 +1390,16 @@ int get_hints(struct cmd_context *cmd, struct dm_list *hints_out, int *newhints,
b6fb8c
 		log_debug("get_hints: needs refresh");
b6fb8c
 		free_hints(&hints_list);
b6fb8c
 
b6fb8c
+		/*
b6fb8c
+		 * This is not related to hints, and is probably unnecessary,
b6fb8c
+		 * but it could possibly help.  When hints become invalid it's
b6fb8c
+		 * usually becaues devs on the system have changed, and that
b6fb8c
+		 * also means that a missing devices file entry might be found
b6fb8c
+		 * by searching devices again.  (the searched_devnames
b6fb8c
+		 * mechanism should eventually be replaced)
b6fb8c
+		 */
b6fb8c
+		unlink_searched_devnames(cmd);
b6fb8c
+
b6fb8c
 		if (!_lock_hints(cmd, LOCK_EX, NONBLOCK))
b6fb8c
 			return 0;
b6fb8c
 
b6fb8c
-- 
38b7b2
2.34.3
b6fb8c