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(-)
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index db8a217..8498e62 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -208,6 +208,8 @@ EXT4_ATTR_FUNC(sra_exceeded_retry_limit, 0444);
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);
@@ -259,6 +261,8 @@ static struct attribute *ext4_attrs[] = {
ATTR_LIST(sra_exceeded_retry_limit),
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),
@@ -402,7 +406,9 @@ static ssize_t ext4_attr_show(struct kobject *kobj,
le32_to_cpup(ptr));
else
return sysfs_emit(buf, "%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;
@@ -465,6 +471,8 @@ static ssize_t ext4_attr_store(struct kobject *kobj,
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
--
2.25.1