1 diff -rupN linux-2.6.18-164.6.1_1//fs/ext4/ialloc.c linux-2.6.18-164.6.1_2//fs/ext4/ialloc.c
2 --- linux-2.6.18-164.6.1_1//fs/ext4/ialloc.c 2010-03-31 17:42:50.000000000 +0530
3 +++ linux-2.6.18-164.6.1_2//fs/ext4/ialloc.c 2010-03-31 17:43:22.000000000 +0530
4 @@ -710,12 +710,15 @@ struct inode *ext4_new_inode_goal(handle
6 trace_mark(ext4_request_inode, "dev %s dir %lu mode %d", sb->s_id,
9 + if (sbi->s_max_dir_size > 0 && i_size_read(dir) >= sbi->s_max_dir_size)
10 + return ERR_PTR(-EFBIG);
12 inode = new_inode(sb);
14 return ERR_PTR(-ENOMEM);
20 if (goal && goal <= le32_to_cpu(es->s_inodes_count)) {
21 diff -rupN linux-2.6.18-164.6.1_1//fs/ext4/super.c linux-2.6.18-164.6.1_2//fs/ext4/super.c
22 --- linux-2.6.18-164.6.1_1//fs/ext4/super.c 2010-03-31 17:42:50.000000000 +0530
23 +++ linux-2.6.18-164.6.1_2//fs/ext4/super.c 2010-03-31 17:45:32.000000000 +0530
25 #include <asm/uaccess.h>
26 #include <linux/kthread.h>
27 #include <linux/utsname.h>
28 +#include <linux/proc_fs.h>
31 #include "ext4_jbd2.h"
32 @@ -581,6 +582,7 @@ static void ext4_put_super(struct super_
33 ext4_commit_super(sb, es, 1);
36 + remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
37 remove_proc_entry("inode_readahead_blks", sbi->s_proc);
38 remove_proc_entry("inode_goal", sbi->s_proc);
39 remove_proc_entry(sb->s_id, ext4_proc_root);
40 @@ -2341,6 +2343,48 @@ static unsigned long ext4_get_stripe_siz
44 +#ifdef CONFIG_PROC_FS
45 +static int ext4_max_dir_size_read(char *page, char **start, off_t off,
46 + int count, int *eof, void *data)
48 + struct ext4_sb_info *sbi = data;
55 + len = sprintf(page, "%lu\n", sbi->s_max_dir_size);
60 +static int ext4_max_dir_size_write(struct file *file, const char *buffer,
61 + unsigned long count, void *data)
63 + struct ext4_sb_info *sbi = data;
65 + unsigned long value;
68 + if (count >= sizeof(str)) {
69 + printk(KERN_ERR "EXT4-fs: %s string too long, max %u bytes\n",
70 + EXT4_MAX_DIR_SIZE_NAME, (int)sizeof(str));
74 + if (copy_from_user(str, buffer, count))
77 + value = simple_strtol(str, &end, 0);
81 + sbi->s_max_dir_size = value;
86 static int ext4_fill_super(struct super_block *sb, void *data, int silent)
87 __releases(kernel_lock)
88 __acquires(kernel_lock)
89 @@ -2690,6 +2734,19 @@ static int ext4_fill_super(struct super_
90 p->proc_fops = &ext4_ui_proc_fops,
91 p->data = &sbi->s_inode_goal;
93 + sbi->s_max_dir_size = EXT4_DEFAULT_MAX_DIR_SIZE;
94 + p = create_proc_entry(EXT4_MAX_DIR_SIZE_NAME,
95 + S_IFREG | S_IRUGO | S_IWUSR, sbi->s_proc);
97 + printk(KERN_ERR "EXT4-fs: unable to create %s\n",
98 + EXT4_MAX_DIR_SIZE_NAME);
103 + p->read_proc = ext4_max_dir_size_read;
104 + p->write_proc = ext4_max_dir_size_write;
109 @@ -2976,6 +3033,7 @@ failed_mount2:
110 kfree(sbi->s_group_desc);
113 + remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
114 remove_proc_entry("inode_readahead_blks", sbi->s_proc);
115 remove_proc_entry("inode_goal", sbi->s_proc);
116 remove_proc_entry(sb->s_id, ext4_proc_root);
117 diff -rupN linux-2.6.18-164.6.1_1//fs/ext4/ext4_sb.h linux-2.6.18-164.6.1_2//fs/ext4/ext4_sb.h
118 --- linux-2.6.18-164.6.1_1//fs/ext4/ext4_sb.h 2010-03-31 17:42:50.000000000 +0530
119 +++ linux-2.6.18-164.6.1_2//fs/ext4/ext4_sb.h 2010-03-31 17:43:22.000000000 +0530
120 @@ -119,6 +119,7 @@ struct ext4_sb_info {
121 /* where last allocation was done - for stream allocation */
122 unsigned long s_mb_last_group;
123 unsigned long s_mb_last_start;
124 + unsigned long s_max_dir_size;
126 /* history to debug policy */
127 struct ext4_mb_history *s_mb_history;
128 diff -rupN linux-2.6.18-164.6.1_1//fs/ext4/ext4.h linux-2.6.18-164.6.1_2//fs/ext4/ext4.h
129 --- linux-2.6.18-164.6.1_1//fs/ext4/ext4.h 2010-03-31 17:42:50.000000000 +0530
130 +++ linux-2.6.18-164.6.1_2//fs/ext4/ext4.h 2010-03-31 17:43:22.000000000 +0530
131 @@ -1029,6 +1029,12 @@ struct mmp_struct {
132 #define EXT4_MMP_MIN_CHECK_INTERVAL 5
135 + * max directory size tunable
137 +#define EXT4_DEFAULT_MAX_DIR_SIZE 0
138 +#define EXT4_MAX_DIR_SIZE_NAME "max_dir_size"
141 * Function prototypes