summaryrefslogtreecommitdiff
path: root/lib/misc
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2021-06-08 17:12:09 -0500
committerDavid Teigland <teigland@redhat.com>2021-07-13 11:11:23 -0500
commit90485650931d3fc04d00c92a729050c8743969e5 (patch)
treee7b17771fba2aeba3fa9415a68524022ca30d60d /lib/misc
parentdb22a389cfb12eef77dfc2e1ce124ac83ed6c5a2 (diff)
downloadlvm2-90485650931d3fc04d00c92a729050c8743969e5.tar.gz
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.
Diffstat (limited to 'lib/misc')
-rw-r--r--lib/misc/lvm-wrappers.c14
1 files changed, 12 insertions, 2 deletions
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;
}