1 Index: linux-2.6.18.i386/fs/ext4/ialloc.c
2 ===================================================================
3 --- linux-2.6.18.i386.orig/fs/ext4/ialloc.c
4 +++ linux-2.6.18.i386/fs/ext4/ialloc.c
5 @@ -622,12 +622,15 @@ struct inode *ext4_new_inode(handle_t *h
7 trace_mark(ext4_request_inode, "dev %s dir %lu mode %d", sb->s_id,
10 + if (sbi->s_max_dir_size > 0 && i_size_read(dir) >= sbi->s_max_dir_size)
11 + return ERR_PTR(-EFBIG);
13 inode = new_inode(sb);
15 return ERR_PTR(-ENOMEM);
22 Index: linux-2.6.18.i386/fs/ext4/super.c
23 ===================================================================
24 --- linux-2.6.18.i386.orig/fs/ext4/super.c
25 +++ linux-2.6.18.i386/fs/ext4/super.c
27 #include <asm/uaccess.h>
28 #include <linux/kthread.h>
29 #include <linux/utsname.h>
30 +#include <linux/proc_fs.h>
33 #include "ext4_jbd2.h"
34 @@ -551,6 +554,7 @@ static void ext4_put_super(struct super_
35 ext4_commit_super(sb, es, 1);
38 + remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
39 remove_proc_entry("inode_readahead_blks", sbi->s_proc);
40 remove_proc_entry(sb->s_id, ext4_proc_root);
42 @@ -2185,6 +2191,48 @@ static unsigned long ext4_get_stripe_siz
46 +#ifdef CONFIG_PROC_FS
47 +static int ext4_max_dir_size_read(char *page, char **start, off_t off,
48 + int count, int *eof, void *data)
50 + struct ext4_sb_info *sbi = data;
57 + len = sprintf(page, "%lu\n", sbi->s_max_dir_size);
62 +static int ext4_max_dir_size_write(struct file *file, const char *buffer,
63 + unsigned long count, void *data)
65 + struct ext4_sb_info *sbi = data;
67 + unsigned long value;
70 + if (count >= sizeof(str)) {
71 + printk(KERN_ERR "EXT4-fs: %s string too long, max %u bytes\n",
72 + EXT4_MAX_DIR_SIZE_NAME, (int)sizeof(str));
76 + if (copy_from_user(str, buffer, count))
79 + value = simple_strtol(str, &end, 0);
83 + sbi->s_max_dir_size = value;
88 static int ext4_fill_super(struct super_block *sb, void *data, int silent)
89 __releases(kernel_lock)
90 __acquires(kernel_lock)
91 @@ -2743,6 +2790,20 @@ static int ext4_fill_super(struct super_
92 p->proc_fops = &ext4_ui_proc_fops,
93 p->data = &sbi->s_inode_goal;
95 + sbi->s_max_dir_size = EXT4_DEFAULT_MAX_DIR_SIZE;
96 + p = create_proc_entry(EXT4_MAX_DIR_SIZE_NAME,
97 + S_IFREG | S_IRUGO | S_IWUSR, sbi->s_proc);
99 + printk(KERN_ERR "EXT4-fs: unable to create %s\n",
100 + EXT4_MAX_DIR_SIZE_NAME);
101 + remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
106 + p->read_proc = ext4_max_dir_size_read;
107 + p->write_proc = ext4_max_dir_size_write;
112 Index: linux-2.6.18.i386/fs/ext4/ext4_sb.h
113 ===================================================================
114 --- linux-2.6.18.i386.orig/fs/ext4/ext4_sb.h
115 +++ linux-2.6.18.i386/fs/ext4/ext4_sb.h
116 @@ -117,6 +117,7 @@ struct ext4_sb_info {
117 /* where last allocation was done - for stream allocation */
118 unsigned long s_mb_last_group;
119 unsigned long s_mb_last_start;
120 + unsigned long s_max_dir_size;
122 /* history to debug policy */
123 struct ext4_mb_history *s_mb_history;
124 Index: linux-2.6.18.i386/fs/ext4/ext4.h
125 ===================================================================
126 --- linux-2.6.18.i386.orig/fs/ext4/ext4.h
127 +++ linux-2.6.18.i386/fs/ext4/ext4.h
128 @@ -992,6 +992,12 @@ struct mmp_struct {
130 #define EXT4_MMP_MIN_CHECK_INTERVAL 5
133 + * max directory size tunable
135 +#define EXT4_DEFAULT_MAX_DIR_SIZE 0
136 +#define EXT4_MAX_DIR_SIZE_NAME "max_dir_size"
139 * Function prototypes