Whamcloud - gitweb
LU-73 RHEL6 support.
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-misc-rhel6.patch
1 Index: linux-stage/fs/ext4/ext4_jbd2.h
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/ext4_jbd2.h        2011-03-14 16:33:17.087088010 +0800
4 +++ linux-stage/fs/ext4/ext4_jbd2.h     2011-03-14 16:42:28.416591789 +0800
5 @@ -35,6 +35,8 @@
6         (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)   \
7          ? 27U : 8U)
8  
9 +#define ext4_journal_dirty_metadata(handle, bh)  \
10 +               ext4_handle_dirty_metadata(handle, NULL, bh)
11  /* Extended attribute operations touch at most two data buffers,
12   * two bitmap buffers, and two group summaries, in addition to the inode
13   * and the superblock, which are already accounted for. */
14 Index: linux-stage/fs/ext4/ext4_extents.h
15 ===================================================================
16 --- linux-stage.orig/fs/ext4/ext4_extents.h     2011-03-14 16:33:17.076087785 +0800
17 +++ linux-stage/fs/ext4/ext4_extents.h  2011-03-14 16:43:08.254267525 +0800
18 @@ -58,6 +58,12 @@
19   */
20  #define EXT_STATS_
21  
22 +/*
23 + * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb
24 + * are now accounted in ext4_ext_calc_credits_for_insert()
25 + */
26 +#define EXT4_ALLOC_NEEDED 0
27 +#define HAVE_EXT_PREPARE_CB_EXTENT
28  
29  /*
30   * ext4_inode has i_block array (60 bytes total).
31 @@ -160,6 +166,7 @@
32  #define EXT_INIT_MAX_LEN       (1UL << 15)
33  #define EXT_UNINIT_MAX_LEN     (EXT_INIT_MAX_LEN - 1)
34  
35 +#define EXT4_EXT_HAS_NO_TREE   /* ext4_extents_tree struct is not used*/
36  
37  #define EXT_FIRST_EXTENT(__hdr__) \
38         ((struct ext4_extent *) (((char *) (__hdr__)) +         \
39 @@ -239,6 +246,8 @@
40  extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
41                                                    int num,
42                                                    struct ext4_ext_path *path);
43 +extern int ext4_ext_calc_credits_for_insert(struct inode *,
44 +                                           struct ext4_ext_path *);
45  extern int ext4_can_extents_be_merged(struct inode *inode,
46                                       struct ext4_extent *ex1,
47                                       struct ext4_extent *ex2);
48 Index: linux-stage/fs/ext4/mballoc.c
49 ===================================================================
50 --- linux-stage.orig/fs/ext4/mballoc.c  2011-03-14 16:33:27.072292006 +0800
51 +++ linux-stage/fs/ext4/mballoc.c       2011-03-14 16:41:02.500138039 +0800
52 @@ -4039,6 +4039,7 @@
53         if (ac)
54                 kmem_cache_free(ext4_ac_cachep, ac);
55  }
56 +EXPORT_SYMBOL(ext4_discard_preallocations);
57  
58  /*
59   * finds all preallocated spaces and return blocks being freed to them
60 @@ -4831,3 +4832,6 @@
61                 kmem_cache_free(ext4_ac_cachep, ac);
62         return;
63  }
64 +
65 +EXPORT_SYMBOL(ext4_free_blocks);
66 +
67 Index: linux-stage/fs/ext4/super.c
68 ===================================================================
69 --- linux-stage.orig/fs/ext4/super.c    2011-03-14 16:33:17.036086967 +0800
70 +++ linux-stage/fs/ext4/super.c 2011-03-14 16:41:14.964348396 +0800
71 @@ -127,6 +127,7 @@
72                 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
73                  (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0);
74  }
75 +EXPORT_SYMBOL(ext4_itable_unused_count);
76  
77  void ext4_block_bitmap_set(struct super_block *sb,
78                            struct ext4_group_desc *bg, ext4_fsblk_t blk)
79 @@ -1491,6 +1492,7 @@
80         Opt_block_validity, Opt_noblock_validity,
81         Opt_inode_readahead_blks, Opt_journal_ioprio,
82         Opt_discard, Opt_nodiscard,
83 +       Opt_mballoc,
84  };
85  
86  static const match_table_t tokens = {
87 @@ -1557,6 +1559,7 @@
88         {Opt_auto_da_alloc, "auto_da_alloc=%u"},
89         {Opt_auto_da_alloc, "auto_da_alloc"},
90         {Opt_noauto_da_alloc, "noauto_da_alloc"},
91 +       {Opt_mballoc, "mballoc"},
92         {Opt_discard, "discard"},
93         {Opt_nodiscard, "nodiscard"},
94         {Opt_err, NULL},
95 @@ -1997,6 +2000,8 @@
96                 case Opt_nodiscard:
97                         clear_opt(sbi->s_mount_opt, DISCARD);
98                         break;
99 +               case Opt_mballoc:
100 +                       break;
101                 default:
102                         ext4_msg(sb, KERN_ERR,
103                                "Unrecognized mount option \"%s\" "
104 Index: linux-stage/fs/ext4/ext4_jbd2.c
105 ===================================================================
106 --- linux-stage.orig/fs/ext4/ext4_jbd2.c        2011-03-14 16:33:17.049087232 +0800
107 +++ linux-stage/fs/ext4/ext4_jbd2.c     2011-03-14 16:34:39.849759386 +0800
108 @@ -31,6 +31,7 @@
109         }
110         return err;
111  }
112 +EXPORT_SYMBOL(__ext4_journal_get_write_access);
113  
114  int __ext4_journal_forget(const char *where, handle_t *handle,
115                                 struct buffer_head *bh)
116 @@ -107,3 +108,4 @@
117         }
118         return err;
119  }
120 +EXPORT_SYMBOL(__ext4_handle_dirty_metadata);
121 Index: linux-stage/fs/ext4/ext4.h
122 ===================================================================
123 --- linux-stage.orig/fs/ext4/ext4.h     2011-03-14 16:33:17.056087375 +0800
124 +++ linux-stage/fs/ext4/ext4.h  2011-03-14 16:45:40.754870806 +0800
125 @@ -1110,6 +1110,9 @@
126  
127  #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
128  
129 +/* Has been moved to linux/magic.h but we need it for Lustre */
130 +#define EXT4_SUPER_MAGIC       0xEF53
131 +
132  /*
133   * Codes for operating systems
134   */
135 @@ -1528,6 +1531,8 @@
136  extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
137  extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
138                                                 ext4_group_t, int);
139 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
140 +
141  /* inode.c */
142  int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
143                 struct buffer_head *bh, ext4_fsblk_t blocknr);
144 Index: linux-stage/fs/ext4/inode.c
145 ===================================================================
146 --- linux-stage.orig/fs/ext4/inode.c    2011-03-14 16:33:17.063087519 +0800
147 +++ linux-stage/fs/ext4/inode.c 2011-03-14 16:34:39.913760434 +0800
148 @@ -5199,6 +5199,7 @@
149         iget_failed(inode);
150         return ERR_PTR(ret);
151  }
152 +EXPORT_SYMBOL(ext4_iget);
153  
154  static int ext4_inode_blocks_set(handle_t *handle,
155                                 struct ext4_inode *raw_inode,
156 Index: linux-stage/fs/ext4/extents.c
157 ===================================================================
158 --- linux-stage.orig/fs/ext4/extents.c  2011-03-14 16:33:17.070087661 +0800
159 +++ linux-stage/fs/ext4/extents.c       2011-03-14 16:41:04.894178430 +0800
160 @@ -1866,9 +1866,7 @@
161         while (block < last && block != EXT_MAX_BLOCK) {
162                 num = last - block;
163                 /* find extent for this block */
164 -               down_read(&EXT4_I(inode)->i_data_sem);
165                 path = ext4_ext_find_extent(inode, block, path);
166 -               up_read(&EXT4_I(inode)->i_data_sem);
167                 if (IS_ERR(path)) {
168                         err = PTR_ERR(path);
169                         path = NULL;
170 @@ -1965,6 +1963,7 @@
171  
172         return err;
173  }
174 +EXPORT_SYMBOL(ext4_ext_walk_space);
175  
176  static void
177  ext4_ext_put_in_cache(struct inode *inode, ext4_lblk_t block,
178 @@ -2133,6 +2132,55 @@
179  }
180  
181  /*
182 + * This routine returns max. credits extent tree can consume.
183 + * It should be OK for low-performance paths like ->writepage()
184 + * To allow many writing process to fit a single transaction,
185 + * caller should calculate credits under truncate_mutex and
186 + * pass actual path.
187 + */
188 +int ext4_ext_calc_credits_for_insert(struct inode *inode,
189 +                                    struct ext4_ext_path *path)
190 +{
191 +       int depth, needed;
192 +
193 +       if (path) {
194 +               /* probably there is space in leaf? */
195 +               depth = ext_depth(inode);
196 +               if (le16_to_cpu(path[depth].p_hdr->eh_entries)
197 +                               < le16_to_cpu(path[depth].p_hdr->eh_max))
198 +                       return 1;
199 +       }
200 +
201 +       /*
202 +        * given 32bit logical block (4294967296 blocks), max. tree
203 +        * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
204 +        * let's also add one more level for imbalance.
205 +        */
206 +       depth = 5;
207 +
208 +       /* allocation of new data block(s) */
209 +       needed = 2;
210 +
211 +       /*
212 +        * tree can be full, so it'd need to grow in depth:
213 +        * we need one credit to modify old root, credits for
214 +        * new root will be added in split accounting
215 +        */
216 +       needed += 1;
217 +       /*
218 +        * Index split can happen, we'd need:
219 +        *    allocate intermediate indexes (bitmap + group)
220 +        *  + change two blocks at each level, but root (already included)
221 +        */
222 +       needed += (depth * 2) + (depth * 2);
223 +
224 +       /* any allocation modifies superblock */
225 +       needed += 1;
226 +
227 +       return needed;
228 +}
229 +
230 +/*
231   * How many index/leaf blocks need to change/allocate to modify nrblocks?
232   *
233   * if nrblocks are fit in a single extent (chunk flag is 1), then
234 @@ -3934,10 +3982,21 @@
235                  * Walk the extent tree gathering extent information.
236                  * ext4_ext_fiemap_cb will push extents back to user.
237                  */
238 +               down_read(&EXT4_I(inode)->i_data_sem);
239                 error = ext4_ext_walk_space(inode, start_blk, len_blks,
240                                           ext4_ext_fiemap_cb, fieinfo);
241 +               up_read(&EXT4_I(inode)->i_data_sem);
242         }
243  
244         return error;
245  }
246  
247 +EXPORT_SYMBOL(ext4_ext_store_pblock);
248 +EXPORT_SYMBOL(ext4_ext_search_right);
249 +EXPORT_SYMBOL(ext4_ext_search_left);
250 +EXPORT_SYMBOL(ext_pblock);
251 +EXPORT_SYMBOL(ext4_ext_insert_extent);
252 +EXPORT_SYMBOL(ext4_mb_new_blocks);
253 +EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
254 +EXPORT_SYMBOL(ext4_mark_inode_dirty);
255 +