aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2012-08-22 22:10:38 -0400
committerChris Mason <chris.mason@oracle.com>2012-08-28 16:53:41 -0400
commit24c03fa5cf3d02c327cf9f2fc39f72664b1bd7e1 (patch)
treeb0e14cbc951996a4b33fa81e7a19d092e08398d5 /fs/btrfs/inode.c
parentbd7de2c9a449e26a5493d918618eb20ae60d56bd (diff)
Btrfs: fix a dio write regression
This bug is introduced by commit 3b8bde746f6f9bd36a9f05f5f3b6e334318176a9 (Btrfs: lock extents as we map them in DIO). In dio write, we should unlock the section which we didn't do IO on in case that we fall back to buffered write. But we need to not only unlock the section but also cleanup reserved space for the section. This bug was found while running xfstests 133, with this 133 no longer complains. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0808f483dafa..38cda78de5e4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5992,11 +5992,27 @@ unlock:
5992 * in the case of read we need to unlock only the end area that we 5992 * in the case of read we need to unlock only the end area that we
5993 * aren't using if there is any left over space. 5993 * aren't using if there is any left over space.
5994 */ 5994 */
5995 if (lockstart < lockend) 5995 if (lockstart < lockend) {
5996 clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend, 5996 if (create && len < lockend - lockstart) {
5997 unlock_bits, 1, 0, &cached_state, GFP_NOFS); 5997 clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
5998 else 5998 lockstart + len - 1, unlock_bits, 1, 0,
5999 &cached_state, GFP_NOFS);
6000 /*
6001 * Beside unlock, we also need to cleanup reserved space
6002 * for the left range by attaching EXTENT_DO_ACCOUNTING.
6003 */
6004 clear_extent_bit(&BTRFS_I(inode)->io_tree,
6005 lockstart + len, lockend,
6006 unlock_bits | EXTENT_DO_ACCOUNTING,
6007 1, 0, NULL, GFP_NOFS);
6008 } else {
6009 clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
6010 lockend, unlock_bits, 1, 0,
6011 &cached_state, GFP_NOFS);
6012 }
6013 } else {
5999 free_extent_state(cached_state); 6014 free_extent_state(cached_state);
6015 }
6000 6016
6001 free_extent_map(em); 6017 free_extent_map(em);
6002 6018