Index: linux-2.6.18-194.3.1/fs/ext4/namei.c =================================================================== --- linux-2.6.18-194.3.1.orig/fs/ext4/namei.c +++ linux-2.6.18-194.3.1/fs/ext4/namei.c @@ -148,6 +148,17 @@ struct dx_map_entry u16 size; }; +/* + * dentry_param used by ext4_new_inode_wantedi() + */ +#define LVFS_DENTRY_PARAM_MAGIC 20070216UL +struct lvfs_dentry_params +{ + unsigned long ldp_inum; + unsigned long ldp_flags; + u32 ldp_magic; +}; + static inline ext4_lblk_t dx_get_block(struct dx_entry *entry); static void dx_set_block(struct dx_entry *entry, ext4_lblk_t value); static inline unsigned dx_get_hash(struct dx_entry *entry); @@ -1761,6 +1772,19 @@ static int ext4_add_nondir(handle_t *han return err; } +static unsigned ext4_dentry_goal(struct super_block *sb, struct dentry *dentry) +{ + unsigned inum = EXT4_SB(sb)->s_inode_goal; + + if (dentry->d_fsdata != NULL) { + struct lvfs_dentry_params *param = dentry->d_fsdata; + + if (param->ldp_magic == LVFS_DENTRY_PARAM_MAGIC) + inum = param->ldp_inum; + } + return inum; +} + /* * By the time this is called, we already have created * the directory cache entry for the new file, but it @@ -1786,7 +1810,8 @@ retry: if (IS_DIRSYNC(dir)) ext4_handle_sync(handle); - inode = ext4_new_inode(handle, dir, mode, &dentry->d_name, 0); + inode = ext4_new_inode(handle, dir, mode, &dentry->d_name, + ext4_dentry_goal(dir->i_sb, dentry)); err = PTR_ERR(inode); if (!IS_ERR(inode)) { inode->i_op = &ext4_file_inode_operations; @@ -1820,7 +1845,8 @@ retry: if (IS_DIRSYNC(dir)) ext4_handle_sync(handle); - inode = ext4_new_inode(handle, dir, mode, &dentry->d_name, 0); + inode = ext4_new_inode(handle, dir, mode, &dentry->d_name, + ext4_dentry_goal(dir->i_sb, dentry)); err = PTR_ERR(inode); if (!IS_ERR(inode)) { init_special_inode(inode, inode->i_mode, rdev); @@ -1857,8 +1883,8 @@ retry: if (IS_DIRSYNC(dir)) ext4_handle_sync(handle); - inode = ext4_new_inode(handle, dir, S_IFDIR | mode, - &dentry->d_name, 0); + inode = ext4_new_inode(handle, dir, S_IFDIR | mode, &dentry->d_name, + ext4_dentry_goal(dir->i_sb, dentry)); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out_stop; @@ -2270,8 +2296,8 @@ retry: if (IS_DIRSYNC(dir)) ext4_handle_sync(handle); - inode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO, - &dentry->d_name, 0); + inode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO, &dentry->d_name, + ext4_dentry_goal(dir->i_sb, dentry)); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out_stop;