diff options
author | Mingming Cao <cmm@us.ibm.com> | 2008-08-19 22:16:03 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-08-19 22:16:03 -0400 |
commit | f3bd1f3fa8ca7ec70cfd87aa94dc5e1a260901f2 (patch) | |
tree | a0f0ce2e044f8a75009e94d5f788b45a3948bbe3 /fs/ext4/extents.c | |
parent | ee12b630687d510f6f4b6d4acdc4e267fd4adeda (diff) |
ext4: journal credits reservation fixes for DIO, fallocate
DIO and fallocate credit calculation is different than writepage, as
they do start a new journal right for each call to ext4_get_blocks_wrap().
This patch uses the helper function in DIO and fallocate case, passing
a flag indicating that the modified data are contigous thus could account
less indirect/index blocks.
This patch also fixed the journal credit reservation for direct I/O
(DIO). Previously the estimated credits for DIO only was calculated for
non-extent files, which was not enough if the file is extent-based.
Also fixed was fallocate double-counting credits for modifying the the
superblock.
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Reviewed-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 | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 5c5dd3a1d657..5596b70efa20 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -1758,7 +1758,7 @@ int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int num, | |||
1758 | { | 1758 | { |
1759 | if (path) { | 1759 | if (path) { |
1760 | int depth = ext_depth(inode); | 1760 | int depth = ext_depth(inode); |
1761 | int ret; | 1761 | int ret = 0; |
1762 | 1762 | ||
1763 | /* probably there is space in leaf? */ | 1763 | /* probably there is space in leaf? */ |
1764 | if (le16_to_cpu(path[depth].p_hdr->eh_entries) | 1764 | if (le16_to_cpu(path[depth].p_hdr->eh_entries) |
@@ -1777,7 +1777,7 @@ int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int num, | |||
1777 | } | 1777 | } |
1778 | } | 1778 | } |
1779 | 1779 | ||
1780 | return ext4_meta_trans_blocks(inode, num, 1); | 1780 | return ext4_chunk_trans_blocks(inode, num); |
1781 | } | 1781 | } |
1782 | 1782 | ||
1783 | /* | 1783 | /* |
@@ -2810,7 +2810,7 @@ void ext4_ext_truncate(struct inode *inode) | |||
2810 | /* | 2810 | /* |
2811 | * probably first extent we're gonna free will be last in block | 2811 | * probably first extent we're gonna free will be last in block |
2812 | */ | 2812 | */ |
2813 | err = ext4_writepage_trans_blocks(inode) + 3; | 2813 | err = ext4_writepage_trans_blocks(inode); |
2814 | handle = ext4_journal_start(inode, err); | 2814 | handle = ext4_journal_start(inode, err); |
2815 | if (IS_ERR(handle)) | 2815 | if (IS_ERR(handle)) |
2816 | return; | 2816 | return; |
@@ -2923,10 +2923,9 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len) | |||
2923 | max_blocks = (EXT4_BLOCK_ALIGN(len + offset, blkbits) >> blkbits) | 2923 | max_blocks = (EXT4_BLOCK_ALIGN(len + offset, blkbits) >> blkbits) |
2924 | - block; | 2924 | - block; |
2925 | /* | 2925 | /* |
2926 | * credits to insert 1 extent into extent tree + buffers to be able to | 2926 | * credits to insert 1 extent into extent tree |
2927 | * modify 1 super block, 1 block bitmap and 1 group descriptor. | ||
2928 | */ | 2927 | */ |
2929 | credits = EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + 3; | 2928 | credits = ext4_chunk_trans_blocks(inode, max_blocks); |
2930 | mutex_lock(&inode->i_mutex); | 2929 | mutex_lock(&inode->i_mutex); |
2931 | retry: | 2930 | retry: |
2932 | while (ret >= 0 && ret < max_blocks) { | 2931 | while (ret >= 0 && ret < max_blocks) { |