mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Siddh Raman Pant <siddh.raman.pant@oracle.com>
To: stable@vger.kernel.org, Greg KH <gregkh@linuxfoundation.org>,
	"Darrick J . Wong" <djwong@kernel.org>,
	Dave Chinner <dchinner@redhat.com>
Cc: linux-kernel@vger.kernel.org, Mark Tinguely <mark.tinguely@oracle.com>
Subject: [PATCH 6.6 5/6] xfs: factor out stale buffer item completion
Date: Thu,  1 Oct 2026 20:21:02 +0530	[thread overview]
Message-ID: <5f5505bf568c70ceb96f1e33e289eb4e153c4eef.1790864521.git.siddh.raman.pant@oracle.com> (raw)
In-Reply-To: <cover.1790864521.git.siddh.raman.pant@oracle.com>

From: Dave Chinner <dchinner@redhat.com>

The stale buffer item completion handling is currently only done
from BLI unpinning. We need to perform this function from where-ever
the last reference to the BLI is dropped, so first we need to
factor this code out into a helper.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
(cherry picked from commit 816c330b605c3f4813c0dc0ab5af5cce17ff06b3)
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
 fs/xfs/xfs_buf_item.c | 60 ++++++++++++++++++++++++++-----------------
 1 file changed, 37 insertions(+), 23 deletions(-)

diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 033ec1e2f2df..f13df8adcf4a 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -539,6 +539,42 @@ xfs_buf_item_pin(
 	atomic_inc(&bip->bli_buf->b_pin_count);
 }
 
+/*
+ * For a stale BLI, process all the necessary completions that must be
+ * performed when the final BLI reference goes away. The buffer will be
+ * referenced and locked here - we return to the caller with the buffer still
+ * referenced and locked for them to finalise processing of the buffer.
+ */
+static void
+xfs_buf_item_finish_stale(
+	struct xfs_buf_log_item	*bip)
+{
+	struct xfs_buf		*bp = bip->bli_buf;
+	struct xfs_log_item	*lip = &bip->bli_item;
+
+	ASSERT(bip->bli_flags & XFS_BLI_STALE);
+	ASSERT(xfs_buf_islocked(bp));
+	ASSERT(bp->b_flags & XBF_STALE);
+	ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL);
+	ASSERT(list_empty(&lip->li_trans));
+	ASSERT(!bp->b_transp);
+
+	if (bip->bli_flags & XFS_BLI_STALE_INODE) {
+		xfs_buf_item_done(bp);
+		xfs_buf_inode_iodone(bp);
+		ASSERT(list_empty(&bp->b_li_list));
+		return;
+	}
+
+	/*
+	 * We may or may not be on the AIL here, xfs_trans_ail_delete() will do
+	 * the right thing regardless of the situation in which we are called.
+	 */
+	xfs_trans_ail_delete(lip, SHUTDOWN_LOG_IO_ERROR);
+	xfs_buf_item_relse(bip);
+	ASSERT(bp->b_log_item == NULL);
+}
+
 /*
  * This is called to unpin the buffer associated with the buf log item which was
  * previously pinned with a call to xfs_buf_item_pin().  We enter this function
@@ -588,13 +624,6 @@ xfs_buf_item_unpin(
 	}
 
 	if (stale) {
-		ASSERT(bip->bli_flags & XFS_BLI_STALE);
-		ASSERT(xfs_buf_islocked(bp));
-		ASSERT(bp->b_flags & XBF_STALE);
-		ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL);
-		ASSERT(list_empty(&lip->li_trans));
-		ASSERT(!bp->b_transp);
-
 		trace_xfs_buf_item_unpin_stale(bip);
 
 		/*
@@ -605,22 +634,7 @@ xfs_buf_item_unpin(
 		 * processing is complete.
 		 */
 		xfs_buf_rele(bp);
