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
6 (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \
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
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()
26 +#define EXT4_ALLOC_NEEDED 0
27 +#define HAVE_EXT_PREPARE_CB_EXTENT
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)
35 +#define EXT4_EXT_HAS_NO_TREE /* ext4_extents_tree struct is not used*/
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,
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:
54 kmem_cache_free(ext4_ac_cachep, ac);
56 +EXPORT_SYMBOL(ext4_discard_preallocations);
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);
65 +EXPORT_SYMBOL(ext4_free_blocks);
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);
75 +EXPORT_SYMBOL(ext4_itable_unused_count);
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,
92 static const match_table_t tokens = {
93 @@ -1553,6 +1556,9 @@ static const match_table_t tokens = {
94 {Opt_noquota, "noquota"},
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"},
111 @@ -1925,6 +1932,10 @@ set_qf_format:
113 clear_opt(sbi->s_mount_opt, BARRIER);
117 + case Opt_iopen_nopriv:
122 @@ -2008,6 +2019,8 @@ set_qf_format:
124 clear_opt(sbi->s_mount_opt, DISCARD);
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
139 +EXPORT_SYMBOL(__ext4_journal_get_write_access);
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
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
154 #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
156 +/* Has been moved to linux/magic.h but we need it for Lustre */
157 +#define EXT4_SUPER_MAGIC 0xEF53
160 * Codes for operating systems
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 *,
166 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
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:
179 +EXPORT_SYMBOL(ext4_iget);
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
191 +EXPORT_SYMBOL(ext4_ext_walk_space);
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
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.
205 +int ext4_ext_calc_credits_for_insert(struct inode *inode,
206 + struct ext4_ext_path *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))
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.
225 + /* allocation of new data block(s) */
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
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)
239 + needed += (depth * 2) + (depth * 2);
241 + /* any allocation modifies superblock */
248 * How many index/leaf blocks need to change/allocate to modify nrblocks?
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
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);