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