From nobody Sun Dec 14 08:03:06 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A71B7C433FE for ; Wed, 5 Oct 2022 11:39:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbiJELjS (ORCPT ); Wed, 5 Oct 2022 07:39:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbiJELiY (ORCPT ); Wed, 5 Oct 2022 07:38:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9596C72FFA; Wed, 5 Oct 2022 04:35:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 67E55B81DC2; Wed, 5 Oct 2022 11:34:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B18E6C433D7; Wed, 5 Oct 2022 11:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664969692; bh=j8qDiqd4007TTVXR5GQqV4oL8mrRzRo/CNbjxYNi3ss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F08dObQkVzId/ETV1b2KTWPvAqOKrn/LHdP0dbk4nHpiroD1+YKo62owGkoiYKhZr pwSBwAIX1jgmSEcIDWP9I/97SYPmisIuf0X5tM7zzkOifyYwq7CdJtIWYqBCAjwOy3 QwnrNPpVzrdwh+64M8cj6f68lAXOpHGjoTpqxtRw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Christoph Hellwig , "Darrick J. Wong" , Chandan Babu R Subject: [PATCH 5.4 46/51] xfs: streamline xfs_attr3_leaf_inactive Date: Wed, 5 Oct 2022 13:32:34 +0200 Message-Id: <20221005113212.390334261@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221005113210.255710920@linuxfoundation.org> References: <20221005113210.255710920@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Darrick J. Wong" commit 0bb9d159bd018b271e783d3b2d3bc82fa0727321 upstream. Now that we know we don't have to take a transaction to stale the incore buffers for a remote value, get rid of the unnecessary memory allocation in the leaf walker and call the rmt_stale function directly. Flatten the loop while we're at it. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R Signed-off-by: Greg Kroah-Hartman --- fs/xfs/libxfs/xfs_attr_leaf.h | 9 --- fs/xfs/xfs_attr_inactive.c | 103 ++++++++++++-------------------------= ----- 2 files changed, 30 insertions(+), 82 deletions(-) --- a/fs/xfs/libxfs/xfs_attr_leaf.h +++ b/fs/xfs/libxfs/xfs_attr_leaf.h @@ -39,15 +39,6 @@ struct xfs_attr3_icleaf_hdr { } freemap[XFS_ATTR_LEAF_MAPSIZE]; }; =20 -/* - * Used to keep a list of "remote value" extents when unlinking an inode. - */ -typedef struct xfs_attr_inactive_list { - xfs_dablk_t valueblk; /* block number of value bytes */ - int valuelen; /* number of bytes in value */ -} xfs_attr_inactive_list_t; - - /*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * Function prototypes for the kernel. *=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/ --- a/fs/xfs/xfs_attr_inactive.c +++ b/fs/xfs/xfs_attr_inactive.c @@ -37,8 +37,6 @@ xfs_attr3_rmt_stale( int blkcnt) { struct xfs_bmbt_irec map; - xfs_dablk_t tblkno; - int tblkcnt; int nmap; int error; =20 @@ -46,14 +44,12 @@ xfs_attr3_rmt_stale( * Roll through the "value", invalidating the attribute value's * blocks. */ - tblkno =3D blkno; - tblkcnt =3D blkcnt; - while (tblkcnt > 0) { + while (blkcnt > 0) { /* * Try to remember where we decided to put the value. */ nmap =3D 1; - error =3D xfs_bmapi_read(dp, (xfs_fileoff_t)tblkno, tblkcnt, + error =3D xfs_bmapi_read(dp, (xfs_fileoff_t)blkno, blkcnt, &map, &nmap, XFS_BMAPI_ATTRFORK); if (error) return error; @@ -68,8 +64,8 @@ xfs_attr3_rmt_stale( if (error) return error; =20 - tblkno +=3D map.br_blockcount; - tblkcnt -=3D map.br_blockcount; + blkno +=3D map.br_blockcount; + blkcnt -=3D map.br_blockcount; } =20 return 0; @@ -83,84 +79,45 @@ xfs_attr3_rmt_stale( */ STATIC int xfs_attr3_leaf_inactive( - struct xfs_trans **trans, - struct xfs_inode *dp, - struct xfs_buf *bp) + struct xfs_trans **trans, + struct xfs_inode *dp, + struct xfs_buf *bp) { - struct xfs_attr_leafblock *leaf; - struct xfs_attr3_icleaf_hdr ichdr; - struct xfs_attr_leaf_entry *entry; + struct xfs_attr3_icleaf_hdr ichdr; + struct xfs_mount *mp =3D bp->b_mount; + struct xfs_attr_leafblock *leaf =3D bp->b_addr; + struct xfs_attr_leaf_entry *entry; struct xfs_attr_leaf_name_remote *name_rmt; - struct xfs_attr_inactive_list *list; - struct xfs_attr_inactive_list *lp; - int error; - int count; - int size; - int tmp; - int i; - struct xfs_mount *mp =3D bp->b_mount; + int error; + int i; =20 - leaf =3D bp->b_addr; xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &ichdr, leaf); =20 /* - * Count the number of "remote" value extents. + * Find the remote value extents for this leaf and invalidate their + * incore buffers. */ - count =3D 0; entry =3D xfs_attr3_leaf_entryp(leaf); for (i =3D 0; i < ichdr.count; entry++, i++) { - if (be16_to_cpu(entry->nameidx) && - ((entry->flags & XFS_ATTR_LOCAL) =3D=3D 0)) { - name_rmt =3D xfs_attr3_leaf_name_remote(leaf, i); - if (name_rmt->valueblk) - count++; - } - } + int blkcnt; =20 - /* - * If there are no "remote" values, we're done. - */ - if (count =3D=3D 0) { - xfs_trans_brelse(*trans, bp); - return 0; - } + if (!entry->nameidx || (entry->flags & XFS_ATTR_LOCAL)) + continue; =20 - /* - * Allocate storage for a list of all the "remote" value extents. - */ - size =3D count * sizeof(xfs_attr_inactive_list_t); - list =3D kmem_alloc(size, 0); - - /* - * Identify each of the "remote" value extents. - */ - lp =3D list; - entry =3D xfs_attr3_leaf_entryp(leaf); - for (i =3D 0; i < ichdr.count; entry++, i++) { - if (be16_to_cpu(entry->nameidx) && - ((entry->flags & XFS_ATTR_LOCAL) =3D=3D 0)) { - name_rmt =3D xfs_attr3_leaf_name_remote(leaf, i); - if (name_rmt->valueblk) { - lp->valueblk =3D be32_to_cpu(name_rmt->valueblk); - lp->valuelen =3D xfs_attr3_rmt_blocks(dp->i_mount, - be32_to_cpu(name_rmt->valuelen)); - lp++; - } - } - } - xfs_trans_brelse(*trans, bp); /* unlock for trans. in freextent() */ - - /* - * Invalidate each of the "remote" value extents. - */ - error =3D 0; - for (lp =3D list, i =3D 0; i < count; i++, lp++) { - tmp =3D xfs_attr3_rmt_stale(dp, lp->valueblk, lp->valuelen); - if (error =3D=3D 0) - error =3D tmp; /* save only the 1st errno */ + name_rmt =3D xfs_attr3_leaf_name_remote(leaf, i); + if (!name_rmt->valueblk) + continue; + + blkcnt =3D xfs_attr3_rmt_blocks(dp->i_mount, + be32_to_cpu(name_rmt->valuelen)); + error =3D xfs_attr3_rmt_stale(dp, + be32_to_cpu(name_rmt->valueblk), blkcnt); + if (error) + goto err; } =20 - kmem_free(list); + xfs_trans_brelse(*trans, bp); +err: return error; }