From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 5/5] xfs: use shared ilock mode for direct IO writes by default
Date: Tue, 27 Mar 2012 12:39:13 +1100 [thread overview]
Message-ID: <20120327013913.GU5091@dastard> (raw)
In-Reply-To: <20120326211603.856796827@bombadil.infradead.org>
On Mon, Mar 26, 2012 at 05:14:26PM -0400, Christoph Hellwig wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> For the direct IO write path, we only really need the ilock to be taken in
> exclusive mode during IO submission if we need to do extent allocation
> instaled of all the time.
>
> Change the block mapping code to take the ilock in shared mode for the
> initial block mapping, and only retake it exclusively when we actually
> have to perform extent allocations. We were already dropping the ilock
> for the transaction allocation, so this doesn't introduce new race windows.
>
> Based on an earlier patch from Dave Chinner.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> ---
> fs/xfs/xfs_aops.c | 21 +++++++++++++++++----
> fs/xfs/xfs_iomap.c | 45 +++++++++++++++++++--------------------------
> 2 files changed, 36 insertions(+), 30 deletions(-)
>
> Index: xfs/fs/xfs/xfs_aops.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_aops.c 2012-03-26 21:06:52.184213212 +0200
> +++ xfs/fs/xfs/xfs_aops.c 2012-03-26 21:16:40.744358040 +0200
> @@ -1146,7 +1146,14 @@ __xfs_get_blocks(
> if (!create && direct && offset >= i_size_read(inode))
> return 0;
>
> - if (create) {
> + /*
> + * Direct I/O is usually done on preallocated files, so try getting
> + * a block mapping without an exclusive lock first. For buffer
buffered
.....
> @@ -1169,22 +1176,28 @@ __xfs_get_blocks(
> (imap.br_startblock == HOLESTARTBLOCK ||
> imap.br_startblock == DELAYSTARTBLOCK))) {
> if (direct) {
> + xfs_iunlock(ip, lockmode);
> +
> error = xfs_iomap_write_direct(ip, offset, size,
> &imap, nimaps);
> + if (error)
> + return -error;
> } else {
> error = xfs_iomap_write_delay(ip, offset, size, &imap);
> + if (error)
> + goto out_unlock;
> +
> + xfs_iunlock(ip, lockmode);
I'm not sure that I like the implicit different lock semantics here.
One function drops the lock first, the other requires the lock to be
held. Perhaps a comment is in order, such that direct IO requires
transactions for allocation here and hence will drop the lock to do
so and this avoids a needless lock round-trip?
Actually, when would we *ever* take the direct IO path when we have
imap.br_startblock == DELAYSTARTBLOCK? Buffered write regions are
supposed to have been flushed before the DIO write gets here.
Perhaps there should be an ASSERT(imap.br_startblock ==
HOLESTARTBLOCK) in the direct IO path.
Otherwise it looks OK.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-03-27 1:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-26 21:14 [PATCH 0/5] reduce exclusive ilock hold times Christoph Hellwig
2012-03-26 21:14 ` [PATCH 1/5] xfs: avoid taking the ilock unnessecarily in xfs_qm_dqattach Christoph Hellwig
2012-03-26 22:13 ` Dave Chinner
2012-03-26 21:14 ` [PATCH 2/5] xfs: reduce ilock hold times in xfs_file_aio_write_checks Christoph Hellwig
2012-03-26 22:15 ` Dave Chinner
2012-03-26 21:14 ` [PATCH 3/5] xfs: reduce ilock hold times in xfs_setattr_size Christoph Hellwig
2012-03-26 22:17 ` Dave Chinner
2012-03-26 21:14 ` [PATCH 4/5] xfs: push the ilock into xfs_zero_eof Christoph Hellwig
2012-03-27 1:15 ` Dave Chinner
2012-03-27 5:48 ` Christoph Hellwig
2012-03-27 6:11 ` Dave Chinner
2012-03-26 21:14 ` [PATCH 5/5] xfs: use shared ilock mode for direct IO writes by default Christoph Hellwig
2012-03-27 1:39 ` Dave Chinner [this message]
2012-03-27 6:08 ` [PATCH 0/5] reduce exclusive ilock hold times Dave Chinner
-- strict thread matches above, loose matches on Subject: below --
2012-03-27 14:34 [PATCH 0/5] reduce exclusive ilock hold times V2 Christoph Hellwig
2012-03-27 14:34 ` [PATCH 5/5] xfs: use shared ilock mode for direct IO writes by default Christoph Hellwig
2012-04-03 17:01 ` Mark Tinguely
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=20120327013913.GU5091@dastard \
--to=david@fromorbit.com \
--cc=hch@infradead.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