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