Whamcloud - gitweb
b481aca32b2c6c889988fdf0d6d1dd28aef1dce2
[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
4 +++ linux-stage/fs/ext4/ext4_jbd2.h
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
17 +++ linux-stage/fs/ext4/extents.c
18 @@ -59,6 +59,17 @@ ext4_fsblk_t ext_pblock(struct ext4_exte
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 @@ -2097,6 +2097,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 @@ -3941,3 +3991,15 @@ 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 +EXPORT_SYMBOL(ext4_ext_find_extent);
125 +EXPORT_SYMBOL(ext4_ext_drop_refs);
126 +
127 Index: linux-stage/fs/ext4/ext4_extents.h
128 ===================================================================
129 --- linux-stage.orig/fs/ext4/ext4_extents.h
130 +++ linux-stage/fs/ext4/ext4_extents.h
131 @@ -58,6 +58,12 @@
132   */
133  #define EXT_STATS_
134  
135 +/*
136 + * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb
137 + * are now accounted in ext4_ext_calc_credits_for_insert()
138 + */
139 +#define EXT4_ALLOC_NEEDED 0
140 +#define HAVE_EXT_PREPARE_CB_EXTENT
141  
142  /*
143   * ext4_inode has i_block array (60 bytes total).
144 @@ -160,6 +166,7 @@ typedef int (*ext_prepare_callback)(stru
145  #define EXT_INIT_MAX_LEN       (1UL << 15)
146  #define EXT_UNINIT_MAX_LEN     (EXT_INIT_MAX_LEN - 1)
147  
148 +#define EXT4_EXT_HAS_NO_TREE  /* ext4_extents_tree struct is not used*/
149  
150  #define EXT_FIRST_EXTENT(__hdr__) \
151         ((struct ext4_extent *) (((char *) (__hdr__)) +         \
152 @@ -231,6 +238,8 @@ extern ext4_fsblk_t ext_pblock(struct ex
153  extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
154  extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
155  extern int ext4_extent_tree_init(handle_t *, struct inode *);
156 +extern int ext4_ext_calc_credits_for_insert(struct inode *,
157 +                                           struct ext4_ext_path *);
158  extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
159                                                    int num,
160                                                    struct ext4_ext_path *path);
161 Index: linux-stage/fs/ext4/mballoc.c
162 ===================================================================
163 --- linux-stage.orig/fs/ext4/mballoc.c
164 +++ linux-stage/fs/ext4/mballoc.c
165 @@ -4313,6 +4313,7 @@ repeat:
166         if (ac)
167                 kmem_cache_free(ext4_ac_cachep, ac);
168  }
169 +EXPORT_SYMBOL(ext4_discard_preallocations); 
170  
171  /*
172   * finds all preallocated spaces and return blocks being freed to them
173 @@ -5127,3 +5128,6 @@ error_return:
174                 kmem_cache_free(ext4_ac_cachep, ac);
175         return;
176  }
177 +
178 +EXPORT_SYMBOL(ext4_free_blocks);
179 +
180 Index: linux-stage/fs/ext4/ext4_jbd2.c
181 ===================================================================
182 --- linux-stage.orig/fs/ext4/ext4_jbd2.c
183 +++ linux-stage/fs/ext4/ext4_jbd2.c
184 @@ -31,6 +31,7 @@ int __ext4_journal_get_write_access(cons
185         }
186         return err;
187  }
188 +EXPORT_SYMBOL(__ext4_journal_get_write_access);
189  
190  int __ext4_journal_forget(const char *where, handle_t *handle,
191                                 struct buffer_head *bh)
192 @@ -107,3 +108,4 @@ int __ext4_handle_dirty_metadata(const c
193         }
194         return err;
195  }
196 +EXPORT_SYMBOL(__ext4_handle_dirty_metadata);
197 Index: linux-stage/fs/ext4/ext4.h
198 ===================================================================
199 --- linux-stage.orig/fs/ext4/ext4.h
200 +++ linux-stage/fs/ext4/ext4.h
201 @@ -1528,6 +1528,8 @@ extern int ext4_mb_add_groupinfo(struct 
202  extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
203  extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
204                                                 ext4_group_t, int);
205 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
206 +
207  /* inode.c */
208  int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
209                 struct buffer_head *bh, ext4_fsblk_t blocknr);
210 Index: linux-stage/fs/ext4/inode.c
211 ===================================================================
212 --- linux-stage.orig/fs/ext4/inode.c
213 +++ linux-stage/fs/ext4/inode.c
214 @@ -5078,6 +5078,7 @@ bad_inode:
215         iget_failed(inode);
216         return ERR_PTR(ret);
217  }
218 +EXPORT_SYMBOL(ext4_iget);
219  
220  static int ext4_inode_blocks_set(handle_t *handle,
221                                 struct ext4_inode *raw_inode,
222 Index: linux-stage/fs/ext4/super.c
223 ===================================================================
224 --- linux-stage.orig/fs/ext4/super.c
225 +++ linux-stage/fs/ext4/super.c
226 @@ -90,6 +90,7 @@ ext4_fsblk_t ext4_inode_bitmap(struct su
227                 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
228                  (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0);
229  }
230 +EXPORT_SYMBOL(ext4_inode_bitmap);
231  
232  ext4_fsblk_t ext4_inode_table(struct super_block *sb,
233                               struct ext4_group_desc *bg)
234 @@ -114,6 +115,7 @@ __u32 ext4_free_inodes_count(struct supe
235                 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
236                  (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0);
237  }
238 +EXPORT_SYMBOL(ext4_itable_unused_count);
239  
240  __u32 ext4_used_dirs_count(struct super_block *sb,
241                               struct ext4_group_desc *bg)
242 @@ -1489,9 +1491,11 @@ enum {
243         Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
244         Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize,
245         Opt_usrquota, Opt_grpquota, Opt_i_version,
246 +       Opt_mballoc, Opt_extents,
247         Opt_stripe, Opt_delalloc, Opt_nodelalloc,
248         Opt_block_validity, Opt_noblock_validity,
249 -       Opt_inode_readahead_blks, Opt_journal_ioprio
250 +       Opt_inode_readahead_blks, Opt_journal_ioprio,
251 +       Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
252  };
253  
254  static match_table_t tokens = {
255 @@ -1547,6 +1551,11 @@ static match_table_t tokens = {
256         {Opt_barrier, "barrier"},
257         {Opt_nobarrier, "nobarrier"},
258         {Opt_i_version, "i_version"},
259 +       {Opt_mballoc, "mballoc"},
260 +       {Opt_extents, "extents"},
261 +       {Opt_iopen, "iopen"},
262 +       {Opt_noiopen, "noiopen"},
263 +       {Opt_iopen_nopriv, "iopen_nopriv"},
264         {Opt_stripe, "stripe=%u"},
265         {Opt_resize, "resize"},
266         {Opt_delalloc, "delalloc"},
267 @@ -1993,6 +2002,12 @@ set_qf_format:
268                         else
269                                 set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC);
270                         break;
271 +               case Opt_mballoc:
272 +               case Opt_extents:
273 +               case Opt_iopen:
274 +               case Opt_noiopen:
275 +               case Opt_iopen_nopriv:
276 +                       break;
277                 default:
278                         ext4_msg(sb, KERN_ERR,
279                                "Unrecognized mount option \"%s\" "
280 @@ -2543,7 +2558,7 @@ static ssize_t delayed_allocation_blocks
281                                               char *buf)
282  {
283         return snprintf(buf, PAGE_SIZE, "%llu\n",
284 -                       (s64) percpu_counter_sum(&sbi->s_dirtyblocks_counter));
285 +                       (unsigned long long) percpu_counter_sum(&sbi->s_dirtyblocks_counter));
286  }
287  
288  static ssize_t session_write_kbytes_show(struct ext4_attr *a,
289 @@ -2564,11 +2579,11 @@ static ssize_t lifetime_write_kbytes_sho
290         struct super_block *sb = sbi->s_buddy_cache->i_sb;
291  
292         return snprintf(buf, PAGE_SIZE, "%llu\n",
293 -                       sbi->s_kbytes_written + 
294 +                       (unsigned long long)(sbi->s_kbytes_written + 
295                         (sb->s_bdev->bd_part ?
296                         (part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
297                           EXT4_SB(sb)->s_sectors_written_start) >> 1
298 -                       : 0));
299 +                       : 0)));
300  }
301  
302  static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
303 @@ -3042,7 +3057,7 @@ static int ext4_fill_super(struct super_
304         if (blocks_count && ext4_blocks_count(es) > blocks_count) {
305                 ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu "
306                        "exceeds size of device (%llu blocks)",
307 -                      ext4_blocks_count(es), blocks_count);
308 +                      ext4_blocks_count(es), (unsigned long long)blocks_count);
309                 goto failed_mount;
310         }
311  
312 Index: linux-stage/fs/ext4/fsync.c
313 ===================================================================
314 --- linux-stage.orig/fs/ext4/fsync.c
315 +++ linux-stage/fs/ext4/fsync.c
316 @@ -61,7 +61,7 @@ int ext4_sync_file(struct file *file, st
317  
318         trace_mark(ext4_sync_file, "dev %s datasync %d ino %ld parent %ld",
319                    inode->i_sb->s_id, datasync, inode->i_ino,
320 -                  dentry->d_parent->d_inode->i_ino);
321 +                  0L);
322  
323         ret = flush_aio_dio_completed_IO(inode);
324         if (ret < 0)
325 Index: linux-stage/fs/ext4/move_extent.c
326 ===================================================================
327 --- linux-stage.orig/fs/ext4/move_extent.c
328 +++ linux-stage/fs/ext4/move_extent.c
329 @@ -1358,7 +1358,8 @@ ext4_move_extents(struct file *o_filp, s
330                                 ext4_error(orig_inode->i_sb,
331                                         "We replaced blocks too much! "
332                                         "sum of replaced: %llu requested: %llu",
333 -                                       *moved_len, len);
334 +                                       (unsigned long long)(*moved_len),
335 +                                       (unsigned long long)(len));
336                                 ret1 = -EIO;
337                                 break;
338                         }