Viewing: ext4-max-dir-size.patch
commit 31e1dbf5a16d19ac34a95f6ccd4a815e10306cef
Author: Zhou Bowen <bwzhou@clusterfs.com>
AuthorDate: Tue May 20 09:07:37 2008 +0000
ldiskfs: add max_dir_size tunable directory limit
Add a parameter max_dir_size_kb to limit the maximum directory size.
This allows sites to limit very large directories to avoid issues
with userspace tools like "ls" that cannot handle millions of files
in a directory efficiently.
The max_dir_size tunable is kept for compatibility with kernels < 3.6
when the 'max_dir_size_kb' parameter was added to upstream ext4.
Linux-commit: df981d03eeff7971ac7e6ff37000bfa702327ef1
Bugzilla-ID: b=13285
Signed-off-by: Zhou Bowen <bwzhou@clusterfs.com>
Reviewed-by: Sergey Glushchenko <deen@clusterfs.com>
Reviewed-by: Andreas Dilger <adilger@clusterfs.com>
---
fs/ext4/sysfs.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -209,6 +209,8 @@ EXT4_ATTR_FUNC(reserved_clusters, 0644);
EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, inode_readahead,
ext4_sb_info, s_inode_readahead_blks);
EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal);
+EXT4_RW_ATTR_SBI_UI(max_dir_size, s_max_dir_size_kb);
+EXT4_RW_ATTR_SBI_UI(max_dir_size_kb, s_max_dir_size_kb);
EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats);
EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
@@ -252,6 +254,8 @@ static struct attribute *ext4_attrs[] =
ATTR_LIST(reserved_clusters),
ATTR_LIST(inode_readahead_blks),
ATTR_LIST(inode_goal),
+ ATTR_LIST(max_dir_size),
+ ATTR_LIST(max_dir_size_kb),
ATTR_LIST(mb_stats),
ATTR_LIST(mb_max_to_scan),
ATTR_LIST(mb_min_to_scan),
@@ -376,7 +380,9 @@ static ssize_t ext4_attr_show(struct kob
le32_to_cpup(ptr));
else
return snprintf(buf, PAGE_SIZE, "%u\n",
- *((unsigned int *) ptr));
+ strcmp("max_dir_size", a->attr.name) ?
+ *((unsigned int *) ptr) :
+ (*((unsigned int *) ptr)) << 10);
case attr_pointer_ul:
if (!ptr)
return 0;
@@ -439,6 +445,8 @@ static ssize_t ext4_attr_store(struct ko
ret = kstrtoul(skip_spaces(buf), 0, &t);
if (ret)
return ret;
+ if (strcmp("max_dir_size", a->attr.name) == 0)
+ t >>= 10;
if (a->attr_ptr == ptr_ext4_super_block_offset)
*((__le32 *) ptr) = cpu_to_le32(t);
else