1 diff -pur linux-stage.orig/fs/ext3/ialloc.c linux-stage/fs/ext3/ialloc.c
2 --- linux-stage.orig/fs/ext3/ialloc.c 2008-06-01 16:18:53.000000000 +0800
3 +++ linux-stage/fs/ext3/ialloc.c 2008-06-03 02:21:02.000000000 +0800
4 @@ -519,12 +519,15 @@ struct inode *ext3_new_inode(handle_t *h
5 return ERR_PTR(-EPERM);
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 group = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
21 diff -pur linux-stage.orig/fs/ext3/super.c linux-stage/fs/ext3/super.c
22 --- linux-stage.orig/fs/ext3/super.c 2008-06-03 01:53:34.000000000 +0800
23 +++ linux-stage/fs/ext3/super.c 2008-06-03 19:39:19.000000000 +0800
29 + * max directory size tunable
31 +#define EXT3_DEFAULT_MAX_DIR_SIZE 0
32 +#define EXT3_MAX_DIR_SIZE_NAME "max_dir_size"
34 static int ext3_load_journal(struct super_block *, struct ext3_super_block *,
35 unsigned long journal_devnum);
36 static int ext3_create_journal(struct super_block *, struct ext3_super_block *,
37 @@ -446,6 +452,7 @@ void ext3_put_super (struct super_block
39 kthread_stop(sbi->s_mmp_tsk);
41 + remove_proc_entry(EXT3_MAX_DIR_SIZE_NAME, sbi->s_dev_proc);
42 remove_proc_entry(sb->s_id, proc_root_ext3);
43 sbi->s_dev_proc = NULL;
45 @@ -1765,6 +1772,45 @@ failed:
49 +static int ext3_max_dir_size_read(char *page, char **start, off_t off,
50 + int count, int *eof, void *data)
52 + struct ext3_sb_info *sbi = data;
59 + len = sprintf(page, "%lu\n", sbi->s_max_dir_size);
64 +static int ext3_max_dir_size_write(struct file *file, const char *buffer,
65 + unsigned long count, void *data)
67 + struct ext3_sb_info *sbi = data;
69 + unsigned long value;
72 + if (count >= sizeof(str)) {
73 + printk(KERN_ERR "EXT3-fs: %s string too long, max %u bytes\n",
74 + EXT3_MAX_DIR_SIZE_NAME, (int)sizeof(str));
78 + if (copy_from_user(str, buffer, count))
81 + value = simple_strtol(str, &end, 0);
85 + sbi->s_max_dir_size = value;
89 static int ext3_fill_super (struct super_block *sb, void *data, int silent)
91 @@ -1785,6 +1831,7 @@ static int ext3_fill_super (struct super
95 + struct proc_dir_entry *proc;
97 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
99 @@ -1802,6 +1849,23 @@ static int ext3_fill_super (struct super
103 + sbi->s_max_dir_size = EXT3_DEFAULT_MAX_DIR_SIZE;
104 + proc = create_proc_entry(EXT3_MAX_DIR_SIZE_NAME,
105 + S_IFREG | S_IRUGO | S_IWUSR, sbi->s_dev_proc);
106 + if (proc == NULL) {
107 + printk(KERN_ERR "EXT3-fs: unable to create %s\n",
108 + EXT3_MAX_DIR_SIZE_NAME);
109 + remove_proc_entry(EXT3_MAX_DIR_SIZE_NAME, sbi->s_dev_proc);
110 + remove_proc_entry(sb->s_id, proc_root_ext3);
111 + sbi->s_dev_proc = NULL;
112 + sb->s_fs_info = NULL;
117 + proc->read_proc = ext3_max_dir_size_read;
118 + proc->write_proc = ext3_max_dir_size_write;
120 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE);
122 printk(KERN_ERR "EXT3-fs: unable to set blocksize\n");
123 @@ -2224,6 +2288,7 @@ failed_mount:
124 ext3_blkdev_remove(sbi);
127 + remove_proc_entry(EXT3_MAX_DIR_SIZE_NAME, sbi->s_dev_proc);
128 remove_proc_entry(sb->s_id, proc_root_ext3);
129 sbi->s_dev_proc = NULL;
130 sb->s_fs_info = NULL;
131 diff -pur linux-stage.orig/include/linux/ext3_fs_sb.h linux-stage/include/linux/ext3_fs_sb.h
132 --- linux-stage.orig/include/linux/ext3_fs_sb.h 2008-06-01 16:18:54.000000000 +0800
133 +++ linux-stage/include/linux/ext3_fs_sb.h 2008-06-03 02:21:02.000000000 +0800
134 @@ -114,6 +114,7 @@ struct ext3_sb_info {
135 unsigned long s_mb_max_groups_to_scan;
136 unsigned long s_mb_stats;
137 unsigned long s_mb_order2_reqs;
138 + unsigned long s_max_dir_size;
140 /* history to debug policy */
141 struct ext3_mb_history *s_mb_history;