Index: linux-stage/fs/ext4/ext4_jbd2.h =================================================================== --- linux-stage.orig/fs/ext4/ext4_jbd2.h +++ linux-stage/fs/ext4/ext4_jbd2.h @@ -35,6 +35,8 @@ (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \ ? 27U : 8U) +#define ext4_journal_dirty_metadata(handle, bh) \ + ext4_handle_dirty_metadata(handle, NULL, bh) /* 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-stage/fs/ext4/extents.c =================================================================== --- linux-stage.orig/fs/ext4/extents.c +++ linux-stage/fs/ext4/extents.c @@ -59,6 +59,17 @@ ext4_fsblk_t ext_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); +} + +/* * idx_pblock: * combine low and high parts of a leaf physical block number into ext4_fsblk_t */ @@ -72,17 +83,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 @@ -2097,6 +2097,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. @@ -3941,3 +3991,15 @@ 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); +EXPORT_SYMBOL(ext4_ext_find_extent); +EXPORT_SYMBOL(ext4_ext_drop_refs); + Index: linux-stage/fs/ext4/ext4_extents.h =================================================================== --- linux-stage.orig/fs/ext4/ext4_extents.h +++ linux-stage/fs/ext4/ext4_extents.h @@ -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). @@ -160,6 +166,7 @@ typedef int (*ext_prepare_callback)(stru #define EXT_INIT_MAX_LEN (1UL << 15) #define EXT_UNINIT_MAX_LEN (EXT_INIT_MAX_LEN - 1) +#define EXT4_EXT_HAS_NO_TREE /* ext4_extents_tree struct is not used*/ #define EXT_FIRST_EXTENT(__hdr__) \ ((struct ext4_extent *) (((char *) (__hdr__)) + \ @@ -231,6 +238,8 @@ extern ext4_fsblk_t ext_pblock(struct ex 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-stage/fs/ext4/mballoc.c =================================================================== --- linux-stage.orig/fs/ext4/mballoc.c +++ linux-stage/fs/ext4/mballoc.c @@ -4313,6 +4313,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 @@ -5127,3 +5128,6 @@ error_return: kmem_cache_free(ext4_ac_cachep, ac); return; } + +EXPORT_SYMBOL(ext4_free_blocks); + Index: linux-stage/fs/ext4/ext4_jbd2.c =================================================================== --- linux-stage.orig/fs/ext4/ext4_jbd2.c +++ linux-stage/fs/ext4/ext4_jbd2.c @@ -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/ext4.h =================================================================== --- linux-stage.orig/fs/ext4/ext4.h +++ linux-stage/fs/ext4/ext4.h @@ -1528,6 +1528,8 @@ extern int ext4_mb_add_groupinfo(struct 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-stage/fs/ext4/inode.c =================================================================== --- linux-stage.orig/fs/ext4/inode.c +++ linux-stage/fs/ext4/inode.c @@ -5078,6 +5078,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/super.c =================================================================== --- linux-stage.orig/fs/ext4/super.c +++ linux-stage/fs/ext4/super.c @@ -90,6 +90,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) @@ -114,6 +115,7 @@ __u32 ext4_free_inodes_count(struct supe (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0); } +EXPORT_SYMBOL(ext4_itable_unused_count); __u32 ext4_used_dirs_count(struct super_block *sb, struct ext4_group_desc *bg) @@ -1489,9 +1491,11 @@ enum { Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version, + Opt_mballoc, Opt_extents, Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_block_validity, Opt_noblock_validity, - Opt_inode_readahead_blks, Opt_journal_ioprio + Opt_inode_readahead_blks, Opt_journal_ioprio, + Opt_iopen, Opt_noiopen, Opt_iopen_nopriv, }; static match_table_t tokens = { @@ -1547,6 +1551,11 @@ static match_table_t tokens = { {Opt_barrier, "barrier"}, {Opt_nobarrier, "nobarrier"}, {Opt_i_version, "i_version"}, + {Opt_mballoc, "mballoc"}, + {Opt_extents, "extents"}, + {Opt_iopen, "iopen"}, + {Opt_noiopen, "noiopen"}, + {Opt_iopen_nopriv, "iopen_nopriv"}, {Opt_stripe, "stripe=%u"}, {Opt_resize, "resize"}, {Opt_delalloc, "delalloc"}, @@ -1993,6 +2002,12 @@ set_qf_format: else set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); break; + case Opt_mballoc: + case Opt_extents: + case Opt_iopen: + case Opt_noiopen: + case Opt_iopen_nopriv: + break; default: ext4_msg(sb, KERN_ERR, "Unrecognized mount option \"%s\" " @@ -2543,7 +2558,7 @@ static ssize_t delayed_allocation_blocks char *buf) { return snprintf(buf, PAGE_SIZE, "%llu\n", - (s64) percpu_counter_sum(&sbi->s_dirtyblocks_counter)); + (unsigned long long) percpu_counter_sum(&sbi->s_dirtyblocks_counter)); } static ssize_t session_write_kbytes_show(struct ext4_attr *a, @@ -2564,11 +2579,11 @@ static ssize_t lifetime_write_kbytes_sho struct super_block *sb = sbi->s_buddy_cache->i_sb; return snprintf(buf, PAGE_SIZE, "%llu\n", - sbi->s_kbytes_written + + (unsigned long long)(sbi->s_kbytes_written + (sb->s_bdev->bd_part ? (part_stat_read(sb->s_bdev->bd_part, sectors[1]) - EXT4_SB(sb)->s_sectors_written_start) >> 1 - : 0)); + : 0))); } static ssize_t inode_readahead_blks_store(struct ext4_attr *a, @@ -3042,7 +3057,7 @@ static int ext4_fill_super(struct super_ if (blocks_count && ext4_blocks_count(es) > blocks_count) { ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu " "exceeds size of device (%llu blocks)", - ext4_blocks_count(es), blocks_count); + ext4_blocks_count(es), (unsigned long long)blocks_count); goto failed_mount; } Index: linux-stage/fs/ext4/fsync.c =================================================================== --- linux-stage.orig/fs/ext4/fsync.c +++ linux-stage/fs/ext4/fsync.c @@ -61,7 +61,7 @@ int ext4_sync_file(struct file *file, st trace_mark(ext4_sync_file, "dev %s datasync %d ino %ld parent %ld", inode->i_sb->s_id, datasync, inode->i_ino, - dentry->d_parent->d_inode->i_ino); + 0L); ret = flush_aio_dio_completed_IO(inode); if (ret < 0) Index: linux-stage/fs/ext4/move_extent.c =================================================================== --- linux-stage.orig/fs/ext4/move_extent.c +++ linux-stage/fs/ext4/move_extent.c @@ -1358,7 +1358,8 @@ ext4_move_extents(struct file *o_filp, s ext4_error(orig_inode->i_sb, "We replaced blocks too much! " "sum of replaced: %llu requested: %llu", - *moved_len, len); + (unsigned long long)(*moved_len), + (unsigned long long)(len)); ret1 = -EIO; break; }