sysfs: count subdirectories
sysfs: count subdirectories
This patch introduces a subdirectory counter for each sysfs directory.
Without the patch, sysfs_refresh_inode would walk all entries of the directory
to calculate the number of subdirectories.
This patch improves time of "ls -la /sys/block" when there are 10000 block
devices from 9 seconds to 0.19 seconds.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 845ab3a..6348e2c 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -19,6 +19,8 @@
struct kobject *kobj;
/* children list starts here and goes through sd->s_sibling */
struct sysfs_dirent *children;
+
+ unsigned long subdirs;
};
struct sysfs_elem_symlink {