linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Btrfs: fix the race between write back and nocow buffered write
@ 2013-12-27 13:11 Miao Xie
  2013-12-27 13:11 ` [PATCH 2/2] Btrfs: fix the wrong nocow range check Miao Xie
  2014-01-08 15:09 ` [PATCH 1/2] Btrfs: fix the race between write back and nocow buffered write Josef Bacik
  0 siblings, 2 replies; 4+ messages in thread
From: Miao Xie @ 2013-12-27 13:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: t-itoh

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>
---
 fs/btrfs/file.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 82d0342..f6960c2 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1523,7 +1523,6 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
 		}
 
 		release_bytes = 0;
-		btrfs_drop_pages(pages, num_pages);
 
 		if (only_release_metadata && copied > 0) {
 			u64 lockstart = round_down(pos, root->sectorsize);
@@ -1536,6 +1535,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
 			only_release_metadata = false;
 		}
 
+		btrfs_drop_pages(pages, num_pages);
+
 		cond_resched();
 
 		balance_dirty_pages_ratelimited(inode->i_mapping);
-- 
1.8.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-09  2:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-27 13:11 [PATCH 1/2] Btrfs: fix the race between write back and nocow buffered write Miao Xie
2013-12-27 13:11 ` [PATCH 2/2] Btrfs: fix the wrong nocow range check Miao Xie
2014-01-08 15:09 ` [PATCH 1/2] Btrfs: fix the race between write back and nocow buffered write Josef Bacik
2014-01-09  2:06   ` [PATCH V2 " Miao Xie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).