From patchwork Thu Feb 16 20:41:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13143796 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 9439CC636CC for ; Thu, 16 Feb 2023 20:41:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229630AbjBPUld (ORCPT ); Thu, 16 Feb 2023 15:41:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjBPUld (ORCPT ); Thu, 16 Feb 2023 15:41:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D617CC0D for ; Thu, 16 Feb 2023 12:41:32 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 05E8B60A65 for ; Thu, 16 Feb 2023 20:41:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64DCFC4339B; Thu, 16 Feb 2023 20:41:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676580091; bh=adU9ZB4AFGYAEyFXk11ZcfVHrmhz/+ByHD39monUALA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=pb2jfDbZwmQ137xD8VunUJArconYzpHRG3pQQKk3MpbtMRnPVMHolkdtwfp8Fw8ub FzfIgyBfYJvyCVj3DSHmx9i05s1EJvtyiMatUW0v5oohcm3zChpjk1Z/hEpm6KCEBp HetkJaG0OFhqqiNVEPqxtzJIO6dku8wgIou/fTwDlcgXm1Ob5Ujh+XeabAwQL0Fvd+ Ua6kzOp9YHEFfziYWKkahE4kNHtsGdZ1hM5FeT/XTqCBJK4QcrEy1O4S/div7INF7H S2ieRUpYA1G4tgLZja1bZtArOlrDiquRK45ByNuNOIo7RXzZdmOwEr2h+5ozd/Pvwo SjhNedZU+ZgpQ== Date: Thu, 16 Feb 2023 12:41:30 -0800 Subject: [PATCH 3/4] xfs: pass the attr value to put_listent when possible From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167657873477.3474196.10605438903659189884.stgit@magnolia> In-Reply-To: <167657873432.3474196.15004300376430244372.stgit@magnolia> References: <167657873432.3474196.15004300376430244372.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Pass the attr value to put_listent when we have local xattrs or shortform xattrs. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.h | 5 +++-- fs/xfs/libxfs/xfs_attr_sf.h | 1 + fs/xfs/scrub/attr.c | 8 ++++++++ fs/xfs/xfs_attr_list.c | 8 +++++++- fs/xfs/xfs_ioctl.c | 1 + fs/xfs/xfs_xattr.c | 1 + 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index d6d23cf19ade..02a20b948c8f 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -47,8 +47,9 @@ struct xfs_attrlist_cursor_kern { /* void; state communicated via *context */ -typedef void (*put_listent_func_t)(struct xfs_attr_list_context *, int, - unsigned char *, int, int); +typedef void (*put_listent_func_t)(struct xfs_attr_list_context *context, + int flags, unsigned char *name, int namelen, void *value, + int valuelen); struct xfs_attr_list_context { struct xfs_trans *tp; diff --git a/fs/xfs/libxfs/xfs_attr_sf.h b/fs/xfs/libxfs/xfs_attr_sf.h index 37578b369d9b..c6e259791bc3 100644 --- a/fs/xfs/libxfs/xfs_attr_sf.h +++ b/fs/xfs/libxfs/xfs_attr_sf.h @@ -24,6 +24,7 @@ typedef struct xfs_attr_sf_sort { uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */ xfs_dahash_t hash; /* this entry's hash value */ unsigned char *name; /* name value, pointer into buffer */ + void *value; } xfs_attr_sf_sort_t; #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \ diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 2a79a13cb600..00682006d0d3 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -109,6 +109,7 @@ xchk_xattr_listent( int flags, unsigned char *name, int namelen, + void *value, int valuelen) { struct xchk_xattr *sx; @@ -134,6 +135,13 @@ xchk_xattr_listent( return; } + /* + * Shortform and local attrs don't require external lookups to retrieve + * the value, so there's nothing else to check here. + */ + if (value) + return; + /* * Try to allocate enough memory to extrat the attr value. If that * doesn't work, we overload the seen_enough variable to convey diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index a51f7f13a352..8e3891b96736 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -94,6 +94,7 @@ xfs_attr_shortform_list( sfe->flags, sfe->nameval, (int)sfe->namelen, + &sfe->nameval[sfe->namelen], (int)sfe->valuelen); /* * Either search callback finished early or @@ -139,6 +140,7 @@ xfs_attr_shortform_list( sbp->name = sfe->nameval; sbp->namelen = sfe->namelen; /* These are bytes, and both on-disk, don't endian-flip */ + sbp->value = &sfe->nameval[sfe->namelen], sbp->valuelen = sfe->valuelen; sbp->flags = sfe->flags; sfe = xfs_attr_sf_nextentry(sfe); @@ -189,6 +191,7 @@ xfs_attr_shortform_list( sbp->flags, sbp->name, sbp->namelen, + sbp->value, sbp->valuelen); if (context->seen_enough) break; @@ -443,6 +446,7 @@ xfs_attr3_leaf_list_int( */ for (; i < ichdr.count; entry++, i++) { char *name; + void *value; int namelen, valuelen; if (be32_to_cpu(entry->hashval) != cursor->hashval) { @@ -460,6 +464,7 @@ xfs_attr3_leaf_list_int( name_loc = xfs_attr3_leaf_name_local(leaf, i); name = name_loc->nameval; namelen = name_loc->namelen; + value = &name_loc->nameval[name_loc->namelen]; valuelen = be16_to_cpu(name_loc->valuelen); } else { xfs_attr_leaf_name_remote_t *name_rmt; @@ -467,6 +472,7 @@ xfs_attr3_leaf_list_int( name_rmt = xfs_attr3_leaf_name_remote(leaf, i); name = name_rmt->name; namelen = name_rmt->namelen; + value = NULL; valuelen = be32_to_cpu(name_rmt->valuelen); } @@ -475,7 +481,7 @@ xfs_attr3_leaf_list_int( entry->flags))) return -EFSCORRUPTED; context->put_listent(context, entry->flags, - name, namelen, valuelen); + name, namelen, value, valuelen); if (context->seen_enough) break; cursor->offset++; diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 19f71d6eb561..e6d1e69c6d4a 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -308,6 +308,7 @@ xfs_ioc_attr_put_listent( int flags, unsigned char *name, int namelen, + void *value, int valuelen) { struct xfs_attrlist *alist = context->buffer; diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index ddc2db5d6f73..85edd7e05fde 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -227,6 +227,7 @@ xfs_xattr_put_listent( int flags, unsigned char *name, int namelen, + void *value, int valuelen) { char *prefix;