summaryrefslogtreecommitdiff
path: root/tools/pvscan.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2023-01-27 15:56:06 -0600
committerDavid Teigland <teigland@redhat.com>2023-01-31 15:30:35 -0600
commitc9fdc828ff0504bc2e57f65862bc382f7663a8a2 (patch)
treebe061567e92602421b7e1cd0ccbcb72bfba1c681 /tools/pvscan.c
parent17a3585cbb55d9a15ced9775a18b50c53a50ee8e (diff)
downloadlvm2-c9fdc828ff0504bc2e57f65862bc382f7663a8a2.tar.gz
vgchange autoactivation: skip regex filter containing symlinks
"vgchange -aay --autoactivation event" is called by our udev rule. When the udev rule runs, symlinks for devices may not all be created yet. If the regex filter contains symlinks, it won't work correctly. This command uses devices that already passed through pvscan. Since pvscan applies the regex filter correctly, this command inherits the filtering from pvscan and can skip the regex filter itself. See the previous commit "pvscan: use alternate device names from DEVLINKS to check filter"
Diffstat (limited to 'tools/pvscan.c')
-rw-r--r--tools/pvscan.c49
1 files changed, 3 insertions, 46 deletions
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 71485610b..8f60b2522 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -803,49 +803,6 @@ out:
return ret;
}
-/*
- * The optimization in which only the pvscan arg devname is added to dev-cache
- * does not work if there's an lvm.conf filter containing symlinks to the dev
- * like /dev/disk/by-id/lvm-pv-uuid-xyz entries. A full dev_cache_scan will
- * associate the symlinks with the system dev name passed to pvscan, which lets
- * filter-regex match the devname with the symlink name in the filter.
- */
-static int _filter_uses_symlinks(struct cmd_context *cmd, int filter_cfg)
-{
- const struct dm_config_node *cn;
- const struct dm_config_value *cv;
- const char *fname;
-
- if ((cn = find_config_tree_array(cmd, filter_cfg, NULL))) {
- for (cv = cn->v; cv; cv = cv->next) {
- if (cv->type != DM_CFG_STRING)
- continue;
- if (!cv->v.str)
- continue;
-
- fname = cv->v.str;
-
- if (fname[0] != 'a')
- continue;
-
- if (strstr(fname, "/dev/disk/"))
- return 1;
- if (strstr(fname, "/dev/mapper/"))
- return 1;
-
- /* In case /dev/disk/by was omitted */
- if (strstr(fname, "lvm-pv-uuid"))
- return 1;
- if (strstr(fname, "dm-uuid"))
- return 1;
- if (strstr(fname, "wwn-"))
- return 1;
- }
- }
-
- return 0;
-}
-
struct pvscan_arg {
struct dm_list list;
const char *devname;
@@ -1544,9 +1501,9 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
* be usable by that symlink name yet.
*/
if ((dm_list_size(&pvscan_devs) == 1) &&
- !cmd->enable_devices_file && !cmd->enable_devices_list &&
- (_filter_uses_symlinks(cmd, devices_filter_CFG) ||
- _filter_uses_symlinks(cmd, devices_global_filter_CFG))) {
+ !cmd->enable_devices_file &&
+ !cmd->enable_devices_list &&
+ regex_filter_contains_symlink(cmd)) {
char *env_str;
struct dm_list *env_aliases;
devl = dm_list_item(dm_list_first(&pvscan_devs), struct device_list);