ext4: better estimate credits needed for ext4_da_writepages()

We limit the number of blocks written in a single loop of
ext4_da_writepages() to 64 when inode uses indirect blocks.  That is
unnecessary as credit estimates for mapping logically continguous run
of blocks is rather low even for inode with indirect blocks.  So just
lift this limitation and properly calculate the number of necessary
credits.

This better credit estimate will also later allow us to always write
at least a single page in one iteration.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
Jan Kara
2013-06-04 13:01:11 -04:00
committed by Theodore Ts'o
parent fa55a0ed03
commit fffb273997
3 changed files with 35 additions and 46 deletions

View File

@@ -2328,17 +2328,15 @@ int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int nrblocks,
}
/*
* How many index/leaf blocks need to change/allocate to modify nrblocks?
* How many index/leaf blocks need to change/allocate to add @extents extents?
*
* if nrblocks are fit in a single extent (chunk flag is 1), then
* in the worse case, each tree level index/leaf need to be changed
* if the tree split due to insert a new extent, then the old tree
* index/leaf need to be updated too
* If we add a single extent, then in the worse case, each tree level
* index/leaf need to be changed in case of the tree split.
*
* If the nrblocks are discontiguous, they could cause
* the whole tree split more than once, but this is really rare.
* If more extents are inserted, they could cause the whole tree split more
* than once, but this is really rare.
*/
int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks, int chunk)
int ext4_ext_index_trans_blocks(struct inode *inode, int extents)
{
int index;
int depth;
@@ -2349,7 +2347,7 @@ int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks, int chunk)
depth = ext_depth(inode);
if (chunk)
if (extents <= 1)
index = depth * 2;
else
index = depth * 3;