main - pvscan: use alternate device names from DEVLINKS to check filter
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=17a3585cbb55d9a15ced9775a18b50c53a50ee8e Commit: 17a3585cbb55d9a15ced9775a18b50c53a50ee8e Parent: d9f8acb65a78c20ac806efaeb7a1e39208e1a443 Author: David Teigland <[email protected]> AuthorDate: Thu Jan 19 17:37:31 2023 -0600 Committer: David Teigland <[email protected]> CommitterDate: Tue Jan 31 15:30:35 2023 -0600
pvscan: use alternate device names from DEVLINKS to check filter
pvscan --cache <dev> is called by our udev rule at a time when all the symlinks for <dev> may not be created yet (by other udev rules.) The regex filter in lvm.conf may refer to <dev> using a symlink name that hasn't yet been created, which would cause <dev> to not match the filter regex. The DEVLINKS env var, set by udev, contains all the symlink names for <dev> that have been or will be created. So, we add all these symlink names to dev->aliases, as if we had found them in /dev. This allows <dev> to be recognized by a regex filter containing a symlink for <dev>.
--- lib/commands/toolcontext.h | 1 + lib/filters/filter-regex.c | 2 +- man/lvmautoactivation.7_main | 13 ++++++++++ tools/pvscan.c | 60 ++++++++++++++++++++++++++------------------ 4 files changed, 51 insertions(+), 25 deletions(-)
lib/commands/toolcontext.h +1 -0
@@ -207,6 +207,7 @@ struct cmd_context { unsigned udevoutput:1; unsigned online_vg_file_removed:1; unsigned disable_dm_devs:1; /* temporarily disable use of dm devs cache */ + unsigned filter_regex_set_preferred_name_disable:1; /* prevent dev_set_preferred_name *//* * Devices and filtering.
lib/filters/filter-regex.c +1 -1
@@ -179,7 +179,7 @@ static int _accept_p(struct cmd_context *cmd, struct dev_filter *f, struct devicif (m >=0 ) {if (dm_bit (rf->accept, m)) { -if (!first) +if (!first && !cmd->filter_regex_set_preferred_name_disable)dev_set_preferred_name (sl, dev);return 1 ;
man/lvmautoactivation.7_main +13 -0
@@ -184,6 +184,19 @@ system from booting. A custom systemd service could be written to run autoactivation during system startup, in which case disabling event autoactivation may be useful. . +.SS lvm.conf filter +.P +Device symlinks from /dev/disk/ can be used in the lvm.conf filter to +guard against changes in kernel device names. The /dev/disk/by-path/ or +/dev/disk/by-id/ prefixes should be included in the filter names; these +prefixes help lvm detect that symlink names are used. Filters containing +symlinks require special matching by commands run in the lvm udev rule. +.P +Common symlinks, e.g. beginning with wwn-, scsi-, pci-, or lvm-pv-uuid-, +are recommended. Uncommon or custom symlinks created by custom udev rules +may be less reliable. If a custom udev rule creates symlinks used in the +lvm filter, then the udev rule should be started prior to the lvm rule. +. .SH EXAMPLES .P VG "vg" contains two PVs:
tools/pvscan.c +36 -24
72 lines not on this page · raw message