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=1793211701; b=Js05mwopfea++YE4cEdgkTZFlziAaeOmbkEdo1KaHwHCY0YJvfb3bKvedEimoiveS5uh biE/AfLt3zDCPvijC0G7mzTlPW8cy1giJjM0jmbAM+DhdDCDrv9FpeGdPRQ8NWonI4RxO sdUnaG/Qx+/azaaXoL0fQ55qweNbD8WEN6Zg89fFjGbeek4P2mgATS1XmZtfc2HEyFftE AUYjphaG0uxTocdeHJGuZJhOCQz9Rxt7r/VTc8STQsMACryiC92Qi73bp5bqg9kMdCOzc 61tSSb0H1zrj8KsBzlzKGnKambWBucpyRfQxRtxtoLDg1UfD8RVvue4zhkW1pMkYCwg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793211701; 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=jwIhR5LD48T+4yjRFKiW1ojSIvNDuHx7DuQVQQfEw+o=; b=Ez2ZFQSkQi3ImiMyBsdPQq40SC/wK9viVkeMV/C0OFWOldCBn/ywmkWZvEul0q3cjSD1 W+sYtUISPm1U0UQtNUwugvaclfakCmdaMRNihUgRo1mGr+3730KpJjYb6FTZe223vNkAo h5trQuZLNRbY1zl+Tp8X+xmac3WvMk0bInxCH4IL9eTtXBaNiaVjgJW1Uc2GQJQFzx2me 6/0Ix2J73Ye64aYnZtqHnuy7biph7T3Zn7fKhFia0Ewxss1iWHyMO9apEhaBTp46n/aeb WC0uKDasiOMGUoEiUZqO06KnWAJltGpRt7FBpf6fHULrhwxPkBrZB/fZqz0MP+xCLXg== 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=P5HF2GOK; 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 D1F35606A322; Wed, 28 Oct 2026 18:21:40 +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=P5HF2GOK Received: by smtp.kernel.org (Postfix) with ESMTPSA id F29311F01828; Wed, 28 Oct 2026 18:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793211700; bh=jwIhR5LD48T+4yjRFKiW1ojSIvNDuHx7DuQVQQfEw+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=P5HF2GOKYSt/hpUjnJuwWK1A4rDE8RZQPVJTwDlCQKymXOQX6QmK/Mqvj47vJ29Dh cEbUkZlOBkjsdfnJSICv8suNKIa+3VuSfHQCvs4kWrEqZ0sigTfMZTb9AphmoU8KU7 8+lUssjAzOx+TsrCv45IhoPPwkI3bCZZ2+7bycsg= 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.15 463/571] xfs: rearrange code in xfs_buf_item.c Date: Wed, 28 Oct 2026 18:00:10 +0100 Message-ID: <20261028170019.008924219@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170008.009143722@linuxfoundation.org> References: <20261028170008.009143722@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.15-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") 5.15: Fixed conflict due to the following missing commit: 182696fb021f ("xfs: rename _zone variables to _cache") 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 e0c75aa3cca8a..ebcaccc4ad66b 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c @@ -31,6 +31,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_zone, 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( @@ -562,7 +619,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); @@ -672,7 +729,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; } @@ -792,33 +849,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 @@ -1040,34 +1070,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_zone, 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) @@ -1087,5 +1089,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 50aa0f5ef9590..e3ccbf3ca8014 100644 --- a/fs/xfs/xfs_buf_item.h +++ b/fs/xfs/xfs_buf_item.h @@ -51,7 +51,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