Skip to content

Commit

Permalink
ext4: optimize block allocation on grow indepth
Browse files Browse the repository at this point in the history
It is reasonable to prepend newly created index to older one.

[ Dropped no longer used function parameter newext. -tytso ]

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
  • Loading branch information
Dmitry Monakhov authored and tytso committed Oct 2, 2014
1 parent dfe076c commit be5cd90
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -1263,16 +1263,24 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
* just created block
*/
static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
unsigned int flags,
struct ext4_extent *newext)
unsigned int flags)
{
struct ext4_extent_header *neh;
struct buffer_head *bh;
ext4_fsblk_t newblock;
ext4_fsblk_t newblock, goal = 0;
struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
int err = 0;

newblock = ext4_ext_new_meta_block(handle, inode, NULL,
newext, &err, flags);
/* Try to prepend new index to old one */
if (ext_depth(inode))
goal = ext4_idx_pblock(EXT_FIRST_INDEX(ext_inode_hdr(inode)));
if (goal > le32_to_cpu(es->s_first_data_block)) {
flags |= EXT4_MB_HINT_TRY_GOAL;
goal--;
} else
goal = ext4_inode_to_goal_block(inode);
newblock = ext4_new_meta_blocks(handle, inode, goal, flags,
NULL, &err);
if (newblock == 0)
return err;

Expand Down Expand Up @@ -1373,7 +1381,7 @@ static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode,
err = PTR_ERR(path);
} else {
/* tree is full, time to grow in depth */
err = ext4_ext_grow_indepth(handle, inode, mb_flags, newext);
err = ext4_ext_grow_indepth(handle, inode, mb_flags);
if (err)
goto out;

Expand Down

0 comments on commit be5cd90

Please sign in to comment.