Whamcloud - gitweb
85376770a46b884405013eefb3ec98da0ce3a20a
[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
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/ext4_extents.h
15 ===================================================================
16 --- linux-stage.orig/fs/ext4/ext4_extents.h
17 +++ linux-stage/fs/ext4/ext4_extents.h
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 @@ typedef int (*ext_prepare_callback)(stru
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 @@ extern int ext4_extent_tree_init(handle_
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
51 +++ linux-stage/fs/ext4/mballoc.c
52 @@ -4039,6 +4039,7 @@ repeat:
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 @@ error_return:
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
70 +++ linux-stage/fs/ext4/super.c
71 @@ -127,6 +127,7 @@ __u32 ext4_itable_unused_count(struct su
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 @@ -1497,11 +1498,13 @@ enum {
80         Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
81         Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
82         Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
83 +       Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
84         Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version,
85         Opt_stripe, Opt_delalloc, Opt_nodelalloc,
86         Opt_block_validity, Opt_noblock_validity,
87         Opt_inode_readahead_blks, Opt_journal_ioprio,
88         Opt_discard, Opt_nodiscard,
89 +       Opt_mballoc,
90  };
91  
92  static const match_table_t tokens = {
93 @@ -1553,6 +1556,9 @@ static const match_table_t tokens = {
94         {Opt_noquota, "noquota"},
95         {Opt_quota, "quota"},
96         {Opt_usrquota, "usrquota"},
97 +       {Opt_iopen, "iopen"},
98 +       {Opt_noiopen, "noiopen"},
99 +       {Opt_iopen_nopriv, "iopen_nopriv"},
100         {Opt_barrier, "barrier=%u"},
101         {Opt_barrier, "barrier"},
102         {Opt_nobarrier, "nobarrier"},
103 @@ -1568,6 +1574,7 @@ static const match_table_t tokens = {
104         {Opt_auto_da_alloc, "auto_da_alloc=%u"},
105         {Opt_auto_da_alloc, "auto_da_alloc"},
106         {Opt_noauto_da_alloc, "noauto_da_alloc"},
107 +       {Opt_mballoc, "mballoc"},
108         {Opt_discard, "discard"},
109         {Opt_nodiscard, "nodiscard"},
110         {Opt_err, NULL},
111 @@ -1925,6 +1932,10 @@ set_qf_format:
112                         else
113                                 clear_opt(sbi->s_mount_opt, BARRIER);
114                         break;
115 +               case Opt_iopen:
116 +               case Opt_noiopen:
117 +               case Opt_iopen_nopriv:
118 +                       break;
119                 case Opt_ignore:
120                         break;
121                 case Opt_resize:
122 @@ -2008,6 +2019,8 @@ set_qf_format:
123                 case Opt_nodiscard:
124                         clear_opt(sbi->s_mount_opt, DISCARD);
125                         break;
126 +               case Opt_mballoc:
127 +                       break;
128                 default:
129                         ext4_msg(sb, KERN_ERR,
130                                "Unrecognized mount option \"%s\" "
131 Index: linux-stage/fs/ext4/ext4_jbd2.c
132 ===================================================================
133 --- linux-stage.orig/fs/ext4/ext4_jbd2.c
134 +++ linux-stage/fs/ext4/ext4_jbd2.c
135 @@ -31,6 +31,7 @@ int __ext4_journal_get_write_access(cons
136         }
137         return err;
138  }
139 +EXPORT_SYMBOL(__ext4_journal_get_write_access);
140  
141  int __ext4_journal_forget(const char *where, handle_t *handle,
142                                 struct buffer_head *bh)
143 @@ -107,3 +108,4 @@ int __ext4_handle_dirty_metadata(const c
144         }
145         return err;
146  }
147 +EXPORT_SYMBOL(__ext4_handle_dirty_metadata);
148 Index: linux-stage/fs/ext4/ext4.h
149 ===================================================================
150 --- linux-stage.orig/fs/ext4/ext4.h
151 +++ linux-stage/fs/ext4/ext4.h
152 @@ -1110,6 +1110,9 @@ static inline void ext4_clear_inode_stat
153  
154  #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
155  
156 +/* Has been moved to linux/magic.h but we need it for Lustre */
157 +#define EXT4_SUPER_MAGIC       0xEF53
158 +
159  /*
160   * Codes for operating systems
161   */
162 @@ -1539,6 +1542,8 @@ extern int ext4_mb_add_groupinfo(struct 
163  extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
164  extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
165                                                 ext4_group_t, int);
166 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
167 +
168  /* inode.c */
169  int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
170                 struct buffer_head *bh, ext4_fsblk_t blocknr);
171 Index: linux-stage/fs/ext4/inode.c
172 ===================================================================
173 --- linux-stage.orig/fs/ext4/inode.c
174 +++ linux-stage/fs/ext4/inode.c
175 @@ -5204,6 +5204,7 @@ bad_inode:
176         iget_failed(inode);
177         return ERR_PTR(ret);
178  }
179 +EXPORT_SYMBOL(ext4_iget);
180  
181  static int ext4_inode_blocks_set(handle_t *handle,
182                                 struct ext4_inode *raw_inode,
183 Index: linux-stage/fs/ext4/extents.c
184 ===================================================================
185 --- linux-stage.orig/fs/ext4/extents.c
186 +++ linux-stage/fs/ext4/extents.c
187 @@ -1965,6 +1965,7 @@ int ext4_ext_walk_space(struct inode *in
188  
189         return err;
190  }
191 +EXPORT_SYMBOL(ext4_ext_walk_space);
192  
193  static void
194  ext4_ext_put_in_cache(struct inode *inode, ext4_lblk_t block,
195 @@ -2133,6 +2134,55 @@ int ext4_ext_calc_credits_for_single_ext
196  }
197  
198  /*
199 + * This routine returns max. credits extent tree can consume.
200 + * It should be OK for low-performance paths like ->writepage()
201 + * To allow many writing process to fit a single transaction,
202 + * caller should calculate credits under truncate_mutex and
203 + * pass actual path.
204 + */
205 +int ext4_ext_calc_credits_for_insert(struct inode *inode,
206 +                                    struct ext4_ext_path *path)
207 +{
208 +       int depth, needed;
209 +
210 +       if (path) {
211 +               /* probably there is space in leaf? */
212 +               depth = ext_depth(inode);
213 +               if (le16_to_cpu(path[depth].p_hdr->eh_entries)
214 +                               < le16_to_cpu(path[depth].p_hdr->eh_max))
215 +                       return 1;
216 +       }
217 +
218 +       /*
219 +        * given 32bit logical block (4294967296 blocks), max. tree
220 +        * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
221 +        * let's also add one more level for imbalance.
222 +        */
223 +       depth = 5;
224 +
225 +       /* allocation of new data block(s) */
226 +       needed = 2;
227 +
228 +       /*
229 +        * tree can be full, so it'd need to grow in depth:
230 +        * we need one credit to modify old root, credits for
231 +        * new root will be added in split accounting
232 +        */
233 +       needed += 1;
234 +       /*
235 +        * Index split can happen, we'd need:
236 +        *    allocate intermediate indexes (bitmap + group)
237 +        *  + change two blocks at each level, but root (already included)
238 +        */
239 +       needed += (depth * 2) + (depth * 2);
240 +
241 +       /* any allocation modifies superblock */
242 +       needed += 1;
243 +
244 +       return needed;
245 +}
246 +
247 +/*
248   * How many index/leaf blocks need to change/allocate to modify nrblocks?
249   *
250   * if nrblocks are fit in a single extent (chunk flag is 1), then
251 @@ -3941,3 +3991,12 @@ int ext4_fiemap(struct inode *inode, str
252         return error;
253  }
254  
255 +EXPORT_SYMBOL(ext4_ext_store_pblock);
256 +EXPORT_SYMBOL(ext4_ext_search_right);
257 +EXPORT_SYMBOL(ext4_ext_search_left);
258 +EXPORT_SYMBOL(ext_pblock);
259 +EXPORT_SYMBOL(ext4_ext_insert_extent);
260 +EXPORT_SYMBOL(ext4_mb_new_blocks);
261 +EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
262 +EXPORT_SYMBOL(ext4_mark_inode_dirty);
263 +