aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2014-01-08 21:06:10 -0500
committerChris Mason <clm@fb.com>2014-01-28 16:20:28 -0500
commitf1de968376340c97ac2d7acd25fa3107c398e0e5 (patch)
tree7d09c1d875d894f496bc59079143a8f09b0ccd78 /fs/btrfs
parent7ef81ac86c8a44ab9f4e6e04e1f4c9ea53615b8a (diff)
Btrfs: fix the race between write back and nocow buffered write
When we ran the 274th case of xfstests with nodatacow mount option, We met the following warning message: WARNING: CPU: 1 PID: 14185 at fs/btrfs/extent-tree.c:3734 btrfs_free_reserved_data_space+0xa6/0xd0 It is caused by the race between the write back and nocow buffered write: Task1 Task2 __btrfs_buffered_write() skip data reservation reserve the metadata space copy the data dirty the pages unlock the pages write back the pages release the data space becasue there is no noreserve flag set the noreserve flag This patch fixes this problem by unlocking the pages after the noreserve flag is set. Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/file.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 72df63b0c799..3dfd8db0e243 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1591,9 +1591,10 @@ again:
1591 unlock_extent_cached(&BTRFS_I(inode)->io_tree, 1591 unlock_extent_cached(&BTRFS_I(inode)->io_tree,
1592 lockstart, lockend, &cached_state, 1592 lockstart, lockend, &cached_state,
1593 GFP_NOFS); 1593 GFP_NOFS);
1594 btrfs_drop_pages(pages, num_pages); 1594 if (ret) {
1595 if (ret) 1595 btrfs_drop_pages(pages, num_pages);
1596 break; 1596 break;
1597 }
1597 1598
1598 release_bytes = 0; 1599 release_bytes = 0;
1599 if (only_release_metadata && copied > 0) { 1600 if (only_release_metadata && copied > 0) {
@@ -1607,6 +1608,8 @@ again:
1607 only_release_metadata = false; 1608 only_release_metadata = false;
1608 } 1609 }
1609 1610
1611 btrfs_drop_pages(pages, num_pages);
1612
1610 cond_resched(); 1613 cond_resched();
1611 1614
1612 balance_dirty_pages_ratelimited(inode->i_mapping); 1615 balance_dirty_pages_ratelimited(inode->i_mapping);