Index: linux-2.6.27.21-0.1/fs/ext4/ext4_jbd2.h =================================================================== --- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_jbd2.h 2009-07-07 14:47:19.000000000 +0530 +++ linux-2.6.27.21-0.1/fs/ext4/ext4_jbd2.h 2009-07-07 14:47:22.000000000 +0530 @@ -35,6 +35,9 @@ (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \ || test_opt(sb, EXTENTS) ? 27U : 8U) +/* Indicate that EXT4_SINGLEDATA_TRANS_BLOCKS takes the sb as argument */ +#define EXT4_SINGLEDATA_TRANS_BLOCKS_HAS_SB + /* Extended attribute operations touch at most two data buffers, * two bitmap buffers, and two group summaries, in addition to the inode * and the superblock, which are already accounted for. */ Index: linux-2.6.27.21-0.1/fs/ext4/extents.c =================================================================== --- linux-2.6.27.21-0.1.orig/fs/ext4/extents.c 2009-07-07 14:47:19.000000000 +0530 +++ linux-2.6.27.21-0.1/fs/ext4/extents.c 2009-07-07 14:48:03.000000000 +0530 @@ -48,7 +48,7 @@ * ext_pblock: * combine low and high parts of physical block number into ext4_fsblk_t */ -static ext4_fsblk_t ext_pblock(struct ext4_extent *ex) +ext4_fsblk_t ext_pblock(struct ext4_extent *ex) { ext4_fsblk_t block; @@ -58,6 +58,17 @@ } /* + * ext4_ext_store_pblock: + * stores a large physical block number into an extent struct, + * breaking it into parts + */ +void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb) +{ + ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff)); + ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff); +} + +/* * idx_pblock: * combine low and high parts of a leaf physical block number into ext4_fsblk_t */ @@ -71,17 +82,6 @@ } /* - * ext4_ext_store_pblock: - * stores a large physical block number into an extent struct, - * breaking it into parts - */ -void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb) -{ - ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff)); - ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff); -} - -/* * ext4_idx_store_pblock: * stores a large physical block number into an index struct, * breaking it into parts @@ -1852,6 +1852,56 @@ } /* + * 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 = ext_depth(inode); + 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; +} + +/* * ext4_ext_calc_credits_for_single_extent: * This routine returns max. credits that needed to insert an extent * to the extent tree. @@ -3171,3 +3221,13 @@ 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); + Index: linux-2.6.27.21-0.1/fs/ext4/ext4_extents.h =================================================================== --- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_extents.h 2009-07-07 14:47:19.000000000 +0530 +++ linux-2.6.27.21-0.1/fs/ext4/ext4_extents.h 2009-07-07 14:47:22.000000000 +0530 @@ -59,6 +59,11 @@ */ #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 /* * ext4_inode has i_block array (60 bytes total). @@ -124,6 +129,7 @@ #define EXT4_EXT_CACHE_GAP 1 #define EXT4_EXT_CACHE_EXTENT 2 +#define EXT4_EXT_HAS_NO_TREE /* ext4_extents_tree struct is not used*/ #define EXT_MAX_BLOCK 0xffffffff @@ -223,10 +229,14 @@ (le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN)); } +extern ext4_fsblk_t ext_pblock(struct ext4_extent *ex); +extern void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb); extern int ext4_ext_calc_metadata_amount(struct inode *inode, int blocks); extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *); extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t); extern int ext4_extent_tree_init(handle_t *, struct inode *); +extern int ext4_ext_calc_credits_for_insert(struct inode *, + struct ext4_ext_path *); extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int num, struct ext4_ext_path *path); Index: linux-2.6.27.21-0.1/fs/ext4/mballoc.c =================================================================== --- linux-2.6.27.21-0.1.orig/fs/ext4/mballoc.c 2009-07-07 14:47:19.000000000 +0530 +++ linux-2.6.27.21-0.1/fs/ext4/mballoc.c 2009-07-07 14:47:22.000000000 +0530 @@ -4355,6 +4355,13 @@ kmem_cache_free(ext4_ac_cachep, ac); } +/* For backward compatibility, since Lustre uses this symbol */ +void ext4_mb_discard_inode_preallocations(struct inode *inode) +{ + ext4_discard_preallocations(inode); +} +EXPORT_SYMBOL(ext4_mb_discard_inode_preallocations); + /* * finds all preallocated spaces and return blocks being freed to them * if preallocated space becomes full (no block is used from the space) @@ -5177,3 +5184,6 @@ kmem_cache_free(ext4_ac_cachep, ac); return; } + +EXPORT_SYMBOL(ext4_free_blocks); + Index: linux-2.6.27.21-0.1/fs/ext4/super.c =================================================================== --- linux-2.6.27.21-0.1.orig/fs/ext4/super.c 2009-07-07 14:47:19.000000000 +0530 +++ linux-2.6.27.21-0.1/fs/ext4/super.c 2009-07-07 14:48:53.000000000 +0530 @@ -91,6 +91,7 @@ (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0); } +EXPORT_SYMBOL(ext4_inode_bitmap); ext4_fsblk_t ext4_inode_table(struct super_block *sb, struct ext4_group_desc *bg) @@ -1286,6 +1287,7 @@ Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version, + Opt_mballoc, Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_inode_readahead_blks, Opt_bigendian_extents, Opt_iopen, Opt_noiopen, Opt_iopen_nopriv, @@ -1346,6 +1348,7 @@ {Opt_i_version, "i_version"}, {Opt_stripe, "stripe=%u"}, {Opt_resize, "resize"}, + {Opt_mballoc, "mballoc"}, {Opt_delalloc, "delalloc"}, {Opt_nodelalloc, "nodelalloc"}, {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, @@ -1768,6 +1771,8 @@ case Opt_bigendian_extents: bigendian_extents = 1; break; + case Opt_mballoc: + break; default: printk(KERN_ERR "EXT4-fs: Unrecognized mount option \"%s\" " @@ -4094,7 +4099,7 @@ .kill_sb = kill_block_super, .fs_flags = FS_REQUIRES_DEV, }; -MODULE_ALIAS("ext4dev"); +MODULE_ALIAS("ext4"); static int __init init_ext4_fs(void) { Index: linux-2.6.27.21-0.1/fs/ext4/ext4_jbd2.c =================================================================== --- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_jbd2.c 2009-07-07 14:47:19.000000000 +0530 +++ linux-2.6.27.21-0.1/fs/ext4/ext4_jbd2.c 2009-07-07 14:47:22.000000000 +0530 @@ -21,6 +21,7 @@ ext4_journal_abort_handle(where, __func__, bh, handle, err); return err; } +EXPORT_SYMBOL(__ext4_journal_get_write_access); int __ext4_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh) @@ -57,3 +58,4 @@ ext4_journal_abort_handle(where, __func__, bh, handle, err); return err; } +EXPORT_SYMBOL(__ext4_journal_dirty_metadata); Index: linux-2.6.27.21-0.1/fs/ext4/ext4.h =================================================================== --- linux-2.6.27.21-0.1.orig/fs/ext4/ext4.h 2009-07-07 14:47:19.000000000 +0530 +++ linux-2.6.27.21-0.1/fs/ext4/ext4.h 2009-07-07 14:47:22.000000000 +0530 @@ -26,6 +26,9 @@ * The fourth extended filesystem constants/structures */ +/* Has been moved to linux/magic.h but we need it for Lustre */ +#define EXT4_SUPER_MAGIC 0xEF53 + /* * Define EXT4FS_DEBUG to produce debug messages */ @@ -400,6 +403,8 @@ __le32 i_version_hi; /* high 32 bits for 64-bit version */ }; +/* SLES11 kernel already has 64-bit inode->i_version field */ +#define HAVE_DISK_INODE_VERSION #define EXT4_EPOCH_BITS 2 #define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1) @@ -1123,6 +1128,8 @@ extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t); extern void ext4_mb_put_buddy_cache_lock(struct super_block *, ext4_group_t, int); +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-2.6.27.21-0.1/fs/ext4/inode.c =================================================================== --- linux-2.6.27.21-0.1.orig/fs/ext4/inode.c 2009-07-07 14:47:19.000000000 +0530 +++ linux-2.6.27.21-0.1/fs/ext4/inode.c 2009-07-07 14:47:22.000000000 +0530 @@ -4240,6 +4240,7 @@ 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,