linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miao Xie <miaox@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH V2 03/10] Btrfs: just do dirty page flush for the inode with compression before direct IO
Date: Thu, 6 Mar 2014 13:54:57 +0800	[thread overview]
Message-ID: <1394085304-32589-3-git-send-email-miaox@cn.fujitsu.com> (raw)
In-Reply-To: <1394085304-32589-1-git-send-email-miaox@cn.fujitsu.com>

As the comment in the btrfs_direct_IO says, only the compressed pages need be
flush again to make sure they are on the disk, but the common pages needn't,
so we add a if statement to check if the inode has compressed pages or not,
if no, skip the flush.

And in order to prevent the write ranges from intersecting, we need wait for
the running ordered extents. But the current code waits for them twice, one
is done before the direct IO starts (in btrfs_wait_ordered_range()), the other
is before we get the blocks, it is unnecessary. because we can do the direct
IO without holding i_mutex, it means that the intersected ordered extents may
happen during the direct IO, the first wait can not avoid this problem. So we
use filemap_fdatawrite_range() instead of btrfs_wait_ordered_range() to remove
the first wait.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
Changelog v1 -> v2:
- None.
---
 fs/btrfs/inode.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 1af34d0..8c9522b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7401,15 +7401,15 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
 	smp_mb__after_atomic_inc();
 
 	/*
-	 * The generic stuff only does filemap_write_and_wait_range, which isn't
-	 * enough if we've written compressed pages to this area, so we need to
-	 * call btrfs_wait_ordered_range to make absolutely sure that any
-	 * outstanding dirty pages are on disk.
+	 * The generic stuff only does filemap_write_and_wait_range, which
+	 * isn't enough if we've written compressed pages to this area, so
+	 * we need to flush the dirty pages again to make absolutely sure
+	 * that any outstanding dirty pages are on disk.
 	 */
 	count = iov_length(iov, nr_segs);
-	ret = btrfs_wait_ordered_range(inode, offset, count);
-	if (ret)
-		return ret;
+	if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
+		     &BTRFS_I(inode)->runtime_flags))
+		filemap_fdatawrite_range(inode->i_mapping, offset, count);
 
 	if (rw & WRITE) {
 		/*
-- 
1.8.1.4


  parent reply	other threads:[~2014-03-06  5:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06  5:54 [PATCH V2 01/10] Btrfs: fix early enospc due to the race of the two ordered extent wait Miao Xie
2014-03-06  5:54 ` [PATCH V2 02/10] Btrfs: wake up the tasks that wait for the io earlier Miao Xie
2014-03-27 16:57   ` David Sterba
2014-03-06  5:54 ` Miao Xie [this message]
2014-03-06  5:54 ` [PATCH V2 04/10] Btrfs: remove the unnecessary flush when preparing the pages Miao Xie
2014-03-06  5:54 ` [PATCH V2 05/10] Btrfs: remove unnecessary lock in may_commit_transaction() Miao Xie
2014-03-06  5:55 ` [PATCH V2 06/10] Btrfs: reclaim delalloc metadata more aggressively Miao Xie
2014-03-06  5:55 ` [PATCH V2 07/10] Btrfs: don't flush all delalloc inodes when we doesn't get s_umount lock Miao Xie
2014-03-06  5:55 ` [PATCH V2 08/10] Btrfs: split the global ordered extents mutex Miao Xie
2014-03-06  5:55 ` [PATCH V2 09/10] Btrfs: fix possible empty list access when flushing the delalloc inodes Miao Xie
2014-03-06  5:55 ` [PATCH V2 10/10] Btrfs: reclaim the reserved metadata space at background Miao Xie
2014-03-10 13:35   ` Josef Bacik
2014-05-08  2:06     ` Miao Xie
2014-05-08  2:21   ` [PATCH V3] " Miao Xie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394085304-32589-3-git-send-email-miaox@cn.fujitsu.com \
    --to=miaox@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).