Index: linux-2.6.18.i386/fs/ext4/ext4_jbd2.h =================================================================== --- linux-2.6.18.i386.orig/fs/ext4/ext4_jbd2.h +++ linux-2.6.18.i386/fs/ext4/ext4_jbd2.h @@ -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.18.i386/fs/ext4/extents.c =================================================================== --- linux-2.6.18.i386.orig/fs/ext4/extents.c +++ linux-2.6.18.i386/fs/ext4/extents.c @@ -50,7 +50,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; @@ -60,6 +60,17 @@ static ext4_fsblk_t ext_pblock(struct ex } /* + * 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 */ @@ -73,17 +84,6 @@ ext4_fsblk_t idx_pblock(struct ext4_exte } /* - * 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 @@ -1826,6 +1826,56 @@ static int ext4_ext_rm_idx(handle_t *han } /* + * 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. @@ -3157,3 +3207,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_walk_space); +EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert); +EXPORT_SYMBOL(ext4_mark_inode_dirty); + Index: linux-2.6.18.i386/fs/ext4/ext4_extents.h =================================================================== --- linux-2.6.18.i386.orig/fs/ext4/ext4_extents.h +++ linux-2.6.18.i386/fs/ext4/ext4_extents.h @@ -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 @@ struct ext4_ext_path { #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 @@ -228,9 +234,13 @@ static inline int ext4_ext_get_actual_le (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 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.18.i386/fs/ext4/mballoc.c =================================================================== --- linux-2.6.18.i386.orig/fs/ext4/mballoc.c +++ linux-2.6.18.i386/fs/ext4/mballoc.c @@ -4965,3 +4965,7 @@ error_return: kmem_cache_free(ext4_ac_cachep, ac); return; } + +EXPORT_SYMBOL(ext4_free_blocks); +EXPORT_SYMBOL(ext4_mb_discard_inode_preallocations); + Index: linux-2.6.18.i386/fs/ext4/super.c =================================================================== --- linux-2.6.18.i386.orig/fs/ext4/super.c +++ linux-2.6.18.i386/fs/ext4/super.c @@ -91,6 +91,7 @@ ext4_fsblk_t ext4_inode_bitmap(struct su (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) @@ -513,7 +514,8 @@ static void ext4_put_super(struct super_ struct ext4_super_block *es = sbi->s_es; int i; - ext4_mb_release(sb); + if (test_opt(sb, MBALLOC)) + ext4_mb_release(sb); ext4_ext_release(sb); ext4_xattr_put_super(sb); jbd2_journal_destroy(sbi->s_journal); @@ -2373,16 +2375,6 @@ static int ext4_fill_super(struct super_ "running e2fsck is recommended\n"); /* - * Since ext4 is still considered development code, we require - * that the TEST_FILESYS flag in s->flags be set. - */ - if (!(le32_to_cpu(es->s_flags) & EXT2_FLAGS_TEST_FILESYS)) { - printk(KERN_WARNING "EXT4-fs: %s: not marked " - "OK to use with test code.\n", sb->s_id); - goto failed_mount; - } - - /* * Check feature flags regardless of the revision level, since we * previously didn't change the revision level when setting the flags, * so there is a chance incompat flags are set on a rev 0 filesystem. @@ -3835,9 +3827,9 @@ static int ext4_get_sb(struct file_syste return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super, mnt); } -static struct file_system_type ext4dev_fs_type = { +static struct file_system_type ext4_fs_type = { .owner = THIS_MODULE, - .name = "ext4dev", + .name = "ext4", .get_sb = ext4_get_sb, .kill_sb = kill_block_super, #ifdef HAVE_FALLOCATE @@ -3867,7 +3859,7 @@ static int __init init_ext4_fs(void) err = init_inodecache(); if (err) goto out1; - err = register_filesystem(&ext4dev_fs_type); + err = register_filesystem(&ext4_fs_type); if (err) goto out; return 0; @@ -3884,7 +3876,7 @@ out3: static void __exit exit_ext4_fs(void) { - unregister_filesystem(&ext4dev_fs_type); + unregister_filesystem(&ext4_fs_type); destroy_inodecache(); exit_ext4_xattr(); exit_ext4_mballoc(); Index: linux-2.6.18.i386/fs/ext4/ext4_jbd2.c =================================================================== --- linux-2.6.18.i386.orig/fs/ext4/ext4_jbd2.c +++ linux-2.6.18.i386/fs/ext4/ext4_jbd2.c @@ -21,6 +21,7 @@ int __ext4_journal_get_write_access(cons 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 @@ int __ext4_journal_dirty_metadata(const ext4_journal_abort_handle(where, __func__, bh, handle, err); return err; } +EXPORT_SYMBOL(__ext4_journal_dirty_metadata);