Whamcloud - gitweb
allocate inodes for llog files in last inodes group, for avoid broking
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / alloc-policy-2.6-rhlel5.diff
1 diff -rp ldiskfs/linux-stage/fs/ext3/ialloc.c ldiskfs.new/linux-stage/fs/ext3/ialloc.c
2 *** linux-stage/fs/ext3/ialloc.c        2009-04-10 08:44:23.000000000 +0300
3 --- linux-stage/fs/ext3/ialloc.c        2009-04-10 08:39:37.000000000 +0300
4 *************** fail_drop:
5 *** 821,826 ****
6 --- 821,856 ----
7         return ERR_PTR(err);
8   }
9   
10 + unsigned long ext3_find_reverse(struct super_block *sb)
11 + {
12 +       struct ext3_group_desc *desc;
13 +       struct buffer_head *bitmap_bh = NULL;
14 +       int group;
15 +       unsigned long ino, offset;
16
17 +       for (offset = (EXT3_INODES_PER_GROUP(sb) >> 1); offset >= 0;
18 +            offset >>= 1) {
19 +               for (group = EXT3_SB(sb)->s_groups_count - 1; group >= 0;
20 +                    --group) {
21 +                       desc = ext3_get_group_desc(sb, group, NULL);
22 +                       if (desc->bg_free_inodes_count == 0)
23 +                               continue;
24
25 +                       bitmap_bh = read_inode_bitmap(sb, group);
26 +                       if (!bitmap_bh)
27 +                               continue;
28
29 +                       ino = ext3_find_next_zero_bit((unsigned long *)
30 +                                       bitmap_bh->b_data,
31 +                                       EXT3_INODES_PER_GROUP(sb), offset);
32 +                       if (ino < EXT3_INODES_PER_GROUP(sb))
33 +                               return(group * EXT3_INODES_PER_GROUP(sb) +
34 +                                      ino + 1);
35 +               }
36 +       }
37 +       return 0;
38 + }
39
40   /* Verify that we are loading a valid orphan from disk */
41   struct inode *ext3_orphan_get(struct super_block *sb, unsigned long ino)
42   {
43 diff -rp ldiskfs/linux-stage/fs/ext3/namei.c ldiskfs.new/linux-stage/fs/ext3/namei.c
44 *** linux-stage/fs/ext3/namei.c 2009-04-10 08:44:23.000000000 +0300
45 --- linux-stage/fs/ext3/namei.c 2009-04-10 08:39:37.000000000 +0300
46 *************** struct dx_map_entry
47 *** 146,159 ****
48         u16 size;
49   };
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   };
58   
59   #ifdef CONFIG_EXT3_INDEX
60   static inline unsigned dx_get_block (struct dx_entry *entry);
61   static void dx_set_block (struct dx_entry *entry, unsigned value);
62 --- 146,168 ----
63         u16 size;
64   };
65   
66 + /*
67 +  * dentry_param used by ext3_new_inode_wantedi()
68 +  */
69   #define LVFS_DENTRY_PARAM_MAGIC               20070216UL
70   struct lvfs_dentry_params
71   {
72 !       unsigned long   ldp_inum;
73 !       long            ldp_flags;
74 !       u32             ldp_magic;
75   };
76   
77 + /* Only use the least 3 bits of ldp_flags for goal policy */
78 + typedef enum {
79 +       DP_GOAL_POLICY       = 0,
80 +       DP_LASTGROUP_REVERSE = 1,
81 + } dp_policy_t;
82
83   #ifdef CONFIG_EXT3_INDEX
84   static inline unsigned dx_get_block (struct dx_entry *entry);
85   static void dx_set_block (struct dx_entry *entry, unsigned value);
86 *************** static struct inode * ext3_new_inode_wan
87 *** 1752,1759 ****
88         if (dentry->d_fsdata != NULL) {
89                 struct lvfs_dentry_params *param = dentry->d_fsdata;
90   
91 !               if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
92 !                       inum = param->p_inum;
93         }
94         return ext3_new_inode(handle, dir, mode, inum);
95   }
96 --- 1761,1773 ----
97         if (dentry->d_fsdata != NULL) {
98                 struct lvfs_dentry_params *param = dentry->d_fsdata;
99   
100 !               if (param->ldp_magic == LVFS_DENTRY_PARAM_MAGIC) {
101 !                       if ((dp_policy_t)(param->ldp_flags & 0x7) ==
102 !                           DP_LASTGROUP_REVERSE)
103 !                               inum = ext3_find_reverse(dir->i_sb);
104 !                         else /* DP_GOAL_POLICY */
105 !                               inum = param->ldp_inum;
106 !                 }
107         }
108         return ext3_new_inode(handle, dir, mode, inum);
109   }
110 diff -rp ldiskfs/linux-stage/include/linux/ext3_fs.h ldiskfs.new/linux-stage/include/linux/ext3_fs.h
111 *** linux-stage/include/linux/ext3_fs.h 2009-04-10 08:44:23.000000000 +0300
112 --- linux-stage/include/linux/ext3_fs.h 2009-04-10 08:39:37.000000000 +0300
113 *************** extern int ext3fs_dirhash(const char *na
114 *** 977,982 ****
115 --- 977,983 ----
116   /* ialloc.c */
117   extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
118                                       unsigned long);
119 + extern unsigned long ext3_find_reverse(struct super_block *);
120   extern void ext3_free_inode (handle_t *, struct inode *);
121   extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
122   extern unsigned long ext3_count_free_inodes (struct super_block *);