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

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