linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: hch@infradead.org
Cc: xfs@oss.sgi.com, linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: [PATCH 2/2] xfs: Call filemap_flush_range() for async xfs_flush_pages() call
Date: Wed,  3 Aug 2011 22:49:05 +0200	[thread overview]
Message-ID: <1312404545-15400-3-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1312404545-15400-1-git-send-email-jack@suse.cz>

XFS does its own data writeout from several places using xfs_flush_pages().
When this writeout is racing with flusher thread writing the same inode the
performance gets bad because flusher thread submits writes as normal WRITE
commands while xfs_flush_pages() submits them as WRITE_SYNC (as it uses
filemap_fdatawrite_range()) and CFQ does not merge such requests. So we end up
with relatively small requests from the flusher thread and sync interleaved.
Short excerpt from blktrace:
254,16   2    16949   103.786278461 25233  Q   W 54479888 + 424 [flush-254:16]
254,16   4    20662   103.786386751 25232  Q  WS 54492920 + 1024 [dd]
254,16   4    20665   103.786444241 25232  Q  WS 54493944 + 104 [dd]
254,16   2    16952   103.786533451 25233  Q   W 54494048 + 288 [flush-254:16]
254,16   4    20668   103.787295241 25232  Q  WS 54494336 + 1024 [dd]
254,16   4    20671   103.787332801 25232  Q  WS 54495360 + 216 [dd]
254,16   2    16955   103.789062500 25233  Q   W 54495576 + 1024 [flush-254:16]
(actually, I was observing even smaller requests on a different HW which isn't
available to me now).

Although we cannot fix all the cases (e.g. when fsync is called), we can use
filemap_flush_range() for the case when xfs_flush_pages() is called with
XFS_B_ASYNC flag which fixes the problem at least for some common cases like
the first round of sync writeback or flushing of data during truncate or after
file is closed.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/xfs/linux-2.6/xfs_fs_subr.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c
index ed88ed1..6f33164 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.c
+++ b/fs/xfs/linux-2.6/xfs_fs_subr.c
@@ -70,10 +70,12 @@ xfs_flush_pages(
 	int		ret2;
 
 	xfs_iflags_clear(ip, XFS_ITRUNCATED);
+	if (flags & XBF_ASYNC) {
+		return -filemap_flush_range(mapping, first,
+				last == -1 ? LLONG_MAX : last);
+	}
 	ret = -filemap_fdatawrite_range(mapping, first,
 				last == -1 ? LLONG_MAX : last);
-	if (flags & XBF_ASYNC)
-		return ret;
 	ret2 = xfs_wait_on_pages(ip, first, last);
 	if (!ret)
 		ret = ret2;
-- 
1.7.1


  parent reply	other threads:[~2011-08-03 20:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-03 20:49 [PATCH 0/2] Improve writeout pattern from xfs_flush_pages() Jan Kara
2011-08-03 20:49 ` [PATCH 1/2] vfs: Create filemap_flush_range() Jan Kara
2011-08-03 20:49 ` Jan Kara [this message]
2011-08-03 22:03   ` [PATCH 2/2] xfs: Call filemap_flush_range() for async xfs_flush_pages() call Christoph Hellwig
2011-08-03 22:34   ` Vivek Goyal
2011-08-04 10:03     ` Jan Kara
2011-08-03 21:42 ` [PATCH 0/2] Improve writeout pattern from xfs_flush_pages() Christoph Hellwig
2011-08-04 10:36   ` Jan Kara
2011-08-04 10:42     ` Christoph Hellwig
2011-08-04 12:07       ` Jan Kara
2011-08-04 12:19         ` Christoph Hellwig
2011-08-04 12:37           ` Jan Kara
2011-08-04 12:41             ` Christoph Hellwig

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=1312404545-15400-3-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=xfs@oss.sgi.com \
    /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).