ext4: optimize block allocation on grow indepth
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>
This commit is contained in:
parent
dfe076c106
commit
be5cd90dda
|
@ -1263,16 +1263,24 @@ cleanup:
|
||||||
* just created block
|
* just created block
|
||||||
*/
|
*/
|
||||||
static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
|
static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
|
||||||
unsigned int flags,
|
unsigned int flags)
|
||||||
struct ext4_extent *newext)
|
|
||||||
{
|
{
|
||||||
struct ext4_extent_header *neh;
|
struct ext4_extent_header *neh;
|
||||||
struct buffer_head *bh;
|
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;
|
int err = 0;
|
||||||
|
|
||||||
newblock = ext4_ext_new_meta_block(handle, inode, NULL,
|
/* Try to prepend new index to old one */
|
||||||
newext, &err, flags);
|
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)
|
if (newblock == 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -1373,7 +1381,7 @@ repeat:
|
||||||
err = PTR_ERR(path);
|
err = PTR_ERR(path);
|
||||||
} else {
|
} else {
|
||||||
/* tree is full, time to grow in depth */
|
/* 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)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue