[lvm-devel] [PATCH 4/7] Do not lstat common path prefix
Zdenek Kabelac
zkabelac at redhat.com
Fri Nov 25 09:59:06 UTC 2011
When both path have common prefix i.e. /dev/disk/by-id
skip 2xlstat for /dev /dev/disk /dev/disk/by-id
and directly lstat only different part of path.
Reduces greatly amount of lstat calls on system with
lots of devices.
Signed-off-by: Zdenek Kabelac <zkabelac at redhat.com>
---
lib/device/dev-cache.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 61f479d..9b401ee 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -266,6 +266,8 @@ static int _compare_paths(const char *path0, const char *path1)
strncpy(p1, path1, PATH_MAX);
s0 = &p0[0] + 1;
s1 = &p1[0] + 1;
+ while (*s0 && *s0 == *s1)
+ s0++, s1++;
/* We prefer symlinks - they exist for a reason!
* So we prefer a shorter path before the first symlink in the name.
--
1.7.7.3
More information about the lvm-devel
mailing list