-
-		/*
-		 * If we get called here because of an IO error, we may or may
-		 * not have the item on the AIL. xfs_trans_ail_delete() will
-		 * take care of that situation. xfs_trans_ail_delete() drops
-		 * the AIL lock.
-		 */
-		if (bip->bli_flags & XFS_BLI_STALE_INODE) {
-			xfs_buf_item_done(bp);
-			xfs_buf_inode_iodone(bp);
-			ASSERT(list_empty(&bp->b_li_list));
-		} else {
-			xfs_trans_ail_delete(lip, SHUTDOWN_LOG_IO_ERROR);
-			xfs_buf_item_relse(bip);
-			ASSERT(bp->b_log_item == NULL);
-		}
+		xfs_buf_item_finish_stale(bip);
 		xfs_buf_relse(bp);
 		return;
 	}
-- 
2.53.0


  parent reply	other threads:[~2026-10-01 14:52 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2026090954-revisit-dowry-37ee@gregkh>
2026-10-01 14:50 ` [PATCH 6.12 0/6] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-01 14:50   ` [PATCH 6.12 1/6] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-01 14:50   ` [PATCH 6.12 2/6] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-01 14:50   ` [PATCH 6.12 3/6] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-01 14:50   ` [PATCH 6.12 4/6] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-01 14:50   ` [PATCH 6.12 5/6] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-01 14:50   ` [PATCH 6.12 6/6] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-02 14:19   ` [PATCH 6.12 0/6] Backport of XFS umount hang fixes Sasha Levin
2026-10-01 14:50 ` [PATCH 6.6 " Siddh Raman Pant
2026-10-01 14:50   ` [PATCH 6.6 1/6] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-01 14:50   ` [PATCH 6.6 2/6] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 6.6 3/6] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 6.6 4/6] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-01 14:51   ` Siddh Raman Pant [this message]
2026-10-01 14:51   ` [PATCH 6.6 6/6] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 00/21] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 01/21] xfs: hoist recovered bmap intent checks out of xfs_bui_item_recover Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 02/21] xfs: improve the code that checks recovered bmap intent items Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 03/21] xfs: hoist recovered rmap intent checks out of xfs_rui_item_recover Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 04/21] xfs: improve the code that checks recovered rmap intent items Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 05/21] xfs: hoist recovered refcount intent checks out of xfs_cui_item_recover Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 06/21] xfs: improve the code that checks recovered refcount intent items Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 07/21] xfs: don't nest icloglock inside ic_callback_lock Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 08/21] xfs: convert XLOG_FORCED_SHUTDOWN() to xlog_is_shutdown() Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 09/21] xfs: log items should have a xlog pointer, not a mount Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 10/21] xfs: aborting inodes on shutdown may need buffer lock Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 11/21] xfs: remove xfs_buf_t typedef Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 12/21] xfs: fix super block buf log item UAF during force shutdown Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 13/21] xfs: fix intermittent hang during quotacheck Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 14/21] xfs: dquot shrinker doesn't check for XFS_DQFLAG_FREEING Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 15/21] xfs: buffer pins need to hold a buffer reference Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 16/21] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 17/21] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 18/21] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 19/21] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 20/21] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.10 21/21] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.1 0/6] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 6.1 1/6] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 6.1 2/6] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 6.1 3/6] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 6.1 4/6] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 6.1 5/6] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 6.1 6/6] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 00/11] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 01/11] xfs: log items should have a xlog pointer, not a mount Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 02/11] xfs: aborting inodes on shutdown may need buffer lock Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 03/11] xfs: fix super block buf log item UAF during force shutdown Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 04/11] xfs: dquot shrinker doesn't check for XFS_DQFLAG_FREEING Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 05/11] xfs: buffer pins need to hold a buffer reference Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 06/11] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 07/11] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 08/11] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 09/11] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 10/11] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-01 14:51   ` [PATCH 5.15 11/11] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant

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=5f5505bf568c70ceb96f1e33e289eb4e153c4eef.1790864521.git.siddh.raman.pant@oracle.com \
    --to=siddh.raman.pant@oracle.com \
    --cc=dchinner@redhat.com \
    --cc=djwong@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.tinguely@oracle.com \
    --cc=stable@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

all inboxes | Powered by JetHome®