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=1793213558; b=CFzutS4F5pCpOF4orbF8nocIxhEDmKfdaYp+hg59NRYP8wQedyxDlnpVvzZ1Tp5aP/oF PpnGleq6MiMiCEvJvADry4nYtr5pSdFbsIvzCZWmJc1yAEtWawOfJgG0K51x8kMF3Gkfa misB0Uv4yC1RZeZh/LhJ7xfnXWpl3o0Mbuu8r8GfjLoT436lhUk5TuI9CesFVnk/g16oO GImZDStiLr5m1f8JBTJPwL1654tWq8QiDiv60RqR2d2i4Vq7sLPGqgT9spD9JuKmGALj9 ownb016ishj87PO/N5NoPac11PVDwnL5wuAylO9Pm9X6GGeO5TghJmpxZX7cCGDEQPg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793213558; 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=ZQzahXW3ce6SlxuZnW1Dw7xrw+a6ouiQ2tZx0kgyWms=; b=uObEYdJ/ZtxNDqOPpKC2gG86N42LWtDTHR0CwPxs1BwObq3HQ02cp3oaA7PMFkMiFdNs WkORPxQGEqpBoZyz6QY9IWrqTK3+Dw6adcYNx/tbKqSbPgevUJGgsFe86h/U8x1XYMUls GzPqL+J59XOo1SYxcD61vUJj5NiyEHlHC0FQMYQbU0Z2Wg8h1R3KeVtLLZPA6hLazKpNA VucC4zVTHh7FcGaRBODj2gFMzDliVfLH/sPnX00uYTpE+yPQoRvHXCtAhL53CdLq3+9Co EgOoURCoT3sCyo7tFm+Z7c79xOg3Zlmgp1fz9xqBXcqj4gXwaWe6MT54zoEh78t4/eg== 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=kH6zowC7; 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 CA94B606A31A; Wed, 28 Oct 2026 18:52:37 +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=kH6zowC7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B16E1F01829; Wed, 28 Oct 2026 18:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793213557; bh=ZQzahXW3ce6SlxuZnW1Dw7xrw+a6ouiQ2tZx0kgyWms=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kH6zowC7wmvSHuEb6slsQIpCvHzPn5D+vdsm72ed8VlsF5NWPxrnRemMKJJrQYz9k VdcZUiknI4vSSLCy695Bgycbqg++sxEK9jxtGfj83+iwAlIjtFvPza2G1Le2wYajl7 2mWTQFDyW89vIiZi2RTs1nulro03cA1QuDm11b7c= 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 6.1 0548/1887] xfs: rearrange code in xfs_buf_item.c Date: Wed, 28 Oct 2026 17:44:04 +0100 Message-ID: <20261028170511.836992368@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170459.200466217@linuxfoundation.org> References: <20261028170459.200466217@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Chinner [ Upstream commit d2fe5c4c8d25999862d615f616aea7befdd62799 ] The code to initialise, release and free items is all the way down the bottom of the file. Upcoming fixes need to these functions earlier in the file, so move them to the top. There is one code change in this move - the parameter to xfs_buf_item_relse() is changed from the xfs_buf to the xfs_buf_log_item - the thing that the function is releasing. Signed-off-by: Dave Chinner Reviewed-by: Carlos Maiolino Signed-off-by: Carlos Maiolino 6.6: Fixed conflict due to the following missing commits: [Continuous range: 10634530f7ba^..d4c75a1b40cd] d4c75a1b40cd ("xfs: convert remaining kmem_free() to kfree()") 49292576136f ("xfs: convert kmem_free() for kvmalloc users to kvfree()") afdc115559c5 ("xfs: move kmem_to_page()") f078d4ea8276 ("xfs: convert kmem_alloc() to kmalloc()") 10634530f7ba ("xfs: convert kmem_zalloc() to kzalloc()") Removed ASSERT in favour of existing atomic_read-and-return in xfs_buf_item_relse() due to the following missing commit: 3762113b597f ("xfs: don't lose solo superblock counter update transactions") Signed-off-by: Siddh Raman Pant Signed-off-by: Sasha Levin --- fs/xfs/xfs_buf_item.c | 118 +++++++++++++++++++++--------------------- fs/xfs/xfs_buf_item.h | 1 - 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 72d6e2dd5ef54..1b323b3c0eb93 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c @@ -32,6 +32,63 @@ static inline struct xfs_buf_log_item *BUF_ITEM(struct xfs_log_item *lip) return container_of(lip, struct xfs_buf_log_item, bli_item); } +static void +xfs_buf_item_get_format( + struct xfs_buf_log_item *bip, + int count) +{ + ASSERT(bip->bli_formats == NULL); + bip->bli_format_count = count; + + if (count == 1) { + bip->bli_formats = &bip->__bli_format; + return; + } + + bip->bli_formats = kmem_zalloc(count * sizeof(struct xfs_buf_log_format), + 0); +} + +static void +xfs_buf_item_free_format( + struct xfs_buf_log_item *bip) +{ + if (bip->bli_formats != &bip->__bli_format) { + kmem_free(bip->bli_formats); + bip->bli_formats = NULL; + } +} + +static void +xfs_buf_item_free( + struct xfs_buf_log_item *bip) +{ + xfs_buf_item_free_format(bip); + kmem_free(bip->bli_item.li_lv_shadow); + kmem_cache_free(xfs_buf_item_cache, bip); +} + +/* + * xfs_buf_item_relse() is called when the buf log item is no longer needed. + */ +static void +xfs_buf_item_relse( + struct xfs_buf_log_item *bip) +{ + struct xfs_buf *bp = bip->bli_buf; + + trace_xfs_buf_item_relse(bp, _RET_IP_); + + ASSERT(!test_bit(XFS_LI_IN_AIL, &bip->bli_item.li_flags)); + + if (atomic_read(&bip->bli_refcount)) + return; + + bp->b_log_item = NULL; + xfs_buf_rele(bp); + xfs_buf_item_free(bip); +} + /* Is this log iovec plausibly large enough to contain the buffer log format? */ bool xfs_buf_log_check_iovec( @@ -563,7 +620,7 @@ xfs_buf_item_unpin( ASSERT(list_empty(&bp->b_li_list)); } else { xfs_trans_ail_delete(lip, SHUTDOWN_LOG_IO_ERROR); - xfs_buf_item_relse(bp); + xfs_buf_item_relse(bip); ASSERT(bp->b_log_item == NULL); } xfs_buf_relse(bp); @@ -673,7 +730,7 @@ xfs_buf_item_put( */ if (aborted) xfs_trans_ail_delete(lip, 0); - xfs_buf_item_relse(bip->bli_buf); + xfs_buf_item_relse(bip); return true; } @@ -824,33 +881,6 @@ static const struct xfs_item_ops xfs_buf_item_ops = { .iop_push = xfs_buf_item_push, }; -STATIC void -xfs_buf_item_get_format( - struct xfs_buf_log_item *bip, - int count) -{ - ASSERT(bip->bli_formats == NULL); - bip->bli_format_count = count; - - if (count == 1) { - bip->bli_formats = &bip->__bli_format; - return; - } - - bip->bli_formats = kmem_zalloc(count * sizeof(struct xfs_buf_log_format), - 0); -} - -STATIC void -xfs_buf_item_free_format( - struct xfs_buf_log_item *bip) -{ - if (bip->bli_formats != &bip->__bli_format) { - kmem_free(bip->bli_formats); - bip->bli_formats = NULL; - } -} - /* * Allocate a new buf log item to go with the given buffer. * Set the buffer's b_log_item field to point to the new @@ -1072,34 +1102,6 @@ xfs_buf_item_dirty_format( return false; } -STATIC void -xfs_buf_item_free( - struct xfs_buf_log_item *bip) -{ - xfs_buf_item_free_format(bip); - kmem_free(bip->bli_item.li_lv_shadow); - kmem_cache_free(xfs_buf_item_cache, bip); -} - -/* - * xfs_buf_item_relse() is called when the buf log item is no longer needed. - */ -void -xfs_buf_item_relse( - struct xfs_buf *bp) -{ - struct xfs_buf_log_item *bip = bp->b_log_item; - - trace_xfs_buf_item_relse(bp, _RET_IP_); - ASSERT(!test_bit(XFS_LI_IN_AIL, &bip->bli_item.li_flags)); - - if (atomic_read(&bip->bli_refcount)) - return; - bp->b_log_item = NULL; - xfs_buf_rele(bp); - xfs_buf_item_free(bip); -} - void xfs_buf_item_done( struct xfs_buf *bp) @@ -1119,5 +1121,5 @@ xfs_buf_item_done( xfs_trans_ail_delete(&bp->b_log_item->bli_item, (bp->b_flags & _XBF_LOGRECOVERY) ? 0 : SHUTDOWN_CORRUPT_INCORE); - xfs_buf_item_relse(bp); + xfs_buf_item_relse(bp->b_log_item); } diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h index 7ddda0aa9dac2..8a8a46e698be4 100644 --- a/fs/xfs/xfs_buf_item.h +++ b/fs/xfs/xfs_buf_item.h @@ -49,7 +49,6 @@ struct xfs_buf_log_item { int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *); void xfs_buf_item_done(struct xfs_buf *bp); -void xfs_buf_item_relse(struct xfs_buf *); bool xfs_buf_item_put(struct xfs_buf_log_item *); void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint); bool xfs_buf_item_dirty_format(struct xfs_buf_log_item *); -- 2.53.0