1 Index: linux-2.6.5-7.314/fs/ext3/ialloc.c
2 ===================================================================
3 --- linux-2.6.5-7.314.orig/fs/ext3/ialloc.c
4 +++ linux-2.6.5-7.314/fs/ext3/ialloc.c
5 @@ -520,12 +520,15 @@ struct inode *ext3_new_inode(handle_t *h
6 return ERR_PTR(-EPERM);
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);
21 group = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
22 Index: linux-2.6.5-7.314/fs/ext3/super.c
23 ===================================================================
24 --- linux-2.6.5-7.314.orig/fs/ext3/super.c
25 +++ linux-2.6.5-7.314/fs/ext3/super.c
31 + * max directory size tunable
33 +#define EXT3_DEFAULT_MAX_DIR_SIZE 0
34 +#define EXT3_MAX_DIR_SIZE_NAME "max_dir_size"
36 static int ext3_load_journal(struct super_block *, struct ext3_super_block *,
37 unsigned long journal_devnum);
38 static int ext3_create_journal(struct super_block *, struct ext3_super_block *,
39 @@ -431,6 +437,7 @@ void ext3_put_super (struct super_block
40 invalidate_bdev(sbi->journal_bdev, 0);
41 ext3_blkdev_remove(sbi);
43 + remove_proc_entry(EXT3_MAX_DIR_SIZE_NAME, sbi->s_dev_proc);
44 if (sbi->s_dev_proc) {
45 remove_proc_entry(sbi->s_dev_proc->name, proc_root_ext3);
46 sbi->s_dev_proc = NULL;
47 @@ -1253,6 +1260,45 @@ static unsigned long descriptor_loc(stru
48 return (first_data_block + has_super + (bg * sbi->s_blocks_per_group));
51 +static int ext3_max_dir_size_read(char *page, char **start, off_t off,
52 + int count, int *eof, void *data)
54 + struct ext3_sb_info *sbi = data;
61 + len = sprintf(page, "%lu\n", sbi->s_max_dir_size);
66 +static int ext3_max_dir_size_write(struct file *file, const char *buffer,
67 + unsigned long count, void *data)
69 + struct ext3_sb_info *sbi = data;
71 + unsigned long value;
74 + if (count >= sizeof(str)) {
75 + printk(KERN_ERR "EXT3-fs: %s string too long, max %u bytes\n",
76 + EXT3_MAX_DIR_SIZE_NAME, (int)sizeof(str));
80 + if (copy_from_user(str, buffer, count))
83 + value = simple_strtol(str, &end, 0);
87 + sbi->s_max_dir_size = value;
91 static int ext3_fill_super (struct super_block *sb, void *data, int silent)
93 @@ -1273,6 +1319,7 @@ static int ext3_fill_super (struct super
97 + struct proc_dir_entry *proc;
99 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
101 @@ -1299,6 +1346,23 @@ static int ext3_fill_super (struct super
105 + sbi->s_max_dir_size = EXT3_DEFAULT_MAX_DIR_SIZE;
106 + proc = create_proc_entry(EXT3_MAX_DIR_SIZE_NAME,
107 + S_IFREG | S_IRUGO | S_IWUSR, sbi->s_dev_proc);
108 + if (proc == NULL) {
109 + printk(KERN_ERR "EXT3-fs: unable to create %s\n",
110 + EXT3_MAX_DIR_SIZE_NAME);
111 + remove_proc_entry(EXT3_MAX_DIR_SIZE_NAME, sbi->s_dev_proc);
112 + remove_proc_entry(sb->s_id, proc_root_ext3);
113 + sbi->s_dev_proc = NULL;
114 + sb->s_fs_info = NULL;
119 + proc->read_proc = ext3_max_dir_size_read;
120 + proc->write_proc = ext3_max_dir_size_write;
122 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE);
124 printk(KERN_ERR "EXT3-fs: unable to set blocksize\n");
125 @@ -1713,6 +1777,7 @@ failed_mount:
126 ext3_blkdev_remove(sbi);
129 + remove_proc_entry(EXT3_MAX_DIR_SIZE_NAME, sbi->s_dev_proc);
130 if (sbi->s_dev_proc) {
131 remove_proc_entry(sbi->s_dev_proc->name, proc_root_ext3);
132 sbi->s_dev_proc = NULL;
133 Index: linux-2.6.5-7.314/include/linux/ext3_fs_sb.h
134 ===================================================================
135 --- linux-2.6.5-7.314.orig/include/linux/ext3_fs_sb.h
136 +++ linux-2.6.5-7.314/include/linux/ext3_fs_sb.h
137 @@ -119,6 +119,8 @@ struct ext3_sb_info {
138 unsigned long s_mb_last_group;
139 unsigned long s_mb_last_start;
141 + unsigned long s_max_dir_size;
143 /* history to debug policy */
144 struct ext3_mb_history *s_mb_history;
145 int s_mb_history_cur;