|
|
b6fb8c |
From 5533cd7bf4c1edc5d8fb0e95d2f83b2b2d446339 Mon Sep 17 00:00:00 2001
|
|
|
b6fb8c |
From: David Teigland <teigland@redhat.com>
|
|
|
b6fb8c |
Date: Tue, 16 Nov 2021 09:29:24 -0600
|
|
|
38b7b2 |
Subject: [PATCH 10/54] device_id: fix search on filtered device
|
|
|
b6fb8c |
|
|
|
b6fb8c |
When devnames are used as device ids and devnames change,
|
|
|
b6fb8c |
then new devices need to be located for the PVs. If the old
|
|
|
b6fb8c |
devname is now used by a filtered device, this was preventing
|
|
|
b6fb8c |
the code from searching for the new device, so the PV was
|
|
|
b6fb8c |
reported as missing.
|
|
|
b6fb8c |
---
|
|
|
b6fb8c |
lib/device/device_id.c | 16 ++++++-
|
|
|
b6fb8c |
test/shell/devicesfile-devname.sh | 69 +++++++++++++++++++++++++++++++
|
|
|
b6fb8c |
2 files changed, 83 insertions(+), 2 deletions(-)
|
|
|
b6fb8c |
|
|
|
b6fb8c |
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
|
|
|
b6fb8c |
index dea739fc4..48f1682a3 100644
|
|
|
b6fb8c |
--- a/lib/device/device_id.c
|
|
|
b6fb8c |
+++ b/lib/device/device_id.c
|
|
|
b6fb8c |
@@ -2025,12 +2025,19 @@ void device_ids_find_renamed_devs(struct cmd_context *cmd, struct dm_list *dev_l
|
|
|
b6fb8c |
search_auto = !strcmp(cmd->search_for_devnames, "auto");
|
|
|
b6fb8c |
|
|
|
b6fb8c |
dm_list_iterate_items(du, &cmd->use_devices) {
|
|
|
b6fb8c |
- if (du->dev)
|
|
|
b6fb8c |
- continue;
|
|
|
b6fb8c |
if (!du->pvid)
|
|
|
b6fb8c |
continue;
|
|
|
b6fb8c |
if (du->idtype != DEV_ID_TYPE_DEVNAME)
|
|
|
b6fb8c |
continue;
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+ /*
|
|
|
b6fb8c |
+ * if the old incorrect devname is now a device that's
|
|
|
b6fb8c |
+ * filtered and not scanned, e.g. an mpath component,
|
|
|
b6fb8c |
+ * then we want to look for the pvid on a new device.
|
|
|
b6fb8c |
+ */
|
|
|
b6fb8c |
+ if (du->dev && !du->dev->filtered_flags)
|
|
|
b6fb8c |
+ continue;
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
if (!(dil = dm_pool_zalloc(cmd->mem, sizeof(*dil))))
|
|
|
b6fb8c |
continue;
|
|
|
b6fb8c |
|
|
|
b6fb8c |
@@ -2055,6 +2062,11 @@ void device_ids_find_renamed_devs(struct cmd_context *cmd, struct dm_list *dev_l
|
|
|
b6fb8c |
* the searched file, so a subsequent lvm command will do the search
|
|
|
b6fb8c |
* again. In future perhaps we could add a policy to automatically
|
|
|
b6fb8c |
* remove a devices file entry that's not been found for some time.
|
|
|
b6fb8c |
+ *
|
|
|
b6fb8c |
+ * TODO: like the hint file, add a hash of all devnames to the searched
|
|
|
b6fb8c |
+ * file so it can be ignored and removed if the devs/hash change.
|
|
|
b6fb8c |
+ * If hints are enabled, the hints invalidation could also remove the
|
|
|
b6fb8c |
+ * searched file.
|
|
|
b6fb8c |
*/
|
|
|
b6fb8c |
if (_searched_devnames_exists(cmd)) {
|
|
|
b6fb8c |
log_debug("Search for PVIDs skipped for %s", _searched_file);
|
|
|
b6fb8c |
diff --git a/test/shell/devicesfile-devname.sh b/test/shell/devicesfile-devname.sh
|
|
|
b6fb8c |
index f95be52b1..a99fe3e9a 100644
|
|
|
b6fb8c |
--- a/test/shell/devicesfile-devname.sh
|
|
|
b6fb8c |
+++ b/test/shell/devicesfile-devname.sh
|
|
|
b6fb8c |
@@ -545,4 +545,73 @@ grep "$PVID2" "$DF" |tee out
|
|
|
b6fb8c |
grep "$dev2" out
|
|
|
b6fb8c |
not grep "$dev1" out
|
|
|
b6fb8c |
|
|
|
b6fb8c |
+vgchange -an $vg1
|
|
|
b6fb8c |
+vgchange -an $vg2
|
|
|
b6fb8c |
+vgremove -ff $vg1
|
|
|
b6fb8c |
+vgremove -ff $vg2
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+# devnames change so the new devname now refers to a filtered device,
|
|
|
b6fb8c |
+# e.g. an mpath or md component, which is not scanned
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+wait_md_create() {
|
|
|
b6fb8c |
+ local md=$1
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+ while :; do
|
|
|
b6fb8c |
+ if ! grep "$(basename $md)" /proc/mdstat; then
|
|
|
b6fb8c |
+ echo "$md not ready"
|
|
|
b6fb8c |
+ cat /proc/mdstat
|
|
|
b6fb8c |
+ sleep 2
|
|
|
b6fb8c |
+ else
|
|
|
b6fb8c |
+ break
|
|
|
b6fb8c |
+ fi
|
|
|
b6fb8c |
+ done
|
|
|
b6fb8c |
+ echo "$md" > WAIT_MD_DEV
|
|
|
b6fb8c |
+}
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+aux wipefs_a "$dev1"
|
|
|
b6fb8c |
+aux wipefs_a "$dev2"
|
|
|
b6fb8c |
+aux wipefs_a "$dev3"
|
|
|
b6fb8c |
+aux wipefs_a "$dev4"
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+mddev="/dev/md33"
|
|
|
b6fb8c |
+not grep $mddev /proc/mdstat || skip
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+rm "$DF"
|
|
|
b6fb8c |
+touch "$DF"
|
|
|
b6fb8c |
+vgcreate $vg1 "$dev1" "$dev2"
|
|
|
b6fb8c |
+cat "$DF"
|
|
|
b6fb8c |
+cp "$DF" "$ORIG"
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+# PVID with dashes for matching pvs -o+uuid output
|
|
|
b6fb8c |
+OPVID1=`pvs "$dev1" --noheading -o uuid | awk '{print $1}'`
|
|
|
b6fb8c |
+OPVID2=`pvs "$dev2" --noheading -o uuid | awk '{print $1}'`
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+# PVID without dashes for matching devices file fields
|
|
|
b6fb8c |
+PVID1=`pvs "$dev1" --noheading -o uuid | tr -d - | awk '{print $1}'`
|
|
|
b6fb8c |
+PVID2=`pvs "$dev2" --noheading -o uuid | tr -d - | awk '{print $1}'`
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=2 "$dev3" "$dev4"
|
|
|
b6fb8c |
+wait_md_create "$mddev"
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+sed -e "s|DEVNAME=$dev1|DEVNAME=$dev3|" "$ORIG" > tmp1.devices
|
|
|
b6fb8c |
+sed -e "s|IDNAME=$dev1|IDNAME=$dev3|" tmp1.devices > "$DF"
|
|
|
b6fb8c |
+cat "$DF"
|
|
|
b6fb8c |
+pvs -o+uuid |tee out
|
|
|
b6fb8c |
+grep "$dev1" out
|
|
|
b6fb8c |
+grep "$dev2" out
|
|
|
b6fb8c |
+grep "$OPVID1" out
|
|
|
b6fb8c |
+grep "$OPVID2" out
|
|
|
b6fb8c |
+not grep "$dev3" out
|
|
|
b6fb8c |
+not grep "$dev4" out
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+grep "$dev1" "$DF"
|
|
|
b6fb8c |
+grep "$dev2" "$DF"
|
|
|
b6fb8c |
+grep "$PVID1" "$DF"
|
|
|
b6fb8c |
+grep "$PVID2" "$DF"
|
|
|
b6fb8c |
+not grep "$dev3" "$DF"
|
|
|
b6fb8c |
+not grep "$dev4" "$DF"
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+mdadm --stop "$mddev"
|
|
|
b6fb8c |
+aux udev_wait
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
vgremove -ff $vg1
|
|
|
b6fb8c |
--
|
|
|
38b7b2 |
2.34.3
|
|
|
b6fb8c |
|