1 Index: linux-stage/fs/ext4/ialloc.c
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/ialloc.c
4 +++ linux-stage/fs/ext4/ialloc.c
5 @@ -675,7 +675,8 @@ err_ret:
6 * For other inodes, search forward from the parent directory's block
7 * group to find a free inode.
9 -struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
10 +struct inode *ext4_new_inode_goal(handle_t *handle, struct inode *dir,
11 + int mode, unsigned goal)
13 struct super_block *sb;
14 struct buffer_head *inode_bitmap_bh = NULL;
15 @@ -706,6 +707,14 @@ struct inode *ext4_new_inode(handle_t *h
19 + if (goal && goal <= le32_to_cpu(es->s_inodes_count)) {
20 + group = (goal - 1) / EXT4_INODES_PER_GROUP(sb);
21 + ino = (goal - 1) % EXT4_INODES_PER_GROUP(sb);
27 if (sbi->s_log_groups_per_flex) {
28 ret2 = find_group_flex(sb, dir, &group);
30 @@ -724,7 +733,7 @@ got_group:
34 - for (i = 0; i < sbi->s_groups_count; i++) {
35 + for (i = 0; i < sbi->s_groups_count; i++, ino = 0) {
38 gdp = ext4_get_group_desc(sb, group, &group_desc_bh);
39 @@ -736,8 +745,6 @@ got_group:
46 ino = ext4_find_next_zero_bit((unsigned long *)
47 inode_bitmap_bh->b_data,
48 Index: linux-stage/fs/ext4/namei.c
49 ===================================================================
50 --- linux-stage.orig/fs/ext4/namei.c
51 +++ linux-stage/fs/ext4/namei.c
52 @@ -149,6 +149,17 @@ struct dx_map_entry
57 + * dentry_param used by ext4_new_inode_wantedi()
59 +#define LVFS_DENTRY_PARAM_MAGIC 20070216UL
60 +struct lvfs_dentry_params
62 + unsigned long ldp_inum;
63 + unsigned long ldp_flags;
67 static inline ext4_lblk_t dx_get_block(struct dx_entry *entry);
68 static void dx_set_block(struct dx_entry *entry, ext4_lblk_t value);
69 static inline unsigned dx_get_hash(struct dx_entry *entry);
70 @@ -1716,6 +1727,19 @@ static int ext4_add_nondir(handle_t *han
74 +static unsigned ext4_dentry_goal(struct super_block *sb, struct dentry *dentry)
76 + unsigned inum = EXT4_SB(sb)->s_inode_goal;
78 + if (dentry->d_fsdata != NULL) {
79 + struct lvfs_dentry_params *param = dentry->d_fsdata;
81 + if (param->ldp_magic == LVFS_DENTRY_PARAM_MAGIC)
82 + inum = param->ldp_inum;
88 * By the time this is called, we already have created
89 * the directory cache entry for the new file, but it
90 @@ -1741,7 +1766,8 @@ retry:
94 - inode = ext4_new_inode (handle, dir, mode);
95 + inode = ext4_new_inode_goal(handle, dir, mode,
96 + ext4_dentry_goal(dir->i_sb, dentry));
99 inode->i_op = &ext4_file_inode_operations;
100 @@ -1775,7 +1800,8 @@ retry:
104 - inode = ext4_new_inode(handle, dir, mode);
105 + inode = ext4_new_inode_goal(handle, dir, mode,
106 + ext4_dentry_goal(dir->i_sb, dentry));
107 err = PTR_ERR(inode);
108 if (!IS_ERR(inode)) {
109 init_special_inode(inode, inode->i_mode, rdev);
110 @@ -1811,7 +1836,8 @@ retry:
114 - inode = ext4_new_inode(handle, dir, S_IFDIR | mode);
115 + inode = ext4_new_inode_goal(handle, dir, S_IFDIR | mode,
116 + ext4_dentry_goal(dir->i_sb, dentry));
117 err = PTR_ERR(inode);
120 @@ -2211,7 +2236,8 @@ retry:
124 - inode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO);
125 + inode = ext4_new_inode_goal(handle, dir, S_IFLNK|S_IRWXUGO,
126 + ext4_dentry_goal(dir->i_sb, dentry));
127 err = PTR_ERR(inode);
130 Index: linux-stage/fs/ext4/ext4.h
131 ===================================================================
132 --- linux-stage.orig/fs/ext4/ext4.h
133 +++ linux-stage/fs/ext4/ext4.h
134 @@ -1032,7 +1032,14 @@ extern int ext4fs_dirhash(const char *na
135 dx_hash_info *hinfo);
138 -extern struct inode * ext4_new_inode(handle_t *, struct inode *, int);
139 +extern struct inode *ext4_new_inode_goal(handle_t *handle, struct inode *dir,
140 + int mode, unsigned goal);
141 +static inline struct inode *ext4_new_inode(handle_t *handle, struct inode *dir,
144 + return ext4_new_inode_goal(handle, dir, mode,
145 + EXT4_SB(dir->i_sb)->s_inode_goal);
147 extern void ext4_free_inode(handle_t *, struct inode *);
148 extern struct inode * ext4_orphan_get(struct super_block *, unsigned long);
149 extern unsigned long ext4_count_free_inodes(struct super_block *);
150 Index: linux-stage/fs/ext4/super.c
151 ===================================================================
152 --- linux-stage.orig/fs/ext4/super.c
153 +++ linux-stage/fs/ext4/super.c
154 @@ -560,6 +560,7 @@ static void ext4_put_super(struct super_
157 remove_proc_entry("inode_readahead_blks", sbi->s_proc);
158 + remove_proc_entry("inode_goal", sbi->s_proc);
159 remove_proc_entry(sb->s_id, ext4_proc_root);
162 @@ -2274,6 +2275,11 @@ static int ext4_fill_super(struct super_
163 p->proc_fops = &ext4_ui_proc_fops;
164 p->data = &sbi->s_inode_readahead_blks;
166 + p = create_proc_entry("inode_goal", 0644, sbi->s_proc);
168 + p->proc_fops = &ext4_ui_proc_fops,
169 + p->data = &sbi->s_inode_goal;
174 @@ -2553,6 +2558,7 @@ failed_mount2:
177 remove_proc_entry("inode_readahead_blks", sbi->s_proc);
178 + remove_proc_entry("inode_goal", sbi->s_proc);
179 remove_proc_entry(sb->s_id, ext4_proc_root);
182 Index: linux-stage/fs/ext4/ext4_sb.h
183 ===================================================================
184 --- linux-stage.orig/fs/ext4/ext4_sb.h
185 +++ linux-stage/fs/ext4/ext4_sb.h
186 @@ -53,6 +53,7 @@ struct ext4_sb_info {
189 unsigned int s_inode_readahead_blks;
190 + unsigned int s_inode_goal;
191 spinlock_t s_next_gen_lock;
192 u32 s_next_generation;