diff options
author | Mingming Cao <cmm@us.ibm.com> | 2008-08-19 22:15:58 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-08-19 22:15:58 -0400 |
commit | 525f4ed8dcb72c71b306a78ecbf06f41d08fe441 (patch) | |
tree | d4d74dc7b109c5d74fa955970a8528ec90e20b06 /fs/ext4/extents.c | |
parent | a1d6cc563bfdf1bf2829d3e6ce4d8b774251796b (diff) |
ext4: journal credit fix for the delayed allocation's writepages() function
Previous delalloc writepages implementation started a new transaction
outside of a loop which called get_block() to do the block allocation.
Since we didn't know exactly how many blocks would need to be allocated,
the estimated journal credits required was very conservative and caused
many issues.
With the reworked delayed allocation, a new transaction is created for
each get_block(), thus we don't need to guess how many credits for the
multiple chunk of allocation. We start every transaction with enough
credits for inserting a single exent. When estimate the credits for
indirect blocks to allocate a chunk of blocks, we need to know the
number of data blocks to allocate. We use the total number of reserved
delalloc datablocks; if that is too big, for non-extent files, we need
to limit the number of blocks to EXT4_MAX_TRANS_BLOCKS.
Code cleanup from Aneesh.
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Reviewed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 5596b70efa20..b24d3c53f20c 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -1753,7 +1753,7 @@ static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode, | |||
1753 | * When pass the actual path, the caller should calculate credits | 1753 | * When pass the actual path, the caller should calculate credits |
1754 | * under i_data_sem. | 1754 | * under i_data_sem. |
1755 | */ | 1755 | */ |
1756 | int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int num, | 1756 | int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int nrblocks, |
1757 | struct ext4_ext_path *path) | 1757 | struct ext4_ext_path *path) |
1758 | { | 1758 | { |
1759 | if (path) { | 1759 | if (path) { |
@@ -1772,12 +1772,12 @@ int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int num, | |||
1772 | * and other metadat blocks still need to be | 1772 | * and other metadat blocks still need to be |
1773 | * accounted. | 1773 | * accounted. |
1774 | */ | 1774 | */ |
1775 | /* 1 one bitmap, 1 block group descriptor */ | 1775 | /* 1 bitmap, 1 block group descriptor */ |
1776 | ret = 2 + EXT4_META_TRANS_BLOCKS(inode->i_sb); | 1776 | ret = 2 + EXT4_META_TRANS_BLOCKS(inode->i_sb); |
1777 | } | 1777 | } |
1778 | } | 1778 | } |
1779 | 1779 | ||
1780 | return ext4_chunk_trans_blocks(inode, num); | 1780 | return ext4_chunk_trans_blocks(inode, nrblocks); |
1781 | } | 1781 | } |
1782 | 1782 | ||
1783 | /* | 1783 | /* |
@@ -1791,7 +1791,7 @@ int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int num, | |||
1791 | * If the nrblocks are discontiguous, they could cause | 1791 | * If the nrblocks are discontiguous, they could cause |
1792 | * the whole tree split more than once, but this is really rare. | 1792 | * the whole tree split more than once, but this is really rare. |
1793 | */ | 1793 | */ |
1794 | int ext4_ext_index_trans_blocks(struct inode *inode, int num, int chunk) | 1794 | int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks, int chunk) |
1795 | { | 1795 | { |
1796 | int index; | 1796 | int index; |
1797 | int depth = ext_depth(inode); | 1797 | int depth = ext_depth(inode); |