From patchwork Wed Dec 20 06:34:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13499601 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E6B91DA27 for ; Wed, 20 Dec 2023 06:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="WkVrlD1O" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=WoP/XrSNRaiJYxqBW9NtG53z1a2Q1mj//rNKomONz3o=; b=WkVrlD1OPLh4gd+UeavJkHsljJ Ub6TFzeuDR+BgJB2OEZRXW8Ub1aBmvCb6ur2COew08R5pHS3MKKYtoQEwPQbwOrAM+SBVUgBrElDt LscE/6xdUpjcjeDE2oopFsjSQps6LQDyPIIvICNLq7KUGXHlqUTSjlL1Cj3DoI8MO+++DFiujQ3kF S1iArM26bHGRLyjPPxCUIByVWpFtCG2KVy0GtUAfEvV0hjwaA8r6vuwsT1fM2Hg8qvwYVF2iZ1KO8 9uOUzBW3juj/sPxcUi8pvgg04MfFBcVjYlDA+RqRQ77DPgxD0+rfMtO6gCP830yc/zuyHAHFf21xC Qt/B2ohA==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rFqAk-00GJQ5-1V; Wed, 20 Dec 2023 06:35:14 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 5/9] xfs: remove xfs_attr_shortform_lookup Date: Wed, 20 Dec 2023 07:34:59 +0100 Message-Id: <20231220063503.1005804-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231220063503.1005804-1-hch@lst.de> References: <20231220063503.1005804-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html xfs_attr_shortform_lookup is only used by xfs_attr_shortform_addname, which is much better served by calling xfs_attr_sf_findname. Switch it over and remove xfs_attr_shortform_lookup. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 21 +++++++-------------- fs/xfs/libxfs/xfs_attr_leaf.c | 24 ------------------------ fs/xfs/libxfs/xfs_attr_leaf.h | 1 - 3 files changed, 7 insertions(+), 39 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index bcf8748cb1a333..e8b4317da830ba 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1066,19 +1066,14 @@ xfs_attr_shortform_addname( struct xfs_da_args *args) { int newsize, forkoff; - int error; trace_xfs_attr_sf_addname(args); - error = xfs_attr_shortform_lookup(args); - switch (error) { - case -ENOATTR: - if (args->op_flags & XFS_DA_OP_REPLACE) - return error; - break; - case -EEXIST: + if (xfs_attr_sf_findname(args)) { + int error; + if (!(args->op_flags & XFS_DA_OP_REPLACE)) - return error; + return -EEXIST; error = xfs_attr_sf_removename(args); if (error) @@ -1091,11 +1086,9 @@ xfs_attr_shortform_addname( * around. */ args->op_flags &= ~XFS_DA_OP_REPLACE; - break; - case 0: - break; - default: - return error; + } else { + if (args->op_flags & XFS_DA_OP_REPLACE) + return -ENOATTR; } if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX || diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 7a623efd23a6a4..75c597805ffa8b 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -837,30 +837,6 @@ xfs_attr_sf_removename( return 0; } -/* - * Look up a name in a shortform attribute list structure. - */ -/*ARGSUSED*/ -int -xfs_attr_shortform_lookup( - struct xfs_da_args *args) -{ - struct xfs_ifork *ifp = &args->dp->i_af; - struct xfs_attr_shortform *sf = ifp->if_data; - struct xfs_attr_sf_entry *sfe; - int i; - - ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL); - sfe = &sf->list[0]; - for (i = 0; i < sf->hdr.count; - sfe = xfs_attr_sf_nextentry(sfe), i++) { - if (xfs_attr_match(args, sfe->namelen, sfe->nameval, - sfe->flags)) - return -EEXIST; - } - return -ENOATTR; -} - /* * Retrieve the attribute value and length. * diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h index 56fcd689eedfe7..35e668ae744fb1 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.h +++ b/fs/xfs/libxfs/xfs_attr_leaf.h @@ -47,7 +47,6 @@ struct xfs_attr3_icleaf_hdr { */ void xfs_attr_shortform_create(struct xfs_da_args *args); void xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff); -int xfs_attr_shortform_lookup(struct xfs_da_args *args); int xfs_attr_shortform_getvalue(struct xfs_da_args *args); int xfs_attr_shortform_to_leaf(struct xfs_da_args *args); int xfs_attr_sf_removename(struct xfs_da_args *args);