+++ /dev/null
-Index: linux-stage/fs/ext4/ext4.h
-===================================================================
---- linux-stage.orig/fs/ext4/ext4.h 2011-05-20 10:59:32.000000000 +0300
-+++ linux-stage/fs/ext4/ext4.h 2011-05-20 11:01:06.000000000 +0300
-@@ -1630,6 +1633,9 @@ extern void ext4_mb_put_buddy_cache_lock
- ext4_group_t, int);
- extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
-
-+extern void ext4_mb_discard_inode_preallocations(struct inode *);
-+
-+
- /* inode.c */
- int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
- struct buffer_head *bh, ext4_fsblk_t blocknr);
-Index: linux-stage/fs/ext4/ext4_extents.h
-===================================================================
---- linux-stage.orig/fs/ext4/ext4_extents.h 2011-05-20 10:59:30.000000000 +0300
-+++ linux-stage/fs/ext4/ext4_extents.h 2011-05-20 11:00:01.000000000 +0300
-@@ -58,6 +58,12 @@
- */
- #define EXT_STATS_
-
-+/*
-+ * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb
-+ * are now accounted in ext4_ext_calc_credits_for_insert()
-+ */
-+#define EXT4_ALLOC_NEEDED 0
-+#define HAVE_EXT_PREPARE_CB_EXTENT
-
- /*
- * ext4_inode has i_block array (60 bytes total).
-@@ -239,6 +245,8 @@ extern int ext4_extent_tree_init(handle_
- extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
- int num,
- struct ext4_ext_path *path);
-+extern int ext4_ext_calc_credits_for_insert(struct inode *,
-+ struct ext4_ext_path *);
- extern int ext4_can_extents_be_merged(struct inode *inode,
- struct ext4_extent *ex1,
- struct ext4_extent *ex2);
-Index: linux-stage/fs/ext4/ext4_jbd2.c
-===================================================================
---- linux-stage.orig/fs/ext4/ext4_jbd2.c 2011-05-20 10:59:29.000000000 +0300
-+++ linux-stage/fs/ext4/ext4_jbd2.c 2011-05-20 11:00:01.000000000 +0300
-@@ -31,6 +31,7 @@ int __ext4_journal_get_write_access(cons
- }
- return err;
- }
-+EXPORT_SYMBOL(__ext4_journal_get_write_access);
-
- int __ext4_journal_forget(const char *where, handle_t *handle,
- struct buffer_head *bh)
-@@ -107,3 +108,4 @@ int __ext4_handle_dirty_metadata(const c
- }
- return err;
- }
-+EXPORT_SYMBOL(__ext4_handle_dirty_metadata);
-Index: linux-stage/fs/ext4/extents.c
-===================================================================
---- linux-stage.orig/fs/ext4/extents.c
-+++ linux-stage/fs/ext4/extents.c
-@@ -2133,6 +2133,55 @@ int ext4_ext_calc_credits_for_single_ext
- }
-
- /*
-+ * This routine returns max. credits extent tree can consume.
-+ * It should be OK for low-performance paths like ->writepage()
-+ * To allow many writing process to fit a single transaction,
-+ * caller should calculate credits under truncate_mutex and
-+ * pass actual path.
-+ */
-+int ext4_ext_calc_credits_for_insert(struct inode *inode,
-+ struct ext4_ext_path *path)
-+{
-+ int depth, needed;
-+
-+ if (path) {
-+ /* probably there is space in leaf? */
-+ depth = path->p_depth;
-+ if (le16_to_cpu(path[depth].p_hdr->eh_entries)
-+ < le16_to_cpu(path[depth].p_hdr->eh_max))
-+ return 1;
-+ }
-+
-+ /*
-+ * given 32bit logical block (4294967296 blocks), max. tree
-+ * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
-+ * let's also add one more level for imbalance.
-+ */
-+ depth = 5;
-+
-+ /* allocation of new data block(s) */
-+ needed = 2;
-+
-+ /*
-+ * tree can be full, so it'd need to grow in depth:
-+ * we need one credit to modify old root, credits for
-+ * new root will be added in split accounting
-+ */
-+ needed += 1;
-+ /*
-+ * Index split can happen, we'd need:
-+ * allocate intermediate indexes (bitmap + group)
-+ * + change two blocks at each level, but root (already included)
-+ */
-+ needed += (depth * 2) + (depth * 2);
-+
-+ /* any allocation modifies superblock */
-+ needed += 1;
-+
-+ return needed;
-+}
-+
-+/*
- * How many index/leaf blocks need to change/allocate to modify nrblocks?
- *
- * if nrblocks are fit in a single extent (chunk flag is 1), then
-@@ -4029,3 +4079,14 @@ int ext4_fiemap(struct inode *inode, str
- return error;
- }
-
-+EXPORT_SYMBOL(ext4_ext_store_pblock);
-+EXPORT_SYMBOL(ext4_ext_search_right);
-+EXPORT_SYMBOL(ext4_ext_search_left);
-+EXPORT_SYMBOL(ext_pblock);
-+EXPORT_SYMBOL(ext4_ext_insert_extent);
-+EXPORT_SYMBOL(ext4_mb_new_blocks);
-+EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
-+EXPORT_SYMBOL(ext4_mark_inode_dirty);
-+EXPORT_SYMBOL(ext4_ext_walk_space);
-+EXPORT_SYMBOL(ext4_ext_find_extent);
-+EXPORT_SYMBOL(ext4_ext_drop_refs);
-+
-Index: linux-stage/fs/ext4/inode.c
-===================================================================
---- linux-stage.orig/fs/ext4/inode.c 2011-05-20 10:59:31.000000000 +0300
-+++ linux-stage/fs/ext4/inode.c 2011-05-20 11:00:01.000000000 +0300
-@@ -5249,6 +5249,7 @@ bad_inode:
- iget_failed(inode);
- return ERR_PTR(ret);
- }
-+EXPORT_SYMBOL(ext4_iget);
-
- static int ext4_inode_blocks_set(handle_t *handle,
- struct ext4_inode *raw_inode,
-Index: linux-stage/fs/ext4/mballoc.c
-===================================================================
---- linux-stage.orig/fs/ext4/mballoc.c 2011-05-20 10:59:32.000000000 +0300
-+++ linux-stage/fs/ext4/mballoc.c 2011-05-20 11:00:01.000000000 +0300
-@@ -4044,6 +4044,7 @@ repeat:
- if (ac)
- kmem_cache_free(ext4_ac_cachep, ac);
- }
-+EXPORT_SYMBOL(ext4_discard_preallocations);
-
- /*
- * finds all preallocated spaces and return blocks being freed to them
-@@ -5029,3 +5030,6 @@ int ext4_trim_fs(struct super_block *sb,
-
- return ret;
- }
-+
-+EXPORT_SYMBOL(ext4_free_blocks);
-+
-Index: linux-stage/fs/ext4/super.c
-===================================================================
---- linux-stage.orig/fs/ext4/super.c 2011-05-20 10:59:31.000000000 +0300
-+++ linux-stage/fs/ext4/super.c 2011-05-20 11:00:01.000000000 +0300
-@@ -128,6 +128,7 @@ __u32 ext4_itable_unused_count(struct su
- (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
- (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0);
- }
-+EXPORT_SYMBOL(ext4_itable_unused_count);
-
- void ext4_block_bitmap_set(struct super_block *sb,
- struct ext4_group_desc *bg, ext4_fsblk_t blk)