aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/extents.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2009-05-12 16:30:27 -0400
committerTheodore Ts'o <tytso@mit.edu>2009-05-12 16:30:27 -0400
commit29fa89d088941d79765d60f22d5ccdd6b8696e11 (patch)
tree3fbe031eec140c03dafa11f2416c4f6e3826f21d /fs/ext4/extents.c
parent8fb0e342481c4d80040670fec915f0b9c7c6499a (diff)
ext4: Mark the unwritten buffer_head as mapped during write_begin
Setting BH_Unwritten buffer_heads as BH_Mapped avoids multiple (unnecessary) calls to get_block() during the call to the write(2) system call. Setting BH_Unwritten buffer heads as BH_Mapped requires that the writepages() functions can handle BH_Unwritten buffer_heads. After this commit, things work as follows: ext4_ext_get_block() returns unmapped, unwritten, buffer head when called with create = 0 for prealloc space. This makes sure we handle the read path and non-delayed allocation case correctly. Even though the buffer head is marked unmapped we have valid b_blocknr and b_bdev values in the buffer_head. ext4_da_get_block_prep() called for block resrevation will now return mapped, unwritten, new buffer_head for prealloc space. This avoids multiple calls to get_block() for write to same offset. By making such buffers as BH_New, we also assure that sub-block zeroing of buffered writes happens correctly. Signed-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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index a953214f2829..ea5c47608cea 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2872,6 +2872,8 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2872 if (create == EXT4_CREATE_UNINITIALIZED_EXT) 2872 if (create == EXT4_CREATE_UNINITIALIZED_EXT)
2873 goto out; 2873 goto out;
2874 if (!create) { 2874 if (!create) {
2875 if (allocated > max_blocks)
2876 allocated = max_blocks;
2875 /* 2877 /*
2876 * We have blocks reserved already. We 2878 * We have blocks reserved already. We
2877 * return allocated blocks so that delalloc 2879 * return allocated blocks so that delalloc
@@ -2879,8 +2881,6 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2879 * the buffer head will be unmapped so that 2881 * the buffer head will be unmapped so that
2880 * a read from the block returns 0s. 2882 * a read from the block returns 0s.
2881 */ 2883 */
2882 if (allocated > max_blocks)
2883 allocated = max_blocks;
2884 set_buffer_unwritten(bh_result); 2884 set_buffer_unwritten(bh_result);
2885 bh_result->b_bdev = inode->i_sb->s_bdev; 2885 bh_result->b_bdev = inode->i_sb->s_bdev;
2886 bh_result->b_blocknr = newblock; 2886 bh_result->b_blocknr = newblock;