From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793209341; b=YQSYOjCCakqYMxt7EHd4HVEyR+1UVk/B56V+f3N19qPmYO3DVfS0MogsDec4AtI48sJJ Ire3YfT4ka/ZI5RA/JpsbTf+fWcXBadtll8aw44k7iAMWFwbHNiA2/lHeuK+sQ9I7K7EA 9H1nuvonwiTMMaxWXDYwXHZrFAEo3MAMHTEeW8DoLl3j+we6blIOJxqgj7lFny9EZiLkk KgIgf253FFafs9XRLwLNIc9fLicDW23jBHs4t4RZK6ZqNlNA6zcTuunpvDlLCgPbwa5Du 9/vHNaI137foFOMJZX8U7985TFj5JUIkEoY20sQH6Dl0MAqY8V9UBbbOu+IeukM2jOw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793209341; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=M9okiJa0GuEAZyb/0uwvD3db+1K2G1knn/s+A8+zm6U=; b=Jpo3Bmvteud6X6kUHDbj881HAX7tN6EpFczXfxLadyZcYA5Wx0MMmINdTX3MprlgOwPO K/Rso89W8pALc38Y3Jjq2mo7U4lHIeDgkP2rfOv+LYwAotzJy5MZ2cjGz5kGx3c1JiLkw r95ThNCHZnPF92oya+5anznKJ2yDolV0OQDVb0WgQ84nBVPYrISw6nKDIPWhpdp5uztil 67SzVasfUQSby8PE1WprD6OSfHe4cVncpjFsgEUdJG1U9Ml6F2xCcuk5QaQwAzcyFiJ+3 /mut9FR5QdG9YOqzp42/wFnzxOfw2xNv5l5aatzOybLOSJvW8V2iUmGk/COZmodHLYQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=EJ2GbeFM; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76D61606A31C; Wed, 28 Oct 2026 17:42:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=EJ2GbeFM Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8200B1F01825; Wed, 28 Oct 2026 17:42:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793209341; bh=M9okiJa0GuEAZyb/0uwvD3db+1K2G1knn/s+A8+zm6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EJ2GbeFM/QEH7u3pSN8UVz1eJ9+3ic7rnYLJV7SfEtfkj+RfM03JFzllVgNi1e9Ej dO1Yn/xumtn5EmwL1wF7U2jwgUCeip1u8y6I5MXQMrFGprlWNgUb00nFrPOLeu5Z2u Hf4KIuh33pvEg33VRC5R4zl/KYMdH3zSx/pDCDsk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dave Chinner , Carlos Maiolino , Carlos Maiolino , Siddh Raman Pant , Sasha Levin Subject: [PATCH 5.10 420/516] xfs: factor out stale buffer item completion Date: Wed, 28 Oct 2026 17:59:32 +0100 Message-ID: <20261028170013.437101626@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170003.522232767@linuxfoundation.org> References: <20261028170003.522232767@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Chinner [ Upstream commit 816c330b605c3f4813c0dc0ab5af5cce17ff06b3 ] 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 Reviewed-by: Carlos Maiolino Signed-off-by: Carlos Maiolino Signed-off-by: Siddh Raman Pant Signed-off-by: Sasha Levin --- 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 3124f96ad6b32..3a96279f97a1a 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c @@ -459,6 +459,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 @@ -508,13 +544,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); /* @@ -525,22 +554,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