All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 1/2] xfs: define internal buf flag for delwri queue wait list
Date: Thu,  7 Jun 2018 08:41:24 -0400	[thread overview]
Message-ID: <20180607124125.38700-2-bfoster@redhat.com> (raw)
In-Reply-To: <20180607124125.38700-1-bfoster@redhat.com>

The delwri queue mechanism does not provide the ability to
distinguish between stale (or lazily removed) buffers in a delwri
queue and buffers that have been submitted from a delwri queue and
sit on a wait list. Buffers in both cases have the _XBF_DELWRI_Q
flag cleared and ->b_list as a member of an associated list. This
means that a queue of a buffer cannot always tell if a buffer is
actually on a delwri queue if ->b_list is non-empty and
_XBF_DELWRI_Q is not already set.

Define a new flag for wait listed buffers to distinguish this case
and prepare to handle it properly. This patch defines, sets and
clears the _XBF_DELWRI_W flag at the appropriate places and
otherwise does not change behavior.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_buf.c | 5 +++--
 fs/xfs/xfs_buf.h | 4 +++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 980bc48979e9..912cbbf44db7 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -2033,6 +2033,7 @@ xfs_buf_delwri_submit_buffers(
 		bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_WRITE_FAIL);
 		bp->b_flags |= XBF_WRITE | XBF_ASYNC;
 		if (wait_list) {
+			bp->b_flags |= _XBF_DELWRI_W;
 			xfs_buf_hold(bp);
 			list_move_tail(&bp->b_list, wait_list);
 		} else
@@ -2083,10 +2084,10 @@ xfs_buf_delwri_submit(
 	while (!list_empty(&wait_list)) {
 		bp = list_first_entry(&wait_list, struct xfs_buf, b_list);
 
-		list_del_init(&bp->b_list);
-
 		/* locking the buffer will wait for async IO completion. */
 		xfs_buf_lock(bp);
+		bp->b_flags &= ~_XBF_DELWRI_W;
+		list_del_init(&bp->b_list);
 		error2 = bp->b_error;
 		xfs_buf_relse(bp);
 		if (!error)
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index d24dbd4dac39..07409b72dcad 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -50,7 +50,8 @@ typedef enum {
 #define _XBF_PAGES	 (1 << 20)/* backed by refcounted pages */
 #define _XBF_KMEM	 (1 << 21)/* backed by heap memory */
 #define _XBF_DELWRI_Q	 (1 << 22)/* buffer on a delwri queue */
-#define _XBF_COMPOUND	 (1 << 23)/* compound buffer */
+#define _XBF_DELWRI_W	 (1 << 23)/* buffer on a delwri wait list */
+#define _XBF_COMPOUND	 (1 << 24)/* compound buffer */
 
 typedef unsigned int xfs_buf_flags_t;
 
@@ -71,6 +72,7 @@ typedef unsigned int xfs_buf_flags_t;
 	{ _XBF_PAGES,		"PAGES" }, \
 	{ _XBF_KMEM,		"KMEM" }, \
 	{ _XBF_DELWRI_Q,	"DELWRI_Q" }, \
+	{ _XBF_DELWRI_W,	"DELWRI_W" }, \
 	{ _XBF_COMPOUND,	"COMPOUND" }
 
 
-- 
2.17.1


  reply	other threads:[~2018-06-07 12:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 12:41 [PATCH 0/2] xfs: fix buffer delwri queue state race Brian Foster
2018-06-07 12:41 ` Brian Foster [this message]
2018-06-07 12:41 ` [PATCH 2/2] xfs: allow delwri requeue of wait listed buffers Brian Foster
2018-06-07 23:27   ` Dave Chinner
2018-06-08 12:07     ` Brian Foster
2018-06-08 22:49       ` Dave Chinner
2018-06-09 11:26         ` 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=20180607124125.38700-2-bfoster@redhat.com \
    --to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.