1 diff -Nrpu /tmp/linux-stage/fs/ext3/ialloc.c linux-stage/fs/ext3/ialloc.c
2 --- /tmp/linux-stage/fs/ext3/ialloc.c 2009-05-09 06:44:02.000000000 +0400
3 +++ linux-stage/fs/ext3/ialloc.c 2009-05-09 06:45:33.000000000 +0400
4 @@ -822,6 +822,36 @@ fail_drop:
8 +unsigned long ext3_find_reverse(struct super_block *sb)
10 + struct ext3_group_desc *desc;
11 + struct buffer_head *bitmap_bh = NULL;
13 + unsigned long ino, offset;
15 + for (offset = (EXT3_INODES_PER_GROUP(sb) >> 1); offset >= 0;
17 + for (group = EXT3_SB(sb)->s_groups_count - 1; group >= 0;
19 + desc = ext3_get_group_desc(sb, group, NULL);
20 + if (desc->bg_free_inodes_count == 0)
23 + bitmap_bh = read_inode_bitmap(sb, group);
27 + ino = ext3_find_next_zero_bit((unsigned long *)
29 + EXT3_INODES_PER_GROUP(sb), offset);
30 + if (ino < EXT3_INODES_PER_GROUP(sb))
31 + return(group * EXT3_INODES_PER_GROUP(sb) +
38 /* Verify that we are loading a valid orphan from disk */
39 struct inode *ext3_orphan_get(struct super_block *sb, unsigned long ino)
41 diff -Nrpu /tmp/linux-stage/fs/ext3/namei.c linux-stage/fs/ext3/namei.c
42 --- /tmp/linux-stage/fs/ext3/namei.c 2009-05-09 06:44:02.000000000 +0400
43 +++ linux-stage/fs/ext3/namei.c 2009-05-09 06:45:33.000000000 +0400
44 @@ -145,14 +145,25 @@ struct dx_map_entry
49 + * dentry_param used by ext3_new_inode_wantedi()
51 #define LVFS_DENTRY_PARAM_MAGIC 20070216UL
52 struct lvfs_dentry_params
54 - unsigned long p_inum;
57 + unsigned long ldp_inum;
62 +/* Only use the least 3 bits of ldp_flags for goal policy */
65 + DP_LASTGROUP_REVERSE = 1,
68 +#define LDP_FLAGS_RANGE 0x07
70 #ifdef CONFIG_EXT3_INDEX
71 static inline unsigned dx_get_block (struct dx_entry *entry);
72 static void dx_set_block (struct dx_entry *entry, unsigned value);
73 @@ -1718,8 +1727,13 @@ static struct inode * ext3_new_inode_wan
74 if (dentry->d_fsdata != NULL) {
75 struct lvfs_dentry_params *param = dentry->d_fsdata;
77 - if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
78 - inum = param->p_inum;
79 + if (param->ldp_magic == LVFS_DENTRY_PARAM_MAGIC) {
80 + if ((dp_policy_t)(param->ldp_flags & LDP_FLAGS_RANGE) ==
81 + DP_LASTGROUP_REVERSE)
82 + inum = ext3_find_reverse(dir->i_sb);
83 + else /* DP_GOAL_POLICY */
84 + inum = param->ldp_inum;
87 return ext3_new_inode(handle, dir, mode, inum);
89 diff -Nrpu /tmp/linux-stage/include/linux/ext3_fs.h linux-stage/include/linux/ext3_fs.h
90 --- /tmp/linux-stage/include/linux/ext3_fs.h 2009-05-09 06:44:02.000000000 +0400
91 +++ linux-stage/include/linux/ext3_fs.h 2009-05-09 06:45:33.000000000 +0400
92 @@ -973,6 +973,7 @@ extern int ext3fs_dirhash(const char *na
94 extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
96 +extern unsigned long ext3_find_reverse(struct super_block *);
97 extern void ext3_free_inode (handle_t *, struct inode *);
98 extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
99 extern unsigned long ext3_count_free_inodes (struct super_block *);