From: Dave Chinner <david@fromorbit.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2 2/2] xfs: use sync buffer I/O for sync delwri queue submission
Date: Thu, 14 Jun 2018 08:08:07 +1000 [thread overview]
Message-ID: <20180613220807.GG10363@dastard> (raw)
In-Reply-To: <20180613110516.65494-3-bfoster@redhat.com>
On Wed, Jun 13, 2018 at 07:05:16AM -0400, Brian Foster wrote:
> If a delwri queue occurs of a buffer that sits on a delwri queue
> wait list, the queue sets _XBF_DELWRI_Q without changing the state
> of ->b_list. This occurs, for example, if another thread beats the
> current delwri waiter thread to the buffer lock after I/O
> completion. Once the waiter acquires the lock, it removes the buffer
> from the wait list and leaves a buffer with _XBF_DELWRI_Q set but
> not populated on a list. This results in a lost buffer submission
> and in turn can result in assert failures due to _XBF_DELWRI_Q being
> set on buffer reclaim or filesystem lockups if the buffer happens to
> cover an item in the AIL.
>
> This problem has been reproduced by repeated iterations of xfs/305
> on high CPU count (28xcpu) systems with limited memory (~1GB). Dirty
> dquot reclaim races with an xfsaild push of a separate dquot backed
> by the same buffer such that the buffer sits on the reclaim wait
> list at the time xfsaild attempts to queue it. Since the latter
> dquot has been flush locked but the underlying buffer not submitted
> for I/O, the dquot pins the AIL and causes the filesystem to
> livelock.
>
> This race is essentially made possible by the buffer lock cycle
> involved with waiting on a synchronous delwri queue submission.
> Close the race by using synchronous buffer I/O for respective delwri
> queue submission. This means the buffer remains locked across the
> I/O and so is inaccessible from other contexts while in the
> intermediate wait list state. The sync buffer I/O wait mechanism is
> factored into a helper such that sync delwri buffer submission and
> serialization are batched operations.
>
> Designed-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
Just something I noticed on a initial brief scan:
> @@ -2013,21 +2017,22 @@ xfs_buf_delwri_submit_buffers(
> trace_xfs_buf_delwri_split(bp, _RET_IP_);
>
> /*
> - * We do all IO submission async. This means if we need
> - * to wait for IO completion we need to take an extra
> - * reference so the buffer is still valid on the other
> - * side. We need to move the buffer onto the io_list
> - * at this point so the caller can still access it.
> + * If we have a wait list, each buffer (and associated delwri
> + * queue reference) transfers to it and is submitted
> + * synchronously. Otherwise, drop the buffer from the delwri
> + * queue and submit async.
> */
> bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_WRITE_FAIL);
> - bp->b_flags |= XBF_WRITE | XBF_ASYNC;
> + bp->b_flags |= XBF_WRITE;
> if (wait_list) {
> - xfs_buf_hold(bp);
> + bp->b_flags &= ~XBF_ASYNC;
> list_move_tail(&bp->b_list, wait_list);
> - } else
> + __xfs_buf_submit(bp);
We lose a buffer submission tracepoint here.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2018-06-13 22:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 11:05 [PATCH v2 0/2] xfs: fix buffer delwri queue state race Brian Foster
2018-06-13 11:05 ` [PATCH v2 1/2] xfs: refactor buffer submission into a common helper Brian Foster
2018-06-14 13:43 ` [PATCH v3 " Brian Foster
2018-06-15 11:24 ` Christoph Hellwig
2018-06-15 11:53 ` Brian Foster
2018-06-13 11:05 ` [PATCH v2 2/2] xfs: use sync buffer I/O for sync delwri queue submission Brian Foster
2018-06-13 22:08 ` Dave Chinner [this message]
2018-06-13 23:29 ` Brian Foster
2018-06-13 23:37 ` Dave Chinner
2018-06-15 11:28 ` Christoph Hellwig
2018-06-15 11:53 ` Brian Foster
2018-06-15 12:16 ` Christoph Hellwig
2018-06-15 12:39 ` Brian Foster
2018-06-15 16:31 ` Darrick J. Wong
2018-06-15 17:43 ` Brian Foster
2018-06-18 11:21 ` Christoph Hellwig
2018-06-18 11:47 ` Brian Foster
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=20180613220807.GG10363@dastard \
--to=david@fromorbit.com \
--cc=bfoster@redhat.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;
as well as URLs for NNTP newsgroup(s).