From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: xfs <linux-xfs@vger.kernel.org>, Dave Chinner <david@fromorbit.com>
Subject: Re: [PATCH] xfs: abort unaligned nowait directio early
Date: Wed, 17 Apr 2019 11:35:51 -0400 [thread overview]
Message-ID: <20190417153550.GC16377@bfoster> (raw)
In-Reply-To: <20190417144006.GH114154@magnolia>
On Wed, Apr 17, 2019 at 07:40:06AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Dave Chinner noticed that xfs_file_dio_aio_write returns EAGAIN without
> dropping the IOLOCK when its deciding not to wait, which means that we
> leak the IOLOCK there. Since we now make unaligned directio always
> wait, we have the opportunity to bail out before trying to take the
> lock, which should reduce the overhead of this never-gonna-work case
> considerably while also solving the dropped lock problem.
>
> Reported-by: Dave Chinner <david@fromorbit.com>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/xfs_file.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index cdcc75735521..3a45e3b0efa7 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -517,6 +517,9 @@ xfs_file_dio_aio_write(
> }
>
> if (iocb->ki_flags & IOCB_NOWAIT) {
> + /* unaligned dio always waits, bail */
> + if (unaligned_io)
> + return -EAGAIN;
> if (!xfs_ilock_nowait(ip, iolock))
> return -EAGAIN;
> } else {
> @@ -536,9 +539,6 @@ xfs_file_dio_aio_write(
> * xfs_file_aio_write_checks() for other reasons.
> */
> if (unaligned_io) {
> - /* unaligned dio always waits, bail */
> - if (iocb->ki_flags & IOCB_NOWAIT)
> - return -EAGAIN;
> inode_dio_wait(inode);
> } else if (iolock == XFS_IOLOCK_EXCL) {
> xfs_ilock_demote(ip, XFS_IOLOCK_EXCL);
next prev parent reply other threads:[~2019-04-17 15:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 14:40 [PATCH] xfs: abort unaligned nowait directio early Darrick J. Wong
2019-04-17 15:35 ` Brian Foster [this message]
2019-04-17 21:53 ` Dave Chinner
2019-04-23 6:22 ` 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=20190417153550.GC16377@bfoster \
--to=bfoster@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=linux-xfs@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