Skip to contentSkip to conversation

main - pvscan: match device arg to filter symlink

PATCH David Teigland 1 participant 1 message Nov 30, 2021

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d12baba1a9bfe2d82537b20bc768758d84b263b6
Commit:        d12baba1a9bfe2d82537b20bc768758d84b263b6
Parent:        009007484b88fb16e2177deaf4774d0e50576a06
Author:        David Teigland <[email protected]>
AuthorDate:    Mon Nov 29 17:13:44 2021 -0600
Committer:     David Teigland <[email protected]>
CommitterDate: Mon Nov 29 17:13:44 2021 -0600

pvscan: match device arg to filter symlink

This fixes an issue related to the optimization in
"pvscan: only add device args to dev cache"

If the devices file is not used, and the lvm.conf filter accepts devices via symlink names, then those devices won't be accepted by pvscan for autoactivation. To resolve this, recognize when the filter contains symlinks and disable the optimization. When the optimization is disabled, a full dev_cache_scan is performed, and symlinks are associated with the device names passed to pvscan. filter-regex will accept a device if symlinks to that device are accepted.

---
 test/shell/udev-pvscan-vgchange.sh | 53 ++++++++++++++++++++++++++++++++
 tools/pvscan.c                     | 63 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 116 insertions(+)
test/shell/udev-pvscan-vgchange.sh +53 -0
index a82bf8876..a209dc048 100644
@@ -381,8 +381,13 @@ BDEVMD=$(basename "$mddev")
 lvcreate -l1 -an -n $lv1 $vg9
 lvcreate -l1 -an -n $lv2 $vg9
 
+mdadm --stop "$mddev"
+systemctl stop lvm-activate-$vg9 || true
 _clear_online_files
+mdadm --assemble "$mddev" "$dev1" "$dev2"
 
+# this trigger might be redundant because the mdadm --assemble
+# probably triggers an add uevent
 udevadm trigger --settle -c add /sys/block/$BDEVMD
 
 wait_lvm_activate $vg9
@@ -410,3 +415,51 @@ systemctl stop lvm-activate-$vg7
 systemctl stop lvm-activate-$vg8
 systemctl stop lvm-activate-$vg9
 
+
+# no devices file, filter with symlink of PV
+# the pvscan needs to look at all dev names to
+# match the symlink in the filter with the
+# dev name (or major minor) passed to pvscan.
+# This test doesn't really belong in this file
+# because it's not testing lvm-activate.
+
+aux lvmconf 'devices/use_devicesfile = 0'
+_clear_online_files
+rm "$DF"
+vgcreate $vg10 "$dev1"
+lvcreate -l1 -an -n $lv1 $vg10 "$dev1"
+
+PVID1=$(pvs "$dev1" --noheading -o uuid | tr -d - | awk '{print $1}')
+# PVID with dashes
+OPVID1=`pvs "$dev1" --noheading -o uuid | awk '{print $1}'`
+
+udevadm trigger --settle -c add /sys/block/$BDEV1
+
+# uevent from the trigger should create this symlink
+ls /dev/disk/by-id/lvm-pv-uuid-$OPVID1
+
+vgchange -an $vg10
+systemctl stop lvm-activate-$vg10
+_clear_online_files
+
+aux lvmconf "devices/filter = [ \"a|/dev/disk/by-id/lvm-pv-uuid-$OPVID1|\", \"r|.*|\" ]"
+aux lvmconf 'devices/global_filter = [ "a|.*|" ]'
+
+pvscan --cache -aay "$dev1"
+
+check lv_field $vg10/$lv1 lv_active "active"
+
+vgchange -an $vg10
+_clear_online_files
+
+aux lvmconf 'devices/filter = [ "a|lvm-pv-uuid|", "r|.*|" ]'
+aux lvmconf 'devices/global_filter = [ "a|.*|" ]'
+
+pvscan --cache -aay "$dev1"
+
+check lv_field $vg10/$lv1 lv_active "active"
+
+vgchange -an $vg10
+vgremove -y $vg10
+wipe_all
+
tools/pvscan.c +63 -0

75 lines not on this page · raw message