Skip to contentSkip to conversation

main - filter-sysfs: skip when device id is set

PATCH David Teigland 1 participant 1 message Nov 2, 2021

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b5b0369e4decbd7e2b4a160ba8ebad4e8f8a4094
Commit:        b5b0369e4decbd7e2b4a160ba8ebad4e8f8a4094
Parent:        5d0964d127ea62da480cafc91fefe403dda86870
Author:        David Teigland <[email protected]>
AuthorDate:    Tue Nov 2 15:42:26 2021 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Tue Nov 2 16:54:53 2021 -0500

filter-sysfs: skip when device id is set

When a device id is set for a device, using an idtype other than devname, it means that sysfs has been used with the device to match the device id. So, checking for a sysfs entry for the device in filter-sysfs is redundant. For any other cases not covered by this (e.g. devname ids), have filter-sysfs simply stat /sys/dev/block/major:minor to test if the device exists in sysfs.

The extensive processing done by filter-sysfs init is removed. It was taking an immense amount of time with many devices, e.g. . 1024 PVs in 520 VGs
. 520 concurrent vgchange -ay <vgname> commands
. vgchange scans only PVs in the named VG (based on pvs_online
files from a pending patch)

A large number of the vgchange commands were taking over 1 min, and nearly half of that time was used by filter-sysfs init. With this patch, the vgchange commands take about half the time.

---
 lib/commands/toolcontext.c |  24 ++--
 lib/filters/filter-sysfs.c | 296 ++++-----------------------------------------
 2 files changed, 32 insertions(+), 288 deletions(-)
lib/commands/toolcontext.c +11 -13
index 1b7170de1..a0c78ddd6 100644
@@ -1143,19 +1143,6 @@ static struct dev_filter *_init_filter_chain(struct cmd_context *cmd)
 	 * Update MAX_FILTERS definition above when adding new filters.
 	 */
 
-	/*
-	 * sysfs filter. Only available on 2.6 kernels.  Non-critical.
-	 * Listed first because it's very efficient at eliminating
-	 * unavailable devices.
-	 *
-	 * TODO: I suspect that using the lvm_type and device_id
-	 * filters before this one may be more efficient.
-	 */
-	if (find_config_tree_bool(cmd, devices_sysfs_scan_CFG, NULL)) {
-		if ((filters[nr_filt] = sysfs_filter_create()))
-			nr_filt++;
-	}
-
 	/* internal filter used by command processing. */
 	if (!(filters[nr_filt] = internal_filter_create())) {
 		log_error("Failed to create internal device filter");
@@ -1195,6 +1182,17 @@ static struct dev_filter *_init_filter_chain(struct cmd_context *cmd)
 	}
 	nr_filt++;
 
+	/*
+	 * sysfs filter. Only available on 2.6 kernels.  Non-critical.
+	 * Eliminates unavailable devices.
+	 * TODO: this may be unnecessary now with device ids
+	 * (currently not used for devs match to device id using syfs)
+	 */
+	if (find_config_tree_bool(cmd, devices_sysfs_scan_CFG, NULL)) {
+		if ((filters[nr_filt] = sysfs_filter_create()))
+			nr_filt++;
+	}
+
 	/* usable device filter. Required. */
 	if (!(filters[nr_filt] = usable_filter_create(cmd, cmd->dev_types, FILTER_MODE_NO_LVMETAD))) {
 		log_error("Failed to create usabled device filter");
lib/filters/filter-sysfs.c +21 -275

342 lines not on this page · raw message