[lvm-devel] master - activation: do not check for devs without LVM-

Zdenek Kabelac zkabelac at fedoraproject.org
Thu Apr 7 22:22:21 UTC 2016


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8b2108e6b16cbcb528a138413e9050dd6f420e0d
Commit:        8b2108e6b16cbcb528a138413e9050dd6f420e0d
Parent:        097a724bda160e4c0b5c7760e7a710d3e00b898c
Author:        Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate:    Thu Apr 7 21:37:26 2016 +0200
Committer:     Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Thu Apr 7 22:32:08 2016 +0200

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(+), 0 deletions(-)

diff --git a/WHATS_NEW b/WHATS_NEW
index 8387eab..21970a8 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 b3e97db..18e2081 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,




More information about the lvm-devel mailing list