From patchwork Sun Dec 31 23:02: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: 13508013 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BFEB3C8C8 for ; Sun, 31 Dec 2023 23:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m5kDpw7n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92C93C433C7; Sun, 31 Dec 2023 23:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063750; bh=aIgL3BzYCG/GH14gpgYKAW0aK9T+sSEx8wi5QTLQOBw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=m5kDpw7nlNi/oLsRfTIvXeWm2qVFkeCib1Psa1qMDYcsILkvB3F742DSKIo6tmgKL PoMUS005hbgcv6ksl92HFNKbf3bnZTInGJOc6DWFc+9tS5zwa2mN7MkmUicZWikY6f EjbHUzlDqSTmyVutfMExQ934XBGXaSwXeAKRpMw/2aen2eL1wMdgWTf+j4x/X6SMaS UfsQAeQS5E/R3/8X3PUvC7BZNMYpOYzVjHiazpZ8dN9ypbQk8KY6uNQwwkAJIo1/aK 5QmZIHrM9N9Q2SoS33FkxBYxaam4HipmSZAiYwLZpp8TFzqfaxWBG5e5AG/2VKe13P UyTaYzlHqdduw== Date: Sun, 31 Dec 2023 15:02:30 -0800 Subject: [PATCH 01/11] xfs: allow newer INCOMPAT/RO_COMPAT feature bits to protect ATTRI log items From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005610.1804370.15326025974579452778.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Log recovery (which can include replaying ATTRI intent items) occurs on rw and ro mounts. Dirty logs containing these log items must be protected from being replayed by older kernels. The log incompat feature XFS_SB_FEAT_INCOMPAT_LOG_XATTRS provides this protection. However, adding this flag to the filesystem introduces performance problems of its own -- each time we do, we must force the log and write the primary superblock before writing any ATTRI log items. This was ok when the only users were developers using the debug knob, but this sucks for regular users. We'd like to avoid that. If a filesystem has ro-compat or incompat feature bits set that weren't defined at the time that ATTRI log items were defined, then any kernel that doesn't know about ATTRI items will reject that filesystem. This provides the same protection as the log-incompat feature, but at a much lower cost because most ro-compat and incompat features are set on a permanent basis. Avoid the performance hit by detecting these feature bits and skipping the xfs_add_incompat_log_feature calls. Signed-off-by: Darrick J. Wong --- libxfs/xfs_attr.c | 6 +++++- libxfs/xfs_attr.h | 23 +++++++++++++++++++++++ libxfs/xfs_format.h | 6 +++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 8f527ac9292..8958434247f 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -883,9 +883,13 @@ xfs_attr_defer_add( struct xfs_da_args *args, unsigned int op_flags) { - struct xfs_attr_intent *new; + /* ATTRI log items must be protected from older kernels */ + if (args->op_flags & XFS_DA_OP_LOGGED) + ASSERT(xfs_attri_can_use_without_log_assistance(args->dp->i_mount) || + xfs_sb_version_haslogxattrs(&args->dp->i_mount->m_sb)); + new = kmem_cache_zalloc(xfs_attr_intent_cache, GFP_NOFS | __GFP_NOFAIL); new->xattri_op_flags = op_flags; new->xattri_da_args = args; diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index e4f55008552..273e8dff76c 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -620,4 +620,27 @@ void xfs_attr_intent_destroy_cache(void); int xfs_attr_sf_totsize(struct xfs_inode *dp); +/* + * Decide if this filesystem has a new enough permanent feature set to protect + * attri log items from being replayed on a kernel that does not have + * XFS_SB_FEAT_INCOMPAT_LOG_XATTRS set. + */ +static inline bool +xfs_attri_can_use_without_log_assistance( + struct xfs_mount *mp) +{ + if (!xfs_sb_is_v5(&mp->m_sb)) + return false; + + if (xfs_sb_has_incompat_feature(&mp->m_sb, + ~(XFS_SB_FEAT_INCOMPAT_FTYPE | + XFS_SB_FEAT_INCOMPAT_SPINODES | + XFS_SB_FEAT_INCOMPAT_META_UUID | + XFS_SB_FEAT_INCOMPAT_BIGTIME | + XFS_SB_FEAT_INCOMPAT_NREXT64))) + return true; + + return false; +} + #endif /* __XFS_ATTR_H__ */ diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index ec25010b577..8b952909ce1 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -390,7 +390,11 @@ xfs_sb_has_incompat_feature( return (sbp->sb_features_incompat & feature) != 0; } -#define XFS_SB_FEAT_INCOMPAT_LOG_XATTRS (1 << 0) /* Delayed Attributes */ +/* + * Log contains ATTRI log intent items which are not otherwise protected by + * an INCOMPAT/RO_COMPAT feature flag. + */ +#define XFS_SB_FEAT_INCOMPAT_LOG_XATTRS (1 << 0) /* * Log contains SXI log intent items which are not otherwise protected by From patchwork Sun Dec 31 23:02:45 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: 13508014 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C69D0C8CA for ; Sun, 31 Dec 2023 23:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PmoDyaRz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32248C433C8; Sun, 31 Dec 2023 23:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063766; bh=O2vcq3eYCAu7zclmaYJ/r3w3g5IXbw/ApWWFArZxY6w=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=PmoDyaRzA7Aa+ziuzv8yMiuvjR7xsfn2ZLUZWefgp1SWTTU7YlrHp5xRtIEhf6cQS pD9sYPvSrznkhKWkjuESgDTwLZnOGQkziNBbEdg6eofZMs78L/mlg/Xd8GeUp/OX8U ovbWt0H/Czl0yB7d5LiRzX0xy6i6lIFSIG//x5gyH9yDWuMm//FAFZAIenA3efCaMi u110/dc+pS7rO28Sc2pwee9j/BU4nYg1cYioXcMxhcg2PZxuCZbwopcX9KN7Y8hYkF 65cx6UIyzUfL4TosEqiHxkXuYyxBzD23SFI15OrR+iDhBfBL5fJ0KvySpSKtmGP8Qy +Ysg9/xNy5+oQ== Date: Sun, 31 Dec 2023 15:02:45 -0800 Subject: [PATCH 02/11] xfs: make xfs_attr_set require XFS_DA_OP_REMOVE From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005624.1804370.17201026045399486819.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Quite a few patches from now, we're going to change the parent pointer xattr format to encode as much of the dirent name in the xattr name as fits, and spill the rest of it to the xattr value. To make this work correctly, we'll be adding the ability to look up xattrs based on name /and/ value. Internally, the xattr data structure supports attributes with a zero length value, which is how we're going to store parent pointers for short dirent names. The parent pointer repair code uses xfs_attr_set to add missing and remove dangling parent pointers, so that interface must be capable of setting an xattr with args->value == NULL. The userspace API doesn't support this, so xfs_attr_set currently treats a NULL args->value as a request to remove an attr. However, that's a quirk of the existing callers and the interface. Make the callers of xfs_attr_set to declare explicitly that they want to remove an xattr. Signed-off-by: Darrick J. Wong --- db/attrset.c | 4 +++- libxfs/xfs_attr.c | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/db/attrset.c b/db/attrset.c index 2b6cdb5f5c3..123bdff1b62 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -185,7 +185,9 @@ attr_remove_f( int argc, char **argv) { - struct xfs_da_args args = { }; + struct xfs_da_args args = { + .op_flags = XFS_DA_OP_REMOVE, + }; int c; if (cur_typ == NULL) { diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 8958434247f..ca6cfb1ee8a 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -924,6 +924,7 @@ xfs_attr_set( struct xfs_mount *mp = dp->i_mount; struct xfs_trans_res tres; bool rsvd = (args->attr_filter & XFS_ATTR_ROOT); + bool is_remove = args->op_flags & XFS_DA_OP_REMOVE; int error, local; int rmt_blks = 0; unsigned int total; @@ -948,7 +949,7 @@ xfs_attr_set( args->op_flags = XFS_DA_OP_OKNOENT | (args->op_flags & XFS_DA_OP_LOGGED); - if (args->value) { + if (!is_remove) { XFS_STATS_INC(mp, xs_attr_set); args->total = xfs_attr_calc_size(args, &local); @@ -982,7 +983,7 @@ xfs_attr_set( if (error) return error; - if (args->value || xfs_inode_hasattr(dp)) { + if (!is_remove || xfs_inode_hasattr(dp)) { error = xfs_iext_count_may_overflow(dp, XFS_ATTR_FORK, XFS_IEXT_ATTR_MANIP_CNT(rmt_blks)); if (error == -EFBIG) @@ -995,8 +996,7 @@ xfs_attr_set( error = xfs_attr_lookup(args); switch (error) { case -EEXIST: - if (!args->value) { - /* if no value, we are performing a remove operation */ + if (is_remove) { xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_REMOVE); break; } @@ -1008,7 +1008,7 @@ xfs_attr_set( break; case -ENOATTR: /* Can't remove what isn't there. */ - if (!args->value) + if (is_remove) goto out_trans_cancel; /* Pure replace fails if no existing attr to replace. */ From patchwork Sun Dec 31 23:03:01 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: 13508015 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7603DC8CA for ; Sun, 31 Dec 2023 23:03:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tTyZ3SW2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC540C433C8; Sun, 31 Dec 2023 23:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063781; bh=wzSLwOQyQoSh0654sitxLjcQFQlNiMW9aW8rlQbKD7Y=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=tTyZ3SW2t+sSWXsZy5piHaIpbsxWizqWYCjP53/awyaTX+5IzYC+KWJWe/3M0ykH7 n/o+xMjLGihT3pMVtn7eLwTJkIhVhSlUsZvN2aANSixo2tBW+RuWyNkpfpMnEg76Zi PFG/aZuq9QPZgkUTNejNXJoIYfmwjrD6un0k0yFc3G3sNbaD61EiHEfuLLcdXCbaTr YKdhi9mWHfqfDB8kBbTq+ODysuWyej6KbndHHvB9+OXyvSoJX1BVBiR9qNOXt1XkVq ZYvrPLICF2eiOZ69KIhQjtlpZy308q7AEMAGHqc9W1Cd7OMU6mF7kDYgi7FcuLXWF0 seaFLUvo5m8bA== Date: Sun, 31 Dec 2023 15:03:01 -0800 Subject: [PATCH 03/11] xfs: allow xattr matching on name and value for local/sf attrs From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005637.1804370.10798804609296237199.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Add a new NVLOOKUP flag to signal that the caller wants to look up an extended attribute by name and value. This only works with shortform and local attributes. Only parent pointers need this functionality and parent pointers cannot be remote xattrs, so this limitation is ok for now. Signed-off-by: Darrick J. Wong --- libxfs/xfs_attr_leaf.c | 45 +++++++++++++++++++++++++++++++++++++-------- libxfs/xfs_da_btree.h | 4 +++- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 3d798828833..c0fc3c10dc4 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -505,10 +505,12 @@ xfs_attr3_leaf_read( */ static bool xfs_attr_match( - struct xfs_da_args *args, - uint8_t namelen, - unsigned char *name, - int flags) + const struct xfs_da_args *args, + uint8_t namelen, + const unsigned char *name, + unsigned int valuelen, + const void *value, + int flags) { if (args->namelen != namelen) @@ -516,6 +518,23 @@ xfs_attr_match( if (memcmp(args->name, name, namelen) != 0) return false; + if (args->op_flags & XFS_DA_OP_NVLOOKUP) { + if (args->valuelen != valuelen) + return false; + if (args->valuelen && !value) { + /* not implemented for remote values */ + ASSERT(0); + return false; + } + if (valuelen && !args->value) { + /* caller gave us valuelen > 0 but no value?? */ + ASSERT(0); + return false; + } + if (valuelen > 0 && memcmp(args->value, value, valuelen) != 0) + return false; + } + /* Recovery ignores the INCOMPLETE flag. */ if ((args->op_flags & XFS_DA_OP_RECOVERY) && args->attr_filter == (flags & XFS_ATTR_NSP_ONDISK_MASK)) @@ -534,6 +553,10 @@ xfs_attr_copy_value( unsigned char *value, int valuelen) { + /* vlookups already supplied the attr value; don't copy anything */ + if (args->op_flags & XFS_DA_OP_NVLOOKUP) + return 0; + /* * No copy if all we have to do is get the length */ @@ -758,6 +781,7 @@ xfs_attr_sf_findname( base += size, i++) { size = xfs_attr_sf_entsize(sfe); if (!xfs_attr_match(args, sfe->namelen, sfe->nameval, + sfe->valuelen, &sfe->nameval[sfe->namelen], sfe->flags)) continue; break; @@ -926,6 +950,7 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args) for (i = 0; i < sf->hdr.count; sfe = xfs_attr_sf_nextentry(sfe), i++) { if (xfs_attr_match(args, sfe->namelen, sfe->nameval, + sfe->valuelen, &sfe->nameval[sfe->namelen], sfe->flags)) return -EEXIST; } @@ -953,6 +978,7 @@ xfs_attr_shortform_getvalue( for (i = 0; i < sf->hdr.count; sfe = xfs_attr_sf_nextentry(sfe), i++) { if (xfs_attr_match(args, sfe->namelen, sfe->nameval, + sfe->valuelen, &sfe->nameval[sfe->namelen], sfe->flags)) return xfs_attr_copy_value(args, &sfe->nameval[args->namelen], sfe->valuelen); @@ -1005,7 +1031,7 @@ xfs_attr_shortform_to_leaf( nargs.total = args->total; nargs.whichfork = XFS_ATTR_FORK; nargs.trans = args->trans; - nargs.op_flags = XFS_DA_OP_OKNOENT; + nargs.op_flags = XFS_DA_OP_OKNOENT | XFS_DA_OP_NVLOOKUP; nargs.owner = args->owner; sfe = &sf->list[0]; @@ -1209,7 +1235,7 @@ xfs_attr3_leaf_to_shortform( nargs.total = args->total; nargs.whichfork = XFS_ATTR_FORK; nargs.trans = args->trans; - nargs.op_flags = XFS_DA_OP_OKNOENT; + nargs.op_flags = XFS_DA_OP_OKNOENT | XFS_DA_OP_NVLOOKUP; nargs.owner = args->owner; for (i = 0; i < ichdr.count; entry++, i++) { @@ -2506,14 +2532,17 @@ xfs_attr3_leaf_lookup_int( if (entry->flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr3_leaf_name_local(leaf, probe); if (!xfs_attr_match(args, name_loc->namelen, - name_loc->nameval, entry->flags)) + name_loc->nameval, + be16_to_cpu(name_loc->valuelen), + &name_loc->nameval[name_loc->namelen], + entry->flags)) continue; args->index = probe; return -EEXIST; } else { name_rmt = xfs_attr3_leaf_name_remote(leaf, probe); if (!xfs_attr_match(args, name_rmt->namelen, - name_rmt->name, entry->flags)) + name_rmt->name, 0, NULL, entry->flags)) continue; args->index = probe; args->rmtvaluelen = be32_to_cpu(name_rmt->valuelen); diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h index 7a004786ee0..1bcb291150e 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -94,6 +94,7 @@ typedef struct xfs_da_args { #define XFS_DA_OP_REMOVE (1u << 6) /* this is a remove operation */ #define XFS_DA_OP_RECOVERY (1u << 7) /* Log recovery operation */ #define XFS_DA_OP_LOGGED (1u << 8) /* Use intent items to track op */ +#define XFS_DA_OP_NVLOOKUP (1u << 9) /* Match local attr on name+value */ #define XFS_DA_OP_FLAGS \ { XFS_DA_OP_JUSTCHECK, "JUSTCHECK" }, \ @@ -104,7 +105,8 @@ typedef struct xfs_da_args { { XFS_DA_OP_NOTIME, "NOTIME" }, \ { XFS_DA_OP_REMOVE, "REMOVE" }, \ { XFS_DA_OP_RECOVERY, "RECOVERY" }, \ - { XFS_DA_OP_LOGGED, "LOGGED" } + { XFS_DA_OP_LOGGED, "LOGGED" }, \ + { XFS_DA_OP_NVLOOKUP, "NVLOOKUP" } /* * Storage for holding state during Btree searches and split/join ops. From patchwork Sun Dec 31 23:03:17 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: 13508016 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1669EC8CA for ; Sun, 31 Dec 2023 23:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U3tQO3JK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D534C433C8; Sun, 31 Dec 2023 23:03:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063797; bh=BvDxWpmvDVzNThwxcvzklsvX8Vc1NJ2JtFxIaFf5ZvY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=U3tQO3JK49aP8PahMZNacAOIZBIsJ0RK1U3NiT4rjWjRay3cOZWXZAov4nqE2SbSD rYqbkmYnAoPTgvCaEBVYtXr9nS81J7T29Gxb0+2p6+T9S0smuD1KgnRMbOV5XHKUET Pkuo5Nouzvu/Svhgl/YSkb3iMmRCp1IlrSbgMpvheEBAYurDcOsPy5vYoWu9pY+8ln HaDltfHuCl+If2UcL3Jtlfg5NKCqwrl0Yc/z8gUhJEwvftclKwjfcwNsJWNnswGPJ0 sM/lwGMiuE28o5ngAoW2fHCj0AFRKe0kjgeOz42vv1H4+AfLUOc+m6OyDNDxNseLN/ HzSELhbdXz1UA== Date: Sun, 31 Dec 2023 15:03:17 -0800 Subject: [PATCH 04/11] xfs: preserve NVLOOKUP in xfs_attr_set From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005650.1804370.12958441930331877156.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Preserve the attr-value lookup flag when calling xfs_attr_set. Normal xattr users will never use this, but parent pointer fsck will. Signed-off-by: Darrick J. Wong --- libxfs/xfs_attr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index ca6cfb1ee8a..e714ea60319 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -943,11 +943,11 @@ xfs_attr_set( /* * We have no control over the attribute names that userspace passes us * to remove, so we have to allow the name lookup prior to attribute - * removal to fail as well. Preserve the logged flag, since we need - * to pass that through to the logging code. + * removal to fail as well. Preserve the logged and vlookup flags, + * since we need to pass them through to the lower levels. */ - args->op_flags = XFS_DA_OP_OKNOENT | - (args->op_flags & XFS_DA_OP_LOGGED); + args->op_flags &= (XFS_DA_OP_LOGGED | XFS_DA_OP_NVLOOKUP); + args->op_flags |= XFS_DA_OP_OKNOENT; if (!is_remove) { XFS_STATS_INC(mp, xs_attr_set); From patchwork Sun Dec 31 23:03:32 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: 13508017 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5AE8DC8C8 for ; Sun, 31 Dec 2023 23:03:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XTSX/qeI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BFCDC433C8; Sun, 31 Dec 2023 23:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063813; bh=z8BatE9FewisiqDsb5reT86EmlAxOg5abdH9TP/32FY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=XTSX/qeI+ctQh/HaBTCP9Ph+bxPR711rrxe/zpSvTx5vrYSYXM3eqPlmD2x/s1tdj IR5hcBDAviY6Ro5ohEFHGr/ih5PCRV1SS5pSKvND+XdIJynWJCrc0JH1f3EN73eJdB BlWcF/e0T7uQzw1K/89MK3K9mGuLqhiSkBYWlxDUsGCwGZk7J4jksQvCtwvcJxSZO+ OceVHtJixoARdBMyB0PTr8D0niQcrol+Tu/svIzT/RIaac3//a8tw5LW3EQAeTiSQv a4js3Z8HilVPelo86G4vdc6K/MB6x/UuRXlC4T4B6nsOzrCCSOYX8hT0jcnY1uwMwX fxdnCK009/E8g== Date: Sun, 31 Dec 2023 15:03:32 -0800 Subject: [PATCH 05/11] xfs: restructure xfs_attr_complete_op a bit From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005663.1804370.12667483093904991965.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Reduce the indentation in this function by flattening the nested if statements. We're going to add more code later to this function later, hence the early cleanup. No functional changes. Signed-off-by: Darrick J. Wong --- libxfs/xfs_attr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index e714ea60319..3f9c504e755 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -419,11 +419,11 @@ xfs_attr_complete_op( bool do_replace = args->op_flags & XFS_DA_OP_REPLACE; args->op_flags &= ~XFS_DA_OP_REPLACE; - if (do_replace) { - args->attr_filter &= ~XFS_ATTR_INCOMPLETE; - return replace_state; - } - return XFS_DAS_DONE; + if (!do_replace) + return XFS_DAS_DONE; + + args->attr_filter &= ~XFS_ATTR_INCOMPLETE; + return replace_state; } static int From patchwork Sun Dec 31 23:03:48 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: 13508018 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 084B3C8CA for ; Sun, 31 Dec 2023 23:03:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MCEhFBvj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBD36C433C7; Sun, 31 Dec 2023 23:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063828; bh=e9VinUzSGDqCiO/LqBKPv3BksDcGXS2nYUdbAysZH2A=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=MCEhFBvj/ey5Jnd0nbH5T7UeZd833nQCcGjumVgedix+3BCrTy56a7y6qgTuacypN SD/0o5tlL8Pseelq75IjyRQPBDu5I3e+fO3Lro1iEJ4FFNX+aOsiWGTsZ5HOw9Zmrx t4PLKtg+O5YrIGssX/unfbqnWdoROR6uQ83UmvSjWHEYTJpAb+f5Yzp3ccYO40mRtI yVpKZ/WhWiolWjOZ7+qEqfP5xCBl0dbR9Rb/hwhjq5h+iKKWJ/nC0nxyRH0/2sNGM8 fKsXM7DcXJM6nI+NdNt2+QOUrQupC4BBo4WEfn7vpABUTz2Id0LsQlW1rkEuzJkpiV DF8fQcXRQ/9yg== Date: Sun, 31 Dec 2023 15:03:48 -0800 Subject: [PATCH 06/11] xfs: use helpers to extract xattr op from opflags From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005677.1804370.7940866102891604921.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Create helper functions to extract the xattr op from the ondisk xattri log item and the incore attr intent item. These will get more use in the patches that follow. Signed-off-by: Darrick J. Wong --- libxfs/xfs_attr.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 273e8dff76c..ca51b93873b 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -529,6 +529,11 @@ struct xfs_attr_intent { struct xfs_bmbt_irec xattri_map; }; +static inline unsigned int +xfs_attr_intent_op(const struct xfs_attr_intent *attr) +{ + return attr->xattri_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK; +} /*======================================================================== * Function prototypes for the kernel. From patchwork Sun Dec 31 23:04:04 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: 13508019 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B0D6AC8CB for ; Sun, 31 Dec 2023 23:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OMjAeViX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E80EC433C7; Sun, 31 Dec 2023 23:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063844; bh=VGRR26XY3Xz9Fu3YgLsTbbKHBaIVN0wOWNudO3uHACc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=OMjAeViXT1lbXx9WC8toi+pjGvVNdmH9rkZmScJfOKr1+RgmWPmHfLanFTeTLpZ2P i03FgVBuB/cCEf5XbQvLBEH9HH5Z+SUc/Sy1NhF/JvApJQO+oN50cqowXS5vvnvTxa 183A0VQ4Q2sk2siigAS5eVgef08hoD44xRwHdNZ8gk5w49MyaDyVeTgjFoDaMXF+g4 Ic/Wuld/+tQS/sG1z78Hh25G4yfeiZY2vwiya+tW7QWWi1Gal94wuuVV+ujzDFJIdq VDFDRCDVS9U2ZnOFpvrWO+4Oq4S2U5m7YXCaPHaT4qrpqgS5CA/XwmMa+R8R8U69qQ 1YwHEQHz8mvCg== Date: Sun, 31 Dec 2023 15:04:04 -0800 Subject: [PATCH 07/11] xfs: log NVLOOKUP xattr removal operations From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005690.1804370.16319420051060800903.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong If high level code wants to do a deferred xattr remove operation with the NVLOOKUP flag set, we need to push this through the log. Signed-off-by: Darrick J. Wong --- libxfs/xfs_attr.c | 2 ++ libxfs/xfs_log_format.h | 1 + 2 files changed, 3 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 3f9c504e755..c38048536af 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -902,6 +902,8 @@ xfs_attr_defer_add( new->xattri_dela_state = xfs_attr_init_replace_state(args); break; case XFS_ATTRI_OP_FLAGS_REMOVE: + if (args->op_flags & XFS_DA_OP_NVLOOKUP) + new->xattri_op_flags = XFS_ATTRI_OP_FLAGS_NVREMOVE; new->xattri_dela_state = xfs_attr_init_remove_state(args); break; default: diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index d4531060b6b..bf648b75194 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -1043,6 +1043,7 @@ struct xfs_icreate_log { #define XFS_ATTRI_OP_FLAGS_SET 1 /* Set the attribute */ #define XFS_ATTRI_OP_FLAGS_REMOVE 2 /* Remove the attribute */ #define XFS_ATTRI_OP_FLAGS_REPLACE 3 /* Replace the attribute */ +#define XFS_ATTRI_OP_FLAGS_NVREMOVE 4 /* Remove attr w/ vlookup */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* From patchwork Sun Dec 31 23:04:19 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: 13508020 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9C07BC8CB for ; Sun, 31 Dec 2023 23:04:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M1c1TKnu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30ECBC433C9; Sun, 31 Dec 2023 23:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063860; bh=mGYNXjPF5NWZaFX9c2+jDvCqL8FStNbxso250XPVi7c=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=M1c1TKnuimP2oWHc7EJGH+5FOWjP3mySi77GaTkXuV/QGgcYh7yHUZD22+RUAJSsp YR27wlxr62j5GWAuLF4O2ckGYsXL1E9tPrScqtDLJZ2yPV3weMoYfj9IacjOeLvT7c ZqmBmHDalJ6AWUZTUxu5vYdU3ZWRg+3dHgUxXlRYFQJb/v40iVaK5zdEQBE2BH05RQ wxUBMjcyBor0X+Zb8P5GaHCYxdUtqEs3o/1cnsAen5/7ArZJYixlgk7Ps4jI8jLejD H3et7Gq4l4u1OLp7QpK9EdagaRx0OFf5nbXDUUcSHzGRKnIk11lG5ASwLe8x2I59rc +J+hVVSTpQDYQ== Date: Sun, 31 Dec 2023 15:04:19 -0800 Subject: [PATCH 08/11] xfs: log NVLOOKUP xattr setting operations From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005703.1804370.18312911467773302433.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong If high level code wants to do a deferred xattr set operation with the NVLOOKUP flag set, we need to push this through the log. Signed-off-by: Darrick J. Wong --- libxfs/xfs_attr.c | 2 ++ libxfs/xfs_log_format.h | 1 + 2 files changed, 3 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index c38048536af..47684d07693 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -896,6 +896,8 @@ xfs_attr_defer_add( switch (op_flags) { case XFS_ATTRI_OP_FLAGS_SET: + if (args->op_flags & XFS_DA_OP_NVLOOKUP) + new->xattri_op_flags = XFS_ATTRI_OP_FLAGS_NVSET; new->xattri_dela_state = xfs_attr_init_add_state(args); break; case XFS_ATTRI_OP_FLAGS_REPLACE: diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index bf648b75194..2ac520a18e9 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -1044,6 +1044,7 @@ struct xfs_icreate_log { #define XFS_ATTRI_OP_FLAGS_REMOVE 2 /* Remove the attribute */ #define XFS_ATTRI_OP_FLAGS_REPLACE 3 /* Replace the attribute */ #define XFS_ATTRI_OP_FLAGS_NVREMOVE 4 /* Remove attr w/ vlookup */ +#define XFS_ATTRI_OP_FLAGS_NVSET 5 /* Set attr with w/ vlookup */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* From patchwork Sun Dec 31 23:04:35 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: 13508021 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0B8E4C8C8 for ; Sun, 31 Dec 2023 23:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HZ/ry4sX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7924C433C7; Sun, 31 Dec 2023 23:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063875; bh=reJG7VGrPEdoDYNntwxpfp1J9+shAZEUZYU083LG9CM=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=HZ/ry4sXC0YYHAarsnvlHrpCFyZuXSkkI9rsS6KTfl4XW2wHvDMUOYDZ6R259sAXw JlWliQx6AT805LmTCiKAJ2stkiX66qaGAX5F4U+jTuriVF2UZj0VOSetOD78uM9Ek4 K4hGuEYq3y2EyE7CgpFXlDQ7yOAs8d3aNNJzc4EFLgL3PkdSX+o614zXY/cy0Tgcb0 WzCbxENsiWsU0JpaniFGNy4thjbYiBPd47QiRFjTCrjpNBc+28J1D7T9eNjNxdWAyy Idr2us2j/uRQkmbxJHhrcYGPQ7t1JL9BqG68RbGx/tkiiChhgHwxxnkX1ZF2DK0Mxb N4eVpz0ip9Aqg== Date: Sun, 31 Dec 2023 15:04:35 -0800 Subject: [PATCH 09/11] xfs: log NVLOOKUP xattr nvreplace operations From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Allison Henderson , catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005716.1804370.15258815822511157477.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Allison Henderson (Formerly titled "xfs: Add new name to attri/d" and described as follows: This patch adds two new fields to the atti/d. They are nname and nnamelen. This will be used for parent pointer updates since a rename operation may cause the parent pointer to update both the name and value. So we need to carry both the new name as well as the target name in the attri/d.) If high level code wants to do a deferred xattr nvreplace operation with the NVLOOKUP flag set, we need to push this through the log. This log item records the old name/value pair and the new name/value pair, and completely replaces one with the other. Parent pointers will need this ability to handle rename moving a child file between parents. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong [djwong: reworked to handle new disk format] Signed-off-by: Darrick J. Wong --- libxfs/xfs_attr.c | 16 ++++++++++++++++ libxfs/xfs_attr.h | 4 ++-- libxfs/xfs_da_btree.h | 6 +++++- libxfs/xfs_log_format.h | 27 +++++++++++++++++++++++---- 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 47684d07693..3fe9041ae2c 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -423,6 +423,20 @@ xfs_attr_complete_op( return XFS_DAS_DONE; args->attr_filter &= ~XFS_ATTR_INCOMPLETE; + if (xfs_attr_intent_op(attr) != XFS_ATTRI_OP_FLAGS_NVREPLACE) + return replace_state; + + /* + * NVREPLACE operations require the caller to set the old and new names + * and values explicitly. + */ + ASSERT(args->new_namelen > 0); + + args->name = args->new_name; + args->namelen = args->new_namelen; + args->hashval = xfs_da_hashname(args->name, args->namelen); + args->value = args->new_value; + args->valuelen = args->new_valuelen; return replace_state; } @@ -901,6 +915,8 @@ xfs_attr_defer_add( new->xattri_dela_state = xfs_attr_init_add_state(args); break; case XFS_ATTRI_OP_FLAGS_REPLACE: + if (args->op_flags & XFS_DA_OP_NVLOOKUP) + new->xattri_op_flags = XFS_ATTRI_OP_FLAGS_NVREPLACE; new->xattri_dela_state = xfs_attr_init_replace_state(args); break; case XFS_ATTRI_OP_FLAGS_REMOVE: diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index ca51b93873b..b4e8ecee3e0 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -510,8 +510,8 @@ struct xfs_attr_intent { struct xfs_da_args *xattri_da_args; /* - * Shared buffer containing the attr name and value so that the logging - * code can share large memory buffers between log items. + * Shared buffer containing the attr name, new name, and value so that + * the logging code can share large memory buffers between log items. */ struct xfs_attri_log_nameval *xattri_nameval; diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h index 1bcb291150e..93fcf49ab79 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -54,11 +54,15 @@ enum xfs_dacmp { */ typedef struct xfs_da_args { struct xfs_da_geometry *geo; /* da block geometry */ - const uint8_t *name; /* string (maybe not NULL terminated) */ + const uint8_t *name; /* string (maybe not NULL terminated) */ + const uint8_t *new_name; /* new attr name */ int namelen; /* length of string (maybe no NULL) */ + int new_namelen; /* new attr name len */ uint8_t filetype; /* filetype of inode for directories */ void *value; /* set of bytes (maybe contain NULLs) */ + void *new_value; /* new xattr value (may contain NULLs) */ int valuelen; /* length of value */ + int new_valuelen; /* length of new attr value */ unsigned int attr_filter; /* XFS_ATTR_{ROOT,SECURE,INCOMPLETE} */ unsigned int attr_flags; /* XATTR_{CREATE,REPLACE} */ xfs_dahash_t hashval; /* hash value of name */ diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index 2ac520a18e9..285a0a089df 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -115,11 +115,13 @@ struct xfs_unmount_log_format { #define XLOG_REG_TYPE_BUD_FORMAT 26 #define XLOG_REG_TYPE_ATTRI_FORMAT 27 #define XLOG_REG_TYPE_ATTRD_FORMAT 28 -#define XLOG_REG_TYPE_ATTR_NAME 29 +#define XLOG_REG_TYPE_ATTR_NAME 29 #define XLOG_REG_TYPE_ATTR_VALUE 30 #define XLOG_REG_TYPE_SXI_FORMAT 31 #define XLOG_REG_TYPE_SXD_FORMAT 32 -#define XLOG_REG_TYPE_MAX 32 +#define XLOG_REG_TYPE_ATTR_NEWNAME 33 +#define XLOG_REG_TYPE_ATTR_NEWVALUE 34 +#define XLOG_REG_TYPE_MAX 34 /* * Flags to log operation header @@ -1045,6 +1047,7 @@ struct xfs_icreate_log { #define XFS_ATTRI_OP_FLAGS_REPLACE 3 /* Replace the attribute */ #define XFS_ATTRI_OP_FLAGS_NVREMOVE 4 /* Remove attr w/ vlookup */ #define XFS_ATTRI_OP_FLAGS_NVSET 5 /* Set attr with w/ vlookup */ +#define XFS_ATTRI_OP_FLAGS_NVREPLACE 6 /* Replace attr name and val */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* @@ -1062,11 +1065,27 @@ struct xfs_icreate_log { struct xfs_attri_log_format { uint16_t alfi_type; /* attri log item type */ uint16_t alfi_size; /* size of this item */ - uint32_t __pad; /* pad to 64 bit aligned */ + + /* + * For NVREPLACE, this is the length of the new xattr value. + * alfi_value_len contains the length of the old xattr value. + */ + uint32_t alfi_new_value_len; + uint64_t alfi_id; /* attri identifier */ uint64_t alfi_ino; /* the inode for this attr operation */ uint32_t alfi_op_flags; /* marks the op as a set or remove */ - uint32_t alfi_name_len; /* attr name length */ + union { + uint32_t alfi_name_len; /* attr name length */ + struct { + /* + * For NVREPLACE, these are the lengths of the old and + * new attr name. + */ + uint16_t alfi_old_name_len; + uint16_t alfi_new_name_len; + }; + }; uint32_t alfi_value_len; /* attr value length */ uint32_t alfi_attr_filter;/* attr filter flags */ }; From patchwork Sun Dec 31 23:04:51 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: 13508022 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E46D4C8CF for ; Sun, 31 Dec 2023 23:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="caekxNq7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F8B2C433C7; Sun, 31 Dec 2023 23:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063891; bh=wFL97SFPOMPzyf6NDCVCHFJpOJGzV1YH7/b6K1Banqs=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=caekxNq7or46xuSSN2tABL0f+0U4N51a74m5RiU/7KmnoKyuUuI59AS0rSZxYZUKh CudFaAW8nDy/A1HSy3sdpsJrFt7+F+jKcbMqazbjg3yn6i9Roxk+1t7rDxwVX0C2Dg WOYEd1OpX1bDjZzUX8UXPp8aJmE2Mx2HiGJYZ7E87vLDwuUVBK9+rSyjpSBAn1pvpt nFm8xxKDVDZEjrsLiubGjz47JZALU/ufDZ0Lvw87QvTUJTmeM1J97r2tBuNVADjwIG Fciq8/6oc4YBRVXSRYV0DMddex8fsn6Ye8OWErsnoh9vlb/Gu3Wz3JKLJKTRC0wyx5 KRuaP/2Cs6Etw== Date: Sun, 31 Dec 2023 15:04:51 -0800 Subject: [PATCH 10/11] xfs_logprint: dump new attr log item fields From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005730.1804370.3323399662841222983.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Dump the new extended attribute log item fields. This was split out from the previous patch to make libxfs resyncing easier. This code needs more cleaning, which we'll do in the next few patches before moving on to the parent pointer code. Signed-off-by: Darrick J. Wong --- logprint/log_redo.c | 132 +++++++++++++++++++++++++++++++++++++++++---------- logprint/logprint.h | 6 ++ 2 files changed, 111 insertions(+), 27 deletions(-) diff --git a/logprint/log_redo.c b/logprint/log_redo.c index 770485df75d..7531c6117bd 100644 --- a/logprint/log_redo.c +++ b/logprint/log_redo.c @@ -674,6 +674,12 @@ xfs_attri_copy_log_format( return 1; } +static inline unsigned int +xfs_attr_log_item_op(const struct xfs_attri_log_format *attrp) +{ + return attrp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK; +} + int xlog_print_trans_attri( char **ptr, @@ -683,6 +689,10 @@ xlog_print_trans_attri( struct xfs_attri_log_format *src_f = NULL; xlog_op_header_t *head = NULL; uint dst_len; + unsigned int name_len = 0; + unsigned int new_name_len = 0; + unsigned int value_len = 0; + unsigned int new_value_len = 0; int error = 0; dst_len = sizeof(struct xfs_attri_log_format); @@ -705,27 +715,67 @@ xlog_print_trans_attri( memmove((char*)src_f, *ptr, src_len); *ptr += src_len; - printf(_("ATTRI: #regs: %d name_len: %d, value_len: %d id: 0x%llx\n"), - src_f->alfi_size, src_f->alfi_name_len, src_f->alfi_value_len, - (unsigned long long)src_f->alfi_id); + if (xfs_attr_log_item_op(src_f) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { + name_len = src_f->alfi_old_name_len; + new_name_len = src_f->alfi_new_name_len; + value_len = src_f->alfi_value_len; + new_value_len = src_f->alfi_new_value_len; + } else { + name_len = src_f->alfi_name_len; + value_len = src_f->alfi_value_len; + } + + printf(_("ATTRI: #regs: %d name_len: %u, new_name_len: %u, value_len: %u, new_value_len: %u id: 0x%llx\n"), + src_f->alfi_size, + name_len, + new_name_len, + value_len, + new_value_len, + (unsigned long long)src_f->alfi_id); + + if (name_len > 0) { + printf(_("\n")); + (*i)++; + head = (xlog_op_header_t *)*ptr; + xlog_print_op_header(head, *i, ptr); + error = xlog_print_trans_attri_name(ptr, + be32_to_cpu(head->oh_len), "name"); + if (error) + goto error; + } - if (src_f->alfi_name_len > 0) { + if (new_name_len > 0) { printf(_("\n")); (*i)++; head = (xlog_op_header_t *)*ptr; xlog_print_op_header(head, *i, ptr); - error = xlog_print_trans_attri_name(ptr, be32_to_cpu(head->oh_len)); + error = xlog_print_trans_attri_name(ptr, + be32_to_cpu(head->oh_len), "newname"); if (error) goto error; } - if (src_f->alfi_value_len > 0) { + if (value_len > 0) { printf(_("\n")); (*i)++; head = (xlog_op_header_t *)*ptr; xlog_print_op_header(head, *i, ptr); - error = xlog_print_trans_attri_value(ptr, be32_to_cpu(head->oh_len), - src_f->alfi_value_len); + error = xlog_print_trans_attri_value(ptr, + be32_to_cpu(head->oh_len), value_len, "value"); + if (error) + goto error; + } + + if (new_value_len > 0) { + printf(_("\n")); + (*i)++; + head = (xlog_op_header_t *)*ptr; + xlog_print_op_header(head, *i, ptr); + error = xlog_print_trans_attri_value(ptr, + be32_to_cpu(head->oh_len), new_value_len, + "newvalue"); + if (error) + goto error; } error: free(src_f); @@ -736,31 +786,33 @@ xlog_print_trans_attri( int xlog_print_trans_attri_name( char **ptr, - uint src_len) + uint src_len, + const char *tag) { - printf(_("ATTRI: name len:%u\n"), src_len); + printf(_("ATTRI: %s len:%u\n"), tag, src_len); print_or_dump(*ptr, src_len); *ptr += src_len; return 0; -} /* xlog_print_trans_attri */ +} int xlog_print_trans_attri_value( char **ptr, uint src_len, - int value_len) + int value_len, + const char *tag) { int len = min(value_len, src_len); - printf(_("ATTRI: value len:%u\n"), value_len); + printf(_("ATTRI: %s len:%u\n"), tag, value_len); print_or_dump(*ptr, len); *ptr += src_len; return 0; -} /* xlog_print_trans_attri_value */ +} void xlog_recover_print_attri( @@ -768,7 +820,10 @@ xlog_recover_print_attri( { struct xfs_attri_log_format *f, *src_f = NULL; uint src_len, dst_len; - + unsigned int name_len = 0; + unsigned int new_name_len = 0; + unsigned int value_len = 0; + unsigned int new_value_len = 0; int region = 0; src_f = (struct xfs_attri_log_format *)item->ri_buf[0].i_addr; @@ -788,24 +843,51 @@ xlog_recover_print_attri( if (xfs_attri_copy_log_format((char*)src_f, src_len, f)) goto out; - printf(_("ATTRI: #regs: %d name_len: %d, value_len: %d id: 0x%llx\n"), - f->alfi_size, f->alfi_name_len, f->alfi_value_len, (unsigned long long)f->alfi_id); + if (xfs_attr_log_item_op(f) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { + name_len = f->alfi_old_name_len; + new_name_len = f->alfi_new_name_len; + value_len = f->alfi_value_len; + new_value_len = f->alfi_new_value_len; + } else { + name_len = f->alfi_name_len; + value_len = f->alfi_value_len; + } + + printf(_("ATTRI: #regs: %d name_len: %u, new_name_len: %u, value_len: %d, new_value_len: %u id: 0x%llx\n"), + f->alfi_size, + name_len, + new_name_len, + value_len, + new_value_len, + (unsigned long long)f->alfi_id); - if (f->alfi_name_len > 0) { + if (name_len > 0) { region++; - printf(_("ATTRI: name len:%u\n"), f->alfi_name_len); + printf(_("ATTRI: name len:%u\n"), name_len); print_or_dump((char *)item->ri_buf[region].i_addr, - f->alfi_name_len); + name_len); } - if (f->alfi_value_len > 0) { - int len = f->alfi_value_len; + if (new_name_len > 0) { + region++; + printf(_("ATTRI: newname len:%u\n"), new_name_len); + print_or_dump((char *)item->ri_buf[region].i_addr, + new_name_len); + } + + if (value_len > 0) { + int len = min(MAX_ATTR_VAL_PRINT, value_len); + + region++; + printf(_("ATTRI: value len:%u\n"), value_len); + print_or_dump((char *)item->ri_buf[region].i_addr, len); + } - if (len > MAX_ATTR_VAL_PRINT) - len = MAX_ATTR_VAL_PRINT; + if (new_value_len > 0) { + int len = min(MAX_ATTR_VAL_PRINT, new_value_len); region++; - printf(_("ATTRI: value len:%u\n"), f->alfi_value_len); + printf(_("ATTRI: newvalue len:%u\n"), new_value_len); print_or_dump((char *)item->ri_buf[region].i_addr, len); } diff --git a/logprint/logprint.h b/logprint/logprint.h index 892b280b548..8742b98a9d1 100644 --- a/logprint/logprint.h +++ b/logprint/logprint.h @@ -59,8 +59,10 @@ extern void xlog_recover_print_bud(struct xlog_recover_item *item); #define MAX_ATTR_VAL_PRINT 128 extern int xlog_print_trans_attri(char **ptr, uint src_len, int *i); -extern int xlog_print_trans_attri_name(char **ptr, uint src_len); -extern int xlog_print_trans_attri_value(char **ptr, uint src_len, int value_len); +extern int xlog_print_trans_attri_name(char **ptr, uint src_len, + const char *tag); +extern int xlog_print_trans_attri_value(char **ptr, uint src_len, int value_len, + const char *tag); extern void xlog_recover_print_attri(struct xlog_recover_item *item); extern int xlog_print_trans_attrd(char **ptr, uint len); extern void xlog_recover_print_attrd(struct xlog_recover_item *item); From patchwork Sun Dec 31 23:05:06 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: 13508023 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4B684C8C8 for ; Sun, 31 Dec 2023 23:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rngDTx4y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 161CAC433C8; Sun, 31 Dec 2023 23:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704063907; bh=Q8Raf/qaui75K0YXpRdV+CyGxv1OvElKBNrmPljuyqY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=rngDTx4y0uCg9Dgs2cBwFtTz2HkvA39j9xibFxSkgr+wrt36IrsEWyIYE6lfOP/z8 r6+1COGUvNz9MAntkQbnDi33TaK+JFq98Jc5ryYjpizggSrbW7fteLjC/5IzlD7ixI +GqHBMsZM9nnpTOH2E8q5+1l6it0OTO5uUS1hCUoe3XYjWPM5HlNfegZoTAnEn1JbM 9FEVsYWQfTNgohCqlXnp0tb62nB9ey7UTop/nhaxn+k6XqSiWiSjQXTt99bqorESSX CpHtVP97hgcDeXclDXC1ZeEQiv+of9XEGZQQVjOE850aCFwxeiz65KN1qfCP4m3HTp RYmNAv0/9YQfw== Date: Sun, 31 Dec 2023 15:05:06 -0800 Subject: [PATCH 11/11] xfs_logprint: print missing attri header fields From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: catherine.hoang@oracle.com, linux-xfs@vger.kernel.org, allison.henderson@oracle.com Message-ID: <170405005743.1804370.6059457019562722590.stgit@frogsfrogsfrogs> In-Reply-To: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> References: <170405005590.1804370.14232373294131770998.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Not sure why logprint doesn't print the op flags, inode, or attr filter fields. Make it do that. Signed-off-by: Darrick J. Wong --- logprint/log_redo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/logprint/log_redo.c b/logprint/log_redo.c index 7531c6117bd..e6401bb293e 100644 --- a/logprint/log_redo.c +++ b/logprint/log_redo.c @@ -725,8 +725,11 @@ xlog_print_trans_attri( value_len = src_f->alfi_value_len; } - printf(_("ATTRI: #regs: %d name_len: %u, new_name_len: %u, value_len: %u, new_value_len: %u id: 0x%llx\n"), + printf(_("ATTRI: #regs: %d f: 0x%x, ino: 0x%llx, attr_filter: 0x%x, name_len: %u, new_name_len: %u, value_len: %u, new_value_len: %u id: 0x%llx\n"), src_f->alfi_size, + src_f->alfi_op_flags, + (unsigned long long)src_f->alfi_ino, + src_f->alfi_attr_filter, name_len, new_name_len, value_len, @@ -853,8 +856,11 @@ xlog_recover_print_attri( value_len = f->alfi_value_len; } - printf(_("ATTRI: #regs: %d name_len: %u, new_name_len: %u, value_len: %d, new_value_len: %u id: 0x%llx\n"), + printf(_("ATTRI: #regs: %d f: 0x%x, ino: 0x%llx, attr_filter: 0x%x, name_len: %u, new_name_len: %u, value_len: %u, new_value_len: %u id: 0x%llx\n"), f->alfi_size, + f->alfi_op_flags, + (unsigned long long)f->alfi_ino, + f->alfi_attr_filter, name_len, new_name_len, value_len,