Whamcloud - gitweb
LU-73 RHEL6 support.
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-misc-rhel5.patch
1 Index: linux-stage/fs/ext4/ext4_jbd2.h
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/ext4_jbd2.h        2011-03-14 17:17:57.962614294 +0800
4 +++ linux-stage/fs/ext4/ext4_jbd2.h     2011-03-14 17:26:00.570661921 +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/extents.c
15 ===================================================================
16 --- linux-stage.orig/fs/ext4/extents.c  2011-03-14 17:17:57.491605523 +0800
17 +++ linux-stage/fs/ext4/extents.c       2011-03-14 17:25:23.230957562 +0800
18 @@ -59,6 +59,17 @@ static ext4_fsblk_t ext_pblock(struct ex
19  }
20  
21  /*
22 + * ext4_ext_store_pblock:
23 + * stores a large physical block number into an extent struct,
24 + * breaking it into parts
25 + */
26 +void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
27 +{
28 +       ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
29 +       ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
30 +}
31 +
32 +/*
33   * idx_pblock:
34   * combine low and high parts of a leaf physical block number into ext4_fsblk_t
35   */
36 @@ -72,17 +83,6 @@ ext4_fsblk_t idx_pblock(struct ext4_exte
37  }
38  
39  /*
40 - * ext4_ext_store_pblock:
41 - * stores a large physical block number into an extent struct,
42 - * breaking it into parts
43 - */
44 -void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
45 -{
46 -       ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
47 -       ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
48 -}
49 -
50 -/*
51   * ext4_idx_store_pblock:
52   * stores a large physical block number into an index struct,
53   * breaking it into parts
54 @@ -1980,6 +1980,56 @@ static int ext4_ext_rm_idx(handle_t *han
55  }
56  
57  /*
58 + * This routine returns max. credits extent tree can consume.
59 + * It should be OK for low-performance paths like ->writepage()
60 + * To allow many writing process to fit a single transaction,
61 + * caller should calculate credits under truncate_mutex and
62 + * pass actual path.
63 + */
64 +int ext4_ext_calc_credits_for_insert(struct inode *inode,
65 +                                   struct ext4_ext_path *path)
66 +{
67 +       int depth, needed;
68 +
69 +       if (path) {
70 +               /* probably there is space in leaf? */
71 +               depth = ext_depth(inode);
72 +               if (le16_to_cpu(path[depth].p_hdr->eh_entries)
73 +                               < le16_to_cpu(path[depth].p_hdr->eh_max))
74 +                       return 1;
75 +       }
76 +
77 +       /*
78 +        * given 32bit logical block (4294967296 blocks), max. tree
79 +        * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
80 +        * let's also add one more level for imbalance.
81 +        */
82 +       depth = 5;
83 +
84 +       /* allocation of new data block(s) */
85 +       needed = 2;
86 +
87 +       /*
88 +        * tree can be full, so it'd need to grow in depth:
89 +        * we need one credit to modify old root, credits for
90 +        * new root will be added in split accounting
91 +        */
92 +       needed += 1;
93 +
94 +       /*
95 +        * Index split can happen, we'd need:
96 +        *    allocate intermediate indexes (bitmap + group)
97 +        *  + change two blocks at each level, but root (already included)
98 +        */
99 +       needed += (depth * 2) + (depth * 2);
100 +
101 +       /* any allocation modifies superblock */
102 +       needed += 1;
103 +
104 +       return needed;
105 +}
106 +
107 +/*
108   * ext4_ext_calc_credits_for_single_extent:
109   * This routine returns max. credits that needed to insert an extent
110   * to the extent tree.
111 @@ -3731,3 +3781,13 @@ int ext4_fiemap(struct inode *inode, str
112         return error;
113  }
114  
115 +EXPORT_SYMBOL(ext4_ext_store_pblock);
116 +EXPORT_SYMBOL(ext4_ext_search_right);
117 +EXPORT_SYMBOL(ext4_ext_search_left);
118 +EXPORT_SYMBOL(ext_pblock);
119 +EXPORT_SYMBOL(ext4_ext_insert_extent);
120 +EXPORT_SYMBOL(ext4_mb_new_blocks);
121 +EXPORT_SYMBOL(ext4_ext_walk_space);
122 +EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
123 +EXPORT_SYMBOL(ext4_mark_inode_dirty);
124 +
125 Index: linux-stage/fs/ext4/ext4_extents.h
126 ===================================================================
127 --- linux-stage.orig/fs/ext4/ext4_extents.h     2011-03-14 17:17:57.928613657 +0800
128 +++ linux-stage/fs/ext4/ext4_extents.h  2011-03-14 17:27:23.673232962 +0800
129 @@ -58,6 +58,12 @@
130   */
131  #define EXT_STATS_
132  
133 +/*
134 + * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb
135 + * are now accounted in ext4_ext_calc_credits_for_insert()
136 + */
137 +#define EXT4_ALLOC_NEEDED 0
138 +#define HAVE_EXT_PREPARE_CB_EXTENT
139  
140  /*
141   * ext4_inode has i_block array (60 bytes total).
142 @@ -160,6 +166,7 @@ struct ext4_ext_path {
143  #define EXT_INIT_MAX_LEN       (1UL << 15)
144  #define EXT_UNINIT_MAX_LEN     (EXT_INIT_MAX_LEN - 1)
145  
146 +#define EXT4_EXT_HAS_NO_TREE  /* ext4_extents_tree struct is not used*/
147  
148  #define EXT_FIRST_EXTENT(__hdr__) \
149         ((struct ext4_extent *) (((char *) (__hdr__)) +         \
150 @@ -230,6 +237,8 @@
151  extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
152  extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
153  extern int ext4_extent_tree_init(handle_t *, struct inode *);
154 +extern int ext4_ext_calc_credits_for_insert(struct inode *,
155 +                                           struct ext4_ext_path *);
156  extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
157                                                    int num,
158                                                    struct ext4_ext_path *path);
159 Index: linux-stage/fs/ext4/mballoc.c
160 ===================================================================
161 --- linux-stage.orig/fs/ext4/mballoc.c  2011-03-14 17:17:59.872649833 +0800
162 +++ linux-stage/fs/ext4/mballoc.c       2011-03-14 17:25:20.373903681 +0800
163 @@ -4302,6 +4302,13 @@
164                 kmem_cache_free(ext4_ac_cachep, ac);
165  }
166  
167 +/* For backward compatibility, since Lustre uses this symbol */
168 +void ext4_mb_discard_inode_preallocations(struct inode *inode)
169 +{
170 +       ext4_discard_preallocations(inode);
171 +}
172 +EXPORT_SYMBOL(ext4_mb_discard_inode_preallocations);
173 +
174  /*
175   * finds all preallocated spaces and return blocks being freed to them
176   * if preallocated space becomes full (no block is used from the space)
177 @@ -5111,3 +5118,6 @@ error_return:
178                 kmem_cache_free(ext4_ac_cachep, ac);
179         return;
180  }
181 +
182 +EXPORT_SYMBOL(ext4_free_blocks);
183 +
184 Index: linux-stage/fs/ext4/ext4_jbd2.c
185 ===================================================================
186 --- linux-stage.orig/fs/ext4/ext4_jbd2.c        2011-03-14 17:17:57.463605024 +0800
187 +++ linux-stage/fs/ext4/ext4_jbd2.c     2011-03-14 17:18:00.157655139 +0800
188 @@ -31,6 +31,7 @@ int __ext4_journal_get_write_access(cons
189         }
190         return err;
191  }
192 +EXPORT_SYMBOL(__ext4_journal_get_write_access);
193  
194  int __ext4_journal_forget(const char *where, handle_t *handle,
195                                 struct buffer_head *bh)
196 @@ -107,3 +108,4 @@ int __ext4_journal_dirty_metadata(const
197         }
198         return err;
199  }
200 +EXPORT_SYMBOL(__ext4_handle_dirty_metadata);
201 Index: linux-stage/fs/ext4/ext4.h
202 ===================================================================
203 --- linux-stage.orig/fs/ext4/ext4.h     2011-03-14 17:17:59.916650654 +0800
204 +++ linux-stage/fs/ext4/ext4.h  2011-03-14 17:25:30.236089694 +0800
205 @@ -1448,6 +1448,8 @@
206  extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
207  extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
208                                                 ext4_group_t, int);
209 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
210 +
211  /* inode.c */
212  int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
213                 struct buffer_head *bh, ext4_fsblk_t blocknr);
214 Index: linux-stage/fs/ext4/inode.c
215 ===================================================================
216 --- linux-stage.orig/fs/ext4/inode.c    2011-03-14 17:17:59.745647471 +0800
217 +++ linux-stage/fs/ext4/inode.c 2011-03-14 17:18:00.219656294 +0800
218 @@ -4882,6 +4882,7 @@
219         iget_failed(inode);
220         return ERR_PTR(ret);
221  }
222 +EXPORT_SYMBOL(ext4_iget);
223  
224  static int ext4_inode_blocks_set(handle_t *handle,
225                                 struct ext4_inode *raw_inode,
226 Index: linux-stage/fs/ext4/super.c
227 ===================================================================
228 --- linux-stage.orig/fs/ext4/super.c    2011-03-14 17:17:59.659645870 +0800
229 +++ linux-stage/fs/ext4/super.c 2011-03-14 17:25:31.027104616 +0800
230 @@ -90,6 +90,7 @@ ext4_fsblk_t ext4_inode_bitmap(struct su
231                 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
232                  (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0);
233  }
234 +EXPORT_SYMBOL(ext4_inode_bitmap);
235  
236  ext4_fsblk_t ext4_inode_table(struct super_block *sb,
237                               struct ext4_group_desc *bg)
238 @@ -114,6 +115,7 @@
239                 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
240                  (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0);
241  }
242 +EXPORT_SYMBOL(ext4_itable_unused_count);
243  
244  __u32 ext4_used_dirs_count(struct super_block *sb,
245                               struct ext4_group_desc *bg)
246 @@ -1434,9 +1436,11 @@
247         Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
248         Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize,
249         Opt_usrquota, Opt_grpquota, Opt_i_version,
250 +       Opt_mballoc, Opt_extents,
251         Opt_stripe, Opt_delalloc, Opt_nodelalloc,
252         Opt_block_validity, Opt_noblock_validity,
253 -       Opt_inode_readahead_blks, Opt_journal_ioprio
254 +       Opt_inode_readahead_blks, Opt_journal_ioprio,
255 +       Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
256  };
257  
258  static match_table_t tokens = {
259 @@ -1491,6 +1495,11 @@
260         {Opt_barrier, "barrier"},
261         {Opt_nobarrier, "nobarrier"},
262         {Opt_i_version, "i_version"},
263 +       {Opt_mballoc, "mballoc"},
264 +       {Opt_extents, "extents"},
265 +       {Opt_iopen, "iopen"},
266 +       {Opt_noiopen, "noiopen"},
267 +       {Opt_iopen_nopriv, "iopen_nopriv"},
268         {Opt_stripe, "stripe=%u"},
269         {Opt_resize, "resize"},
270         {Opt_delalloc, "delalloc"},
271 @@ -1930,6 +1939,12 @@
272                         else
273                                 set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC);
274                         break;
275 +               case Opt_mballoc:
276 +               case Opt_extents:
277 +               case Opt_iopen:
278 +               case Opt_noiopen:
279 +               case Opt_iopen_nopriv:
280 +                       break;
281                 default:
282                         ext4_msg(sb, KERN_ERR,
283                                "Unrecognized mount option \"%s\" "
284 @@ -2480,7 +2495,7 @@
285                                               char *buf)
286  {
287         return snprintf(buf, PAGE_SIZE, "%llu\n",
288 -                       (s64) percpu_counter_sum(&sbi->s_dirtyblocks_counter));
289 +                       (unsigned long long) percpu_counter_sum(&sbi->s_dirtyblocks_counter));
290  }
291  
292  static ssize_t session_write_kbytes_show(struct ext4_attr *a,
293 @@ -2501,11 +2516,11 @@
294         struct super_block *sb = sbi->s_buddy_cache->i_sb;
295  
296         return snprintf(buf, PAGE_SIZE, "%llu\n",
297 -                       sbi->s_kbytes_written + 
298 +                       (unsigned long long)(sbi->s_kbytes_written + 
299                         (sb->s_bdev->bd_part ?
300                         (part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
301                           EXT4_SB(sb)->s_sectors_written_start) >> 1
302 -                       : 0));
303 +                       : 0)));
304  }
305  
306  static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
307 @@ -2972,7 +2987,7 @@
308         if (blocks_count && ext4_blocks_count(es) > blocks_count) {
309                 ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu "
310                        "exceeds size of device (%llu blocks)",
311 -                      ext4_blocks_count(es), blocks_count);
312 +                      ext4_blocks_count(es), (unsigned long long)blocks_count);
313                 goto failed_mount;
314         }
315  
316 Index: linux-stage/fs/ext4/fsync.c
317 ===================================================================
318 --- linux-stage.orig/fs/ext4/fsync.c    2011-03-14 17:17:57.533606303 +0800
319 +++ linux-stage/fs/ext4/fsync.c 2011-03-14 17:18:00.266657168 +0800
320 @@ -56,7 +56,7 @@
321  
322         trace_mark(ext4_sync_file, "dev %s datasync %d ino %ld parent %ld",
323                    inode->i_sb->s_id, datasync, inode->i_ino,
324 -                  dentry->d_parent->d_inode->i_ino);
325 +                  0L);
326  
327         ret = flush_aio_dio_completed_IO(inode);
328         if (ret < 0)
329 Index: linux-stage/fs/ext4/move_extent.c
330 ===================================================================
331 --- linux-stage.orig/fs/ext4/move_extent.c      2011-03-14 17:17:57.742610199 +0800
332 +++ linux-stage/fs/ext4/move_extent.c   2011-03-14 17:18:00.284657501 +0800
333 @@ -1388,7 +1388,8 @@
334                                 ext4_error(orig_inode->i_sb, __func__,
335                                         "We replaced blocks too much! "
336                                         "sum of replaced: %llu requested: %llu",
337 -                                       *moved_len, len);
338 +                                       (unsigned long long)(*moved_len),
339 +                                       (unsigned long long)(len));
340                                 ret1 = -EIO;
341                                 goto out;
342                         }