[Ocfs2-tools-devel] [PATCH] scandisk: remove unnecessary scansysfs op
Junxiao Bi
junxiao.bi at oracle.com
Tue Jun 21 22:01:06 PDT 2016
For every block device in sysfs who is not a symbol link,
scansysfs() will run two times on it, run once is enough
and that can improve scandisk speed.
Signed-off-by: Junxiao Bi <junxiao.bi at oracle.com>
---
libtools-internal/scandisk.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libtools-internal/scandisk.c b/libtools-internal/scandisk.c
index 0ad21a2b5606..5209de272f5d 100644
--- a/libtools-internal/scandisk.c
+++ b/libtools-internal/scandisk.c
@@ -763,15 +763,15 @@ static int scansysfs(struct devlisthead *devlisthead, const char *path, int leve
sysfs_is_disk(newpath);
}
- if (!stat(newpath, &sb) && !level)
+ if (!stat(newpath, &sb) && !level) {
if (S_ISDIR(sb.st_mode))
if (scansysfs(devlisthead, newpath, 1, has_holder) < 0)
return -1;
-
- if (!lstat(newpath, &sb))
+ } else if (!lstat(newpath, &sb)) {
if (S_ISDIR(sb.st_mode))
if (scansysfs(devlisthead, newpath, 1, has_holder) < 0)
return -1;
+ }
}
free(namelist[n]);
--
1.7.9.5
More information about the Ocfs2-tools-devel
mailing list