Whamcloud - gitweb
LU-162 Export ext4_discard_preallocations for ldiskfs
[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,7 @@
164                 kmem_cache_free(ext4_ac_cachep, ac);
165  }
166 +EXPORT_SYMBOL(ext4_discard_preallocations); 
167  
168  /*
169   * finds all preallocated spaces and return blocks being freed to them
170   * if preallocated space becomes full (no block is used from the space)
171 @@ -5111,3 +5118,6 @@ error_return:
172                 kmem_cache_free(ext4_ac_cachep, ac);
173         return;
174  }
175 +
176 +EXPORT_SYMBOL(ext4_free_blocks);
177 +
178 Index: linux-stage/fs/ext4/ext4_jbd2.c
179 ===================================================================
180 --- linux-stage.orig/fs/ext4/ext4_jbd2.c        2011-03-14 17:17:57.463605024 +0800
181 +++ linux-stage/fs/ext4/ext4_jbd2.c     2011-03-14 17:18:00.157655139 +0800
182 @@ -31,6 +31,7 @@ int __ext4_journal_get_write_access(cons
183         }
184         return err;
185  }
186 +EXPORT_SYMBOL(__ext4_journal_get_write_access);
187  
188  int __ext4_journal_forget(const char *where, handle_t *handle,
189                                 struct buffer_head *bh)
190 @@ -107,3 +108,4 @@ int __ext4_journal_dirty_metadata(const
191         }
192         return err;
193  }
194 +EXPORT_SYMBOL(__ext4_handle_dirty_metadata);
195 Index: linux-stage/fs/ext4/ext4.h
196 ===================================================================
197 --- linux-stage.orig/fs/ext4/ext4.h     2011-03-14 17:17:59.916650654 +0800
198 +++ linux-stage/fs/ext4/ext4.h  2011-03-14 17:25:30.236089694 +0800
199 @@ -1448,6 +1448,8 @@
200  extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
201  extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
202                                                 ext4_group_t, int);
203 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
204 +
205  /* inode.c */
206  int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
207                 struct buffer_head *bh, ext4_fsblk_t blocknr);
208 Index: linux-stage/fs/ext4/inode.c
209 ===================================================================
210 --- linux-stage.orig/fs/ext4/inode.c    2011-03-14 17:17:59.745647471 +0800
211 +++ linux-stage/fs/ext4/inode.c 2011-03-14 17:18:00.219656294 +0800
212 @@ -4882,6 +4882,7 @@
213         iget_failed(inode);
214         return ERR_PTR(ret);
215  }
216 +EXPORT_SYMBOL(ext4_iget);
217  
218  static int ext4_inode_blocks_set(handle_t *handle,
219                                 struct ext4_inode *raw_inode,
220 Index: linux-stage/fs/ext4/super.c
221 ===================================================================
222 --- linux-stage.orig/fs/ext4/super.c    2011-03-14 17:17:59.659645870 +0800
223 +++ linux-stage/fs/ext4/super.c 2011-03-14 17:25:31.027104616 +0800
224 @@ -90,6 +90,7 @@ ext4_fsblk_t ext4_inode_bitmap(struct su
225                 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
226                  (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0);
227  }
228 +EXPORT_SYMBOL(ext4_inode_bitmap);
229  
230  ext4_fsblk_t ext4_inode_table(struct super_block *sb,
231                               struct ext4_group_desc *bg)
232 @@ -114,6 +115,7 @@
233                 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
234                  (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0);
235  }
236 +EXPORT_SYMBOL(ext4_itable_unused_count);
237  
238  __u32 ext4_used_dirs_count(struct super_block *sb,
239                               struct ext4_group_desc *bg)
240 @@ -1434,9 +1436,11 @@
241         Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
242         Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize,
243         Opt_usrquota, Opt_grpquota, Opt_i_version,
244 +       Opt_mballoc, Opt_extents,
245         Opt_stripe, Opt_delalloc, Opt_nodelalloc,
246         Opt_block_validity, Opt_noblock_validity,
247 -       Opt_inode_readahead_blks, Opt_journal_ioprio
248 +       Opt_inode_readahead_blks, Opt_journal_ioprio,
249 +       Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
250  };
251  
252  static match_table_t tokens = {
253 @@ -1491,6 +1495,11 @@
254         {Opt_barrier, "barrier"},
255         {Opt_nobarrier, "nobarrier"},
256         {Opt_i_version, "i_version"},
257 +       {Opt_mballoc, "mballoc"},
258 +       {Opt_extents, "extents"},
259 +       {Opt_iopen, "iopen"},
260 +       {Opt_noiopen, "noiopen"},
261 +       {Opt_iopen_nopriv, "iopen_nopriv"},
262         {Opt_stripe, "stripe=%u"},
263         {Opt_resize, "resize"},
264         {Opt_delalloc, "delalloc"},
265 @@ -1930,6 +1939,12 @@
266                         else
267                                 set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC);
268                         break;
269 +               case Opt_mballoc:
270 +               case Opt_extents:
271 +               case Opt_iopen:
272 +               case Opt_noiopen:
273 +               case Opt_iopen_nopriv:
274 +                       break;
275                 default:
276                         ext4_msg(sb, KERN_ERR,
277                                "Unrecognized mount option \"%s\" "
278 @@ -2480,7 +2495,7 @@
279                                               char *buf)
280  {
281         return snprintf(buf, PAGE_SIZE, "%llu\n",
282 -                       (s64) percpu_counter_sum(&sbi->s_dirtyblocks_counter));
283 +                       (unsigned long long) percpu_counter_sum(&sbi->s_dirtyblocks_counter));
284  }
285  
286  static ssize_t session_write_kbytes_show(struct ext4_attr *a,
287 @@ -2501,11 +2516,11 @@
288         struct super_block *sb = sbi->s_buddy_cache->i_sb;
289  
290         return snprintf(buf, PAGE_SIZE, "%llu\n",
291 -                       sbi->s_kbytes_written + 
292 +                       (unsigned long long)(sbi->s_kbytes_written + 
293                         (sb->s_bdev->bd_part ?
294                         (part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
295                           EXT4_SB(sb)->s_sectors_written_start) >> 1
296 -                       : 0));
297 +                       : 0)));
298  }
299  
300  static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
301 @@ -2972,7 +2987,7 @@
302         if (blocks_count && ext4_blocks_count(es) > blocks_count) {
303                 ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu "
304                        "exceeds size of device (%llu blocks)",
305 -                      ext4_blocks_count(es), blocks_count);
306 +                      ext4_blocks_count(es), (unsigned long long)blocks_count);
307                 goto failed_mount;
308         }
309  
310 Index: linux-stage/fs/ext4/fsync.c
311 ===================================================================
312 --- linux-stage.orig/fs/ext4/fsync.c    2011-03-14 17:17:57.533606303 +0800
313 +++ linux-stage/fs/ext4/fsync.c 2011-03-14 17:18:00.266657168 +0800
314 @@ -56,7 +56,7 @@
315  
316         trace_mark(ext4_sync_file, "dev %s datasync %d ino %ld parent %ld",
317                    inode->i_sb->s_id, datasync, inode->i_ino,
318 -                  dentry->d_parent->d_inode->i_ino);
319 +                  0L);
320  
321         ret = flush_aio_dio_completed_IO(inode);
322         if (ret < 0)
323 Index: linux-stage/fs/ext4/move_extent.c
324 ===================================================================
325 --- linux-stage.orig/fs/ext4/move_extent.c      2011-03-14 17:17:57.742610199 +0800
326 +++ linux-stage/fs/ext4/move_extent.c   2011-03-14 17:18:00.284657501 +0800
327 @@ -1388,7 +1388,8 @@
328                                 ext4_error(orig_inode->i_sb, __func__,
329                                         "We replaced blocks too much! "
330                                         "sum of replaced: %llu requested: %llu",
331 -                                       *moved_len, len);
332 +                                       (unsigned long long)(*moved_len),
333 +                                       (unsigned long long)(len));
334                                 ret1 = -EIO;
335                                 goto out;
336                         }