aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorMingming <cmm@us.ibm.com>2009-11-06 04:01:23 -0500
committerTheodore Ts'o <tytso@mit.edu>2009-11-06 04:01:23 -0500
commitba230c3f6dc88ec008806adb27b12088486d508e (patch)
tree4cd81bc7425161f1103408ce210be9172a2ee6c3 /fs/ext4
parent4b70df181611012a3556f017b57dfcef7e1d279f (diff)
ext4: Fix return value of ext4_split_unwritten_extents() to fix direct I/O
To prepare for a direct I/O write, we need to split the unwritten extents before submitting the I/O. When no extents needed to be split, ext4_split_unwritten_extents() was incorrectly returning 0 instead of the size of uninitialized extents. This bug caused the wrong return value sent back to VFS code when it gets called from async IO path, leading to an unnecessary fall back to buffered IO. This bug also hid the fact that the check to see whether or not a split would be necessary was incorrect; we can only skip splitting the extent if the write completely covers the uninitialized extent. Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/extents.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index e991ae2b461c..715264b4bae4 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2807,6 +2807,8 @@ fix_extent_len:
2807 * into three uninitialized extent(at most). After IO complete, the part 2807 * into three uninitialized extent(at most). After IO complete, the part
2808 * being filled will be convert to initialized by the end_io callback function 2808 * being filled will be convert to initialized by the end_io callback function
2809 * via ext4_convert_unwritten_extents(). 2809 * via ext4_convert_unwritten_extents().
2810 *
2811 * Returns the size of uninitialized extent to be written on success.
2810 */ 2812 */
2811static int ext4_split_unwritten_extents(handle_t *handle, 2813static int ext4_split_unwritten_extents(handle_t *handle,
2812 struct inode *inode, 2814 struct inode *inode,
@@ -2824,7 +2826,6 @@ static int ext4_split_unwritten_extents(handle_t *handle,
2824 unsigned int allocated, ee_len, depth; 2826 unsigned int allocated, ee_len, depth;
2825 ext4_fsblk_t newblock; 2827 ext4_fsblk_t newblock;
2826 int err = 0; 2828 int err = 0;
2827 int ret = 0;
2828 2829
2829 ext_debug("ext4_split_unwritten_extents: inode %lu," 2830 ext_debug("ext4_split_unwritten_extents: inode %lu,"
2830 "iblock %llu, max_blocks %u\n", inode->i_ino, 2831 "iblock %llu, max_blocks %u\n", inode->i_ino,
@@ -2842,12 +2843,12 @@ static int ext4_split_unwritten_extents(handle_t *handle,
2842 ext4_ext_store_pblock(&orig_ex, ext_pblock(ex)); 2843 ext4_ext_store_pblock(&orig_ex, ext_pblock(ex));
2843 2844
2844 /* 2845 /*
2845 * if the entire unintialized extent length less than 2846 * If the uninitialized extent begins at the same logical
2846 * the size of extent to write, there is no need to split 2847 * block where the write begins, and the write completely
2847 * uninitialized extent 2848 * covers the extent, then we don't need to split it.
2848 */ 2849 */
2849 if (allocated <= max_blocks) 2850 if ((iblock == ee_block) && (allocated <= max_blocks))
2850 return ret; 2851 return allocated;
2851 2852
2852 err = ext4_ext_get_access(handle, inode, path + depth); 2853 err = ext4_ext_get_access(handle, inode, path + depth);
2853 if (err) 2854 if (err)