From 90485650931d3fc04d00c92a729050c8743969e5 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Tue, 8 Jun 2021 17:12:09 -0500 Subject: devices: rework libudev usage related to config settings: obtain_device_info_from_udev (controls if lvm gets a list of devices from readdir /dev or from libudev) external_device_info_source (controls if lvm asks libudev for device information) . Make the obtain_device_list_from_udev setting affect only the choice of readdir /dev vs libudev. The setting no longer controls if udev is used for device type checks. . Change obtain_device_list_from_udev default to 0. This helps avoid boot timeouts due to slow libudev queries, avoids reported failures from udev_enumerate_scan_devices, and avoids delays from "device not initialized in udev database" errors. Even without errors, for a system booting with 1024 PVs, lvm2-pvscan times improve from about 100 sec to 15 sec, and the pvscan command from about 64 sec to about 4 sec. . For external_device_info_source="none", remove all libudev device info queries, and use only lvm native device info. . For external_device_info_source="udev", first check lvm native device info, then check libudev info. . Remove sleep/retry loop when attempting libudev queries for device info. udev info will simply be skipped if it's not immediately available. . Only set up a libdev connection if it will be used by obtain_device_list_from_udev/external_device_info_source. . For native multipath component detection, use /etc/multipath/wwids. If a device has a wwid matching an entry in the wwids file, then it's considered a multipath component. This is necessary to natively detect multipath components when the mpath device is not set up. --- lib/misc/lvm-wrappers.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/misc') diff --git a/lib/misc/lvm-wrappers.c b/lib/misc/lvm-wrappers.c index c36e2cfc7..2e0cfd514 100644 --- a/lib/misc/lvm-wrappers.c +++ b/lib/misc/lvm-wrappers.c @@ -25,19 +25,29 @@ struct udev *_udev; int udev_init_library_context(void) { if (_udev) - udev_unref(_udev); + return 1; + + if (getenv("DM_DISABLE_UDEV")) + return 0; if (!(_udev = udev_new())) { log_error("Failed to create udev library context."); return 0; } + if (!udev_is_running()) { + udev_unref(_udev); + _udev = NULL; + return 0; + } + return 1; } void udev_fin_library_context(void) { - udev_unref(_udev); + if (_udev) + udev_unref(_udev); _udev = NULL; } -- cgit v1.2.1