Skip to contentSkip to conversation

pvscan --cache /dev/xx needs to scan all disks and aliases when enable device filter

PATCH New wangzhiqiang (Q) 2 participants 3 messages Dec 7, 2022 – Dec 9, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pvscan --cache /dev/xx needs to scan all disks and aliases when enable device filter

When the system restarts and the disk goes online, the udev rule will be triggered to scan the metadata on the disk to automatically activate the logical volume, If we specify the scanned disk alias in lvm.conf, reject other unspecified disks, then lv cannot activate since the aliases mismatch with disk name.

If device filtering is configured in lvm.conf, then pvscan --cache /dev/xx needs to scan all disks and aliases

---

lib/commands/toolcontext.c | 2 ++
lib/commands/toolcontext.h | 1 +
tools/pvscan.c             | 7 +++++++
3 files changed, 10 insertions(+)
lib/commands/toolcontext.c +2 -0
index 4faad0e..900b6ce 100644
@@ -1175,6 +1175,7 @@ static struct dev_filter *_init_filter_chain(struct cmd_context *cmd)
                        goto bad;
                }
                nr_filt++;
+               cmd->filter_in_config = 1;
        }
 
        /* regex filter. Optional. */
@@ -1184,6 +1185,7 @@ static struct dev_filter *_init_filter_chain(struct cmd_context *cmd)
                        goto bad;
                }
                nr_filt++;
+               cmd->filter_in_config = 1;
        }
 
        /* device type filter. Required. */
lib/commands/toolcontext.h +1 -0
index 957ab7f..0539122 100644
@@ -194,6 +194,7 @@ struct cmd_context {
        unsigned filter_deviceid_skip:1;        /* don't use filter-deviceid */
        unsigned filter_regex_with_devices_file:1; /* use filter-regex even when devices file is enabled */
        unsigned filter_nodata_only:1;          /* only use filters that do not require data from the dev */
+       unsigned filter_in_config:1;            /* only use filters set by lvm.conf */
        unsigned run_by_dmeventd:1;             /* command is being run by dmeventd */
        unsigned sysinit:1;                     /* --sysinit is used */
        unsigned ignorelockingfailure:1;        /* --ignorelockingfailure is used */
tools/pvscan.c +7 -0
index 95d593d..19d99b8 100644
@@ -1944,6 +1944,13 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
                        log_verbose("Ignoring pvscan --cache because event_activation is disabled.");
                        return ECMD_PROCESSED;
                }
+
+               /*
+                * scan all dev to avoid mismatch between the drive name and aliases
+                */
+               if (cmd->filter_in_config)
+                       lvmcache_label_scan(cmd);
+
                if (!_pvscan_cache_args(cmd, argc, argv, &complete_vgnames))
                        return ECMD_FAILED;
        }

--
2.33.0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20221207/69b4e7fc/attachment.htm>

#1 lore raw

PATCH 1/1 pvscan --cache /dev/xx needs to scan all disks and aliases when enable device filter

Quoted 5 lines · wangzhiqiang (Q)

When the system restarts and the disk goes online, the udev rule will be triggered to scan the metadata on the disk to automatically activate the logical volume, If we specify the scanned disk alias in lvm.conf, reject other unspecified disks, then lv cannot activate since the aliases mismatch with disk name.

If device filtering is configured in lvm.conf, then pvscan --cache /dev/xx needs to scan all disks and aliases

Hi, if I understand correctly, pvscan is already attempting to handle this case. See the use of "_filter_uses_symlinks" in pvscan.c. Perhaps it needs check for other symlink substrings? The problem with your patch is that it's a significant performance penalty for a common configuration.

Dave

#2 lore raw

Thanks. the _filter_uses_symlinks function handles this case well.

wangzhiqiang

-----????-----
???: David Teigland <[email protected]>
????: 2022?12?7? 23:30
???: wangzhiqiang (Q) <[email protected]>
??: lvm-devel at redhat.com; linfeilong <[email protected]>; liuzhiqiang (I) <[email protected]> ??: Re: [PATCH] pvscan --cache /dev/xx needs to scan all disks and aliases when enable device filter

Quoted 6 lines · wangzhiqiang (Q)

When the system restarts and the disk goes online, the udev rule will
be triggered to scan the metadata on the disk to automatically
activate the logical volume, If we specify the scanned disk alias in lvm.conf, reject other unspecified disks, then lv cannot activate since the aliases mismatch with disk name.

If device filtering is configured in lvm.conf, then pvscan --cache /dev/xx needs to scan all disks and aliases

Hi, if I understand correctly, pvscan is already attempting to handle this case. See the use of "_filter_uses_symlinks" in pvscan.c. Perhaps it needs check for other symlink substrings? The problem with your patch is that it's a significant performance penalty for a common configuration.

Dave