From 8b2108e6b16cbcb528a138413e9050dd6f420e0d Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 7 Apr 2016 21:37:26 +0200 Subject: [PATCH] activation: do not check for devs without LVM- Devices without "LVM-" uuid prefix have been generated by very old version of lvm2 2.00 and 2.01. Since version 2.02 all lvm2 devices are using prefix "LVM-". However checking for present of ancient non prefixed devices does take extra IOCTL per every call and for majority of todays user it will not find anything new. So use the assumption that users with kernel 3.X and newer are not really using such old versions of lvm2 (year <2005) and with their new kernel they are also using new version of lvm2 and skip checking for them. This change also makes trace logs more readable. --- WHATS_NEW | 1 + lib/activate/dev_manager.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index 8387eabc6..21970a84e 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.150 - ================================= + Check for devices without LVM- uuid prefix only with kernels < 3.X. Reuse %FREE size aproximation with lvcreate -l%PVS thin-pool. Allow the lvmdump directory to exist already provided it is empty. Show lvconverted percentage with 2 decimal digits. diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index b3e97db55..18e208182 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -29,6 +29,7 @@ #include #include +#include #define MAX_TARGET_PARAMSIZE 50000 #define LVM_UDEV_NOSCAN_FLAG DM_SUBSYSTEM_UDEV_FLAG0 @@ -674,6 +675,24 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check) return r; } +/* Returns 1 for kernels >= 3.X, otherwise 0 */ +static int _check_new_kernel(void) +{ + static int major = 0; + struct utsname _uts; + + if (!major) { + if (uname(&_uts) || + (sscanf(_uts.release, "%d", &major) != 1)) + major = 1; + else if (major >= 3) + log_debug("Not checking for devices without prefix " + UUID_PREFIX " with newer kernel."); + } + + return (major >= 3); +} + static int _info(const char *dlid, int with_open_count, int with_read_ahead, struct dm_info *dminfo, uint32_t *read_ahead, struct lv_seg_status *seg_status) @@ -703,6 +722,10 @@ static int _info(const char *dlid, int with_open_count, int with_read_ahead, } } + /* With kernels > 3.X skip checking for devices without UUID_PREFIX */ + if (_check_new_kernel()) + return r; + /* Check for dlid before UUID_PREFIX was added */ if ((r = _info_run(seg_status ? STATUS : INFO, NULL, dlid + sizeof(UUID_PREFIX) - 1, dminfo, read_ahead, seg_status, with_open_count,