All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pvscan --cache /dev/xx needs to scan all disks and aliases when enable device filter
@ 2022-12-07  9:34 wangzhiqiang
  2022-12-07 15:29 ` David Teigland
  0 siblings, 1 reply; 3+ messages in thread
From: wangzhiqiang @ 2022-12-07  9:34 UTC (permalink / raw)
  To: lvm-devel

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

Signed-off-by: wangzhiqiang<wangzhiqiang95@huawei.com>
Signed-off-by: wuguanghao<wuguanghao3@huawei.com>
---
lib/commands/toolcontext.c | 2 ++
lib/commands/toolcontext.h | 1 +
tools/pvscan.c             | 7 +++++++
3 files changed, 10 insertions(+)

diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 4faad0e..900b6ce 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -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. */
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 957ab7f..0539122 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -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 */
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 95d593d..19d99b8 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -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>

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] pvscan --cache /dev/xx needs to scan all disks and aliases when enable device filter
  2022-12-07  9:34 [PATCH] pvscan --cache /dev/xx needs to scan all disks and aliases when enable device filter wangzhiqiang
@ 2022-12-07 15:29 ` David Teigland
  2022-12-09  1:27   ` 答复: " wangzhiqiang
  0 siblings, 1 reply; 3+ messages in thread
From: David Teigland @ 2022-12-07 15:29 UTC (permalink / raw)
  To: lvm-devel

On Wed, Dec 07, 2022 at 09:34:13AM +0000, wangzhiqiang (Q) wrote:
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* 答复: [PATCH] pvscan --cache /dev/xx needs to scan all disks and aliases when enable device filter
  2022-12-07 15:29 ` David Teigland
@ 2022-12-09  1:27   ` wangzhiqiang
  0 siblings, 0 replies; 3+ messages in thread
From: wangzhiqiang @ 2022-12-09  1:27 UTC (permalink / raw)
  To: lvm-devel

Thanks. the _filter_uses_symlinks function handles this case well.

wangzhiqiang

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

On Wed, Dec 07, 2022 at 09:34:13AM +0000, wangzhiqiang (Q) wrote:
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-09  1:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07  9:34 [PATCH] pvscan --cache /dev/xx needs to scan all disks and aliases when enable device filter wangzhiqiang
2022-12-07 15:29 ` David Teigland
2022-12-09  1:27   ` 答复: " wangzhiqiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.