1 Index: linux-stage/fs/ext4/ext4_jbd2.h
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/ext4_jbd2.h 2011-03-14 16:33:17.087088010 +0800
4 +++ linux-stage/fs/ext4/ext4_jbd2.h 2011-03-14 16:42:28.416591789 +0800
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 2011-03-14 16:33:17.076087785 +0800
17 +++ linux-stage/fs/ext4/ext4_extents.h 2011-03-14 16:43:08.254267525 +0800
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).
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__)) + \
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 2011-03-14 16:33:27.072292006 +0800
51 +++ linux-stage/fs/ext4/mballoc.c 2011-03-14 16:41:02.500138039 +0800
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
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 2011-03-14 16:33:17.036086967 +0800
70 +++ linux-stage/fs/ext4/super.c 2011-03-14 16:41:14.964348396 +0800
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)
80 Opt_block_validity, Opt_noblock_validity,
81 Opt_inode_readahead_blks, Opt_journal_ioprio,
82 Opt_discard, Opt_nodiscard,
86 static const match_table_t tokens = {
88 {Opt_auto_da_alloc, "auto_da_alloc=%u"},
89 {Opt_auto_da_alloc, "auto_da_alloc"},
90 {Opt_noauto_da_alloc, "noauto_da_alloc"},
91 + {Opt_mballoc, "mballoc"},
92 {Opt_discard, "discard"},
93 {Opt_nodiscard, "nodiscard"},
97 clear_opt(sbi->s_mount_opt, DISCARD);
102 ext4_msg(sb, KERN_ERR,
103 "Unrecognized mount option \"%s\" "
104 Index: linux-stage/fs/ext4/ext4_jbd2.c
105 ===================================================================
106 --- linux-stage.orig/fs/ext4/ext4_jbd2.c 2011-03-14 16:33:17.049087232 +0800
107 +++ linux-stage/fs/ext4/ext4_jbd2.c 2011-03-14 16:34:39.849759386 +0800
112 +EXPORT_SYMBOL(__ext4_journal_get_write_access);
114 int __ext4_journal_forget(const char *where, handle_t *handle,
115 struct buffer_head *bh)
120 +EXPORT_SYMBOL(__ext4_handle_dirty_metadata);
121 Index: linux-stage/fs/ext4/ext4.h
122 ===================================================================
123 --- linux-stage.orig/fs/ext4/ext4.h 2011-03-14 16:33:17.056087375 +0800
124 +++ linux-stage/fs/ext4/ext4.h 2011-03-14 16:45:40.754870806 +0800
125 @@ -1110,6 +1110,9 @@
127 #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
129 +/* Has been moved to linux/magic.h but we need it for Lustre */
130 +#define EXT4_SUPER_MAGIC 0xEF53
133 * Codes for operating systems
135 @@ -1528,6 +1531,8 @@
136 extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
137 extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
139 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
142 int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
143 struct buffer_head *bh, ext4_fsblk_t blocknr);
144 Index: linux-stage/fs/ext4/inode.c
145 ===================================================================
146 --- linux-stage.orig/fs/ext4/inode.c 2011-03-14 16:33:17.063087519 +0800
147 +++ linux-stage/fs/ext4/inode.c 2011-03-14 16:34:39.913760434 +0800
148 @@ -5199,6 +5199,7 @@
152 +EXPORT_SYMBOL(ext4_iget);
154 static int ext4_inode_blocks_set(handle_t *handle,
155 struct ext4_inode *raw_inode,
156 Index: linux-stage/fs/ext4/extents.c
157 ===================================================================
158 --- linux-stage.orig/fs/ext4/extents.c 2011-03-14 16:33:17.070087661 +0800
159 +++ linux-stage/fs/ext4/extents.c 2011-03-14 16:41:04.894178430 +0800
160 @@ -1866,9 +1866,7 @@
161 while (block < last && block != EXT_MAX_BLOCK) {
163 /* find extent for this block */
164 - down_read(&EXT4_I(inode)->i_data_sem);
165 path = ext4_ext_find_extent(inode, block, path);
166 - up_read(&EXT4_I(inode)->i_data_sem);
170 @@ -1965,6 +1963,7 @@
174 +EXPORT_SYMBOL(ext4_ext_walk_space);
177 ext4_ext_put_in_cache(struct inode *inode, ext4_lblk_t block,
178 @@ -2133,6 +2132,55 @@
182 + * This routine returns max. credits extent tree can consume.
183 + * It should be OK for low-performance paths like ->writepage()
184 + * To allow many writing process to fit a single transaction,
185 + * caller should calculate credits under truncate_mutex and
186 + * pass actual path.
188 +int ext4_ext_calc_credits_for_insert(struct inode *inode,
189 + struct ext4_ext_path *path)
194 + /* probably there is space in leaf? */
195 + depth = ext_depth(inode);
196 + if (le16_to_cpu(path[depth].p_hdr->eh_entries)
197 + < le16_to_cpu(path[depth].p_hdr->eh_max))
202 + * given 32bit logical block (4294967296 blocks), max. tree
203 + * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
204 + * let's also add one more level for imbalance.
208 + /* allocation of new data block(s) */
212 + * tree can be full, so it'd need to grow in depth:
213 + * we need one credit to modify old root, credits for
214 + * new root will be added in split accounting
218 + * Index split can happen, we'd need:
219 + * allocate intermediate indexes (bitmap + group)
220 + * + change two blocks at each level, but root (already included)
222 + needed += (depth * 2) + (depth * 2);
224 + /* any allocation modifies superblock */
231 * How many index/leaf blocks need to change/allocate to modify nrblocks?
233 * if nrblocks are fit in a single extent (chunk flag is 1), then
234 @@ -3934,10 +3982,21 @@
235 * Walk the extent tree gathering extent information.
236 * ext4_ext_fiemap_cb will push extents back to user.
238 + down_read(&EXT4_I(inode)->i_data_sem);
239 error = ext4_ext_walk_space(inode, start_blk, len_blks,
240 ext4_ext_fiemap_cb, fieinfo);
241 + up_read(&EXT4_I(inode)->i_data_sem);
247 +EXPORT_SYMBOL(ext4_ext_store_pblock);
248 +EXPORT_SYMBOL(ext4_ext_search_right);
249 +EXPORT_SYMBOL(ext4_ext_search_left);
250 +EXPORT_SYMBOL(ext_pblock);
251 +EXPORT_SYMBOL(ext4_ext_insert_extent);
252 +EXPORT_SYMBOL(ext4_mb_new_blocks);
253 +EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
254 +EXPORT_SYMBOL(ext4_mark_inode_dirty);