Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / alloc-policy-2.6-rhlel5.diff
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:
5         return ERR_PTR(err);
6  }
7  
8 +unsigned long ext3_find_reverse(struct super_block *sb)
9 +{
10 +       struct ext3_group_desc *desc;
11 +       struct buffer_head *bitmap_bh = NULL;
12 +       int group;
13 +       unsigned long ino, offset;
14 +
15 +       for (offset = (EXT3_INODES_PER_GROUP(sb) >> 1); offset >= 0;
16 +            offset >>= 1) {
17 +               for (group = EXT3_SB(sb)->s_groups_count - 1; group >= 0;
18 +                    --group) {
19 +                       desc = ext3_get_group_desc(sb, group, NULL);
20 +                       if (desc->bg_free_inodes_count == 0)
21 +                               continue;
22 +
23 +                       bitmap_bh = read_inode_bitmap(sb, group);
24 +                       if (!bitmap_bh)
25 +                               continue;
26 +
27 +                       ino = ext3_find_next_zero_bit((unsigned long *)
28 +                                       bitmap_bh->b_data,
29 +                                       EXT3_INODES_PER_GROUP(sb), offset);
30 +                       if (ino < EXT3_INODES_PER_GROUP(sb))
31 +                               return(group * EXT3_INODES_PER_GROUP(sb) +
32 +                                      ino + 1);
33 +               }
34 +       }
35 +       return 0;
36 +}
37 +
38  /* Verify that we are loading a valid orphan from disk */
39  struct inode *ext3_orphan_get(struct super_block *sb, unsigned long ino)
40  {
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
45         u32 offs;
46  };
47  
48 +/*
49 + * dentry_param used by ext3_new_inode_wantedi()
50 + */
51  #define LVFS_DENTRY_PARAM_MAGIC                20070216UL
52  struct lvfs_dentry_params
53  {
54 -       unsigned long   p_inum;
55 -       void            *p_ptr; 
56 -       u32             magic;
57 +       unsigned long   ldp_inum;
58 +       long            ldp_flags;
59 +       u32             ldp_magic;
60  };
61  
62 +/* Only use the least 3 bits of ldp_flags for goal policy */
63 +typedef enum {
64 +       DP_GOAL_POLICY       = 0,
65 +       DP_LASTGROUP_REVERSE = 1,
66 +} dp_policy_t;
67 +
68 +#define LDP_FLAGS_RANGE 0x07
69 +
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;
76  
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;
85 +                }
86         }
87         return ext3_new_inode(handle, dir, mode, inum);
88  }
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
93  /* ialloc.c */
94  extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
95                                       unsigned long);
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 *);