diff options
-rw-r--r-- | fs/ext4/balloc.c | 49 | ||||
-rw-r--r-- | fs/ext4/extents.c | 3 | ||||
-rw-r--r-- | fs/ext4/xattr.c | 3 |
3 files changed, 17 insertions, 38 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 98a97129fc5f..35f5f9a27722 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -666,59 +666,40 @@ int ext4_should_retry_alloc(struct super_block *sb, int *retries) | |||
666 | return jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal); | 666 | return jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal); |
667 | } | 667 | } |
668 | 668 | ||
669 | #define EXT4_META_BLOCK 0x1 | ||
670 | |||
671 | static ext4_fsblk_t do_blk_alloc(handle_t *handle, struct inode *inode, | ||
672 | ext4_lblk_t iblock, ext4_fsblk_t goal, | ||
673 | unsigned long *count, int *errp, int flags) | ||
674 | { | ||
675 | struct ext4_allocation_request ar; | ||
676 | ext4_fsblk_t ret; | ||
677 | |||
678 | memset(&ar, 0, sizeof(ar)); | ||
679 | /* Fill with neighbour allocated blocks */ | ||
680 | |||
681 | ar.inode = inode; | ||
682 | ar.goal = goal; | ||
683 | ar.len = *count; | ||
684 | ar.logical = iblock; | ||
685 | |||
686 | if (S_ISREG(inode->i_mode) && !(flags & EXT4_META_BLOCK)) | ||
687 | /* enable in-core preallocation for data block allocation */ | ||
688 | ar.flags = EXT4_MB_HINT_DATA; | ||
689 | else | ||
690 | /* disable in-core preallocation for non-regular files */ | ||
691 | ar.flags = 0; | ||
692 | |||
693 | ret = ext4_mb_new_blocks(handle, &ar, errp); | ||
694 | *count = ar.len; | ||
695 | return ret; | ||
696 | } | ||
697 | |||
698 | /* | 669 | /* |
699 | * ext4_new_meta_blocks() -- allocate block for meta data (indexing) blocks | 670 | * ext4_new_meta_blocks() -- allocate block for meta data (indexing) blocks |
700 | * | 671 | * |
701 | * @handle: handle to this transaction | 672 | * @handle: handle to this transaction |
702 | * @inode: file inode | 673 | * @inode: file inode |
703 | * @goal: given target block(filesystem wide) | 674 | * @goal: given target block(filesystem wide) |
704 | * @count: total number of blocks need | 675 | * @count: pointer to total number of blocks needed |
705 | * @errp: error code | 676 | * @errp: error code |
706 | * | 677 | * |
707 | * Return 1st allocated block numberon success, *count stores total account | 678 | * Return 1st allocated block number on success, *count stores total account |
708 | * error stores in errp pointer | 679 | * error stores in errp pointer |
709 | */ | 680 | */ |
710 | ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode, | 681 | ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode, |
711 | ext4_fsblk_t goal, unsigned long *count, int *errp) | 682 | ext4_fsblk_t goal, unsigned long *count, int *errp) |
712 | { | 683 | { |
684 | struct ext4_allocation_request ar; | ||
713 | ext4_fsblk_t ret; | 685 | ext4_fsblk_t ret; |
714 | ret = do_blk_alloc(handle, inode, 0, goal, | 686 | |
715 | count, errp, EXT4_META_BLOCK); | 687 | memset(&ar, 0, sizeof(ar)); |
688 | /* Fill with neighbour allocated blocks */ | ||
689 | ar.inode = inode; | ||
690 | ar.goal = goal; | ||
691 | ar.len = count ? *count : 1; | ||
692 | |||
693 | ret = ext4_mb_new_blocks(handle, &ar, errp); | ||
694 | if (count) | ||
695 | *count = ar.len; | ||
696 | |||
716 | /* | 697 | /* |
717 | * Account for the allocated meta blocks | 698 | * Account for the allocated meta blocks |
718 | */ | 699 | */ |
719 | if (!(*errp) && EXT4_I(inode)->i_delalloc_reserved_flag) { | 700 | if (!(*errp) && EXT4_I(inode)->i_delalloc_reserved_flag) { |
720 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); | 701 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); |
721 | EXT4_I(inode)->i_allocated_meta_blocks += *count; | 702 | EXT4_I(inode)->i_allocated_meta_blocks += ar.len; |
722 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | 703 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); |
723 | } | 704 | } |
724 | return ret; | 705 | return ret; |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index e5b169b44b4c..59401d057c69 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -189,10 +189,9 @@ ext4_ext_new_meta_block(handle_t *handle, struct inode *inode, | |||
189 | struct ext4_extent *ex, int *err) | 189 | struct ext4_extent *ex, int *err) |
190 | { | 190 | { |
191 | ext4_fsblk_t goal, newblock; | 191 | ext4_fsblk_t goal, newblock; |
192 | unsigned long count = 1; | ||
193 | 192 | ||
194 | goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block)); | 193 | goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block)); |
195 | newblock = ext4_new_meta_blocks(handle, inode, goal, &count, err); | 194 | newblock = ext4_new_meta_blocks(handle, inode, goal, NULL, err); |
196 | return newblock; | 195 | return newblock; |
197 | } | 196 | } |
198 | 197 | ||
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index f896e2c452f0..9b4a368c5728 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -689,7 +689,6 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, | |||
689 | struct ext4_xattr_info *i, | 689 | struct ext4_xattr_info *i, |
690 | struct ext4_xattr_block_find *bs) | 690 | struct ext4_xattr_block_find *bs) |
691 | { | 691 | { |
692 | unsigned long count = 1; | ||
693 | struct super_block *sb = inode->i_sb; | 692 | struct super_block *sb = inode->i_sb; |
694 | struct buffer_head *new_bh = NULL; | 693 | struct buffer_head *new_bh = NULL; |
695 | struct ext4_xattr_search *s = &bs->s; | 694 | struct ext4_xattr_search *s = &bs->s; |
@@ -812,7 +811,7 @@ inserted: | |||
812 | ext4_fsblk_t goal = ext4_group_first_block_no(sb, | 811 | ext4_fsblk_t goal = ext4_group_first_block_no(sb, |
813 | EXT4_I(inode)->i_block_group); | 812 | EXT4_I(inode)->i_block_group); |
814 | ext4_fsblk_t block = ext4_new_meta_blocks(handle, inode, | 813 | ext4_fsblk_t block = ext4_new_meta_blocks(handle, inode, |
815 | goal, &count, &error); | 814 | goal, NULL, &error); |
816 | if (error) | 815 | if (error) |
817 | goto cleanup; | 816 | goto cleanup; |
818 | ea_idebug(inode, "creating block %d", block); | 817 | ea_idebug(inode, "creating block %d", block); |