main - pvscan: only match devices file for command args
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d0ab5bf7f98da83cd5d7ec393554dff309482cf4 Commit: d0ab5bf7f98da83cd5d7ec393554dff309482cf4 Parent: 87714a1384def2ea107d7dbc264eff44c2025865 Author: David Teigland <[email protected]> AuthorDate: Wed Aug 4 12:04:03 2021 -0500 Committer: David Teigland <[email protected]> CommitterDate: Thu Aug 5 13:20:26 2021 -0500
pvscan: only match devices file for command args
Avoid matching all devices with the devices file to avoid delays during startup.
--- lib/device/dev-cache.c | 19 ++++++++++++++++++- lib/device/dev-cache.h | 1 + lib/device/device_id.c | 4 ++-- tools/pvscan.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 65 insertions(+), 5 deletions(-)
lib/device/dev-cache.c +18 -1
@@ -1829,7 +1829,7 @@ int setup_devices_file(struct cmd_context *cmd)* Add all system devices to dev-cache, and attempt to * match all devices_file entries to dev-cache entries. */ -int setup_devices (struct cmd_context *cmd) +static int _setup_devices (struct cmd_context *cmd,int no_file_match) {int file_exists;int lock_mode =0 ;
@@ -1956,6 +1956,13 @@ int setup_devices(struct cmd_context *cmd)*/ dev_cache_scan (cmd); +/* +* The caller uses "no_file_match" if it wants to match specific devs +* itself, instead of matching everything in device_ids_match. +*/ +if (no_file_match && cmd->enable_devices_file) +return 1 ; +/* * Match entries from cmd->use_devices with device structs in dev-cache. */
@@ -1964,6 +1971,16 @@ int setup_devices(struct cmd_context *cmd)return 1 ; } +int setup_devices (struct cmd_context *cmd) +{ +return _setup_devices (cmd,0 ); +} + +int setup_devices_no_file_match (struct cmd_context *cmd) +{ +return _setup_devices (cmd,1 ); +} +/* * The alternative to setup_devices() when the command is interested * in using only one PV.
lib/device/dev-cache.h +1 -0
@@ -77,6 +77,7 @@ int get_dm_uuid_from_sysfs(char *buf, size_t buf_size, int major, int minor);int setup_devices_file (struct cmd_context *cmd);int setup_devices (struct cmd_context *cmd); +int setup_devices_no_file_match (struct cmd_context *cmd);int setup_device (struct cmd_context *cmd,const char *devname);#endif
lib/device/device_id.c +2 -2
@@ -1324,7 +1324,7 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct du->dev = dev; dev->id = id; dev->flags |=DEV_MATCHED_USE_ID ; -log_debug ("compare match %s %s to %s" , +log_debug ("Match device_id %s %s to %s" ,idtype_to_str (du->idtype), du->idname,dev_name (dev));return 1 ; }else {
@@ -1370,7 +1370,7 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct du->dev = dev; dev->id = id; dev->flags |=DEV_MATCHED_USE_ID ; -log_debug ("compare match %s %s to %s" , +log_debug ("Match device_id %s %s to %s" ,idtype_to_str (du->idtype), du->idname,dev_name (dev));return 1 ; }
tools/pvscan.c +44 -2
72 lines not on this page · raw message