summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2016-04-07 21:37:26 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2016-04-07 22:32:08 +0200
commit8b2108e6b16cbcb528a138413e9050dd6f420e0d (patch)
treea70728019217ba8a4b8552d4557eb53edae7fd46
parent097a724bda160e4c0b5c7760e7a710d3e00b898c (diff)
downloadlvm2-8b2108e6b16cbcb528a138413e9050dd6f420e0d.tar.gz
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.
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/activate/dev_manager.c23
2 files changed, 24 insertions, 0 deletions
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 <limits.h>
#include <dirent.h>
+#include <sys/utsname.h>
#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,