From patchwork Fri May 26 02:19: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: 13256292 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 860C6C77B7A for ; Fri, 26 May 2023 02:19:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233393AbjEZCTd (ORCPT ); Thu, 25 May 2023 22:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbjEZCTd (ORCPT ); Thu, 25 May 2023 22:19:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5237F187 for ; Thu, 25 May 2023 19:19:32 -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 dfw.source.kernel.org (Postfix) with ESMTPS id BFBBA614A2 for ; Fri, 26 May 2023 02:19:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29BB6C43443; Fri, 26 May 2023 02:19:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685067571; bh=Jjpvek0G5ErPa/acMyLJCrWIyd5Telcq1FfI2l1PAMg=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Zda4WFa12I3jZceqVxNMHBzihq1IW19ifwb9arLRPPY5dKp/gUAtJaEsl4b+uD1wc 3UM4tYzXYakqlhpFe63DeO8L5qzhc1MwGRgaM5R+OUZxCHTBdsQjuifx0S9xBxmys6 LRt2yLkC7Olz2OU1zx0q2i/68+4UZeGE1pYVvKXHixFGgQilU3mzsdfmTP3oph88Z4 TZTe9DFhqKvlh0bgPUyOaJ3BIAcvXBY8WwCn0PMtovW6kvDYoEV13BpAz5ctuS+Gdz 32dshDJzogL35BqClajA6IbkF8opWtiPXKeyO8soNQ7otDMKOdbbf+TitHbVDuk/IS 9BgAQA3ygPLxQ== Date: Thu, 25 May 2023 19:19:30 -0700 Subject: [PATCH 01/10] xfs: make xfs_attr_set require XFS_DA_OP_REMOVE From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com, catherine.hoang@oracle.com Message-ID: <168506077448.3749126.4421797460119228908.stgit@frogsfrogsfrogs> In-Reply-To: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> References: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> 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 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 | 9 +++++---- 2 files changed, 8 insertions(+), 5 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 c8382190e22..b131a8f2662 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -965,6 +965,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; @@ -989,7 +990,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); @@ -1023,7 +1024,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) @@ -1037,7 +1038,7 @@ xfs_attr_set( switch (error) { case -EEXIST: /* if no value, we are performing a remove operation */ - if (!args->value) { + if (is_remove) { error = xfs_attr_defer_remove(args); break; } @@ -1049,7 +1050,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 Fri May 26 02:19:46 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: 13256293 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 CDD4BC77B7A for ; Fri, 26 May 2023 02:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233494AbjEZCTy (ORCPT ); Thu, 25 May 2023 22:19:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234550AbjEZCTu (ORCPT ); Thu, 25 May 2023 22:19:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4D84194 for ; Thu, 25 May 2023 19:19:47 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 66E4D64C49 for ; Fri, 26 May 2023 02:19:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA0F4C433D2; Fri, 26 May 2023 02:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685067586; bh=Js9rj0qpM0iRtAb0FuzEhtakxsev7vLoAMhyak/U8wI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=sg2g0gDMADIVsa9wZ5BXyjbNtcgQ04EESKNjZ8rcU37O1Jka6W3Rrq6Meir6W0jds RXsthnJh197eUiJZlv8MQp5SPoGXiAa2JPhe3mCNl0vsgLfr/4V22LCgPhuhaGDqDn haYwJ+47WtLYRDl/yByiaho7+Hw2m0bDox2H1htKk020o6IWZeGGyNsL7TTayCu84s wUk+5nm7w93elWzbdYYIYn1M4TxBdhWebVsrhxwUgbZRSQMrMdLYoIgWBvu6ghQ4E+ DLfNIUFr4YQzUx6Yr4vuGJfDEWIsHqTvqG6bLQSGqrthC1E85QT20B48e//MHMODMD AE5cRLAdtmX0w== Date: Thu, 25 May 2023 19:19:46 -0700 Subject: [PATCH 02/10] xfs: allow xattr matching on name and value for local/sf attrs From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com, catherine.hoang@oracle.com Message-ID: <168506077461.3749126.982144107925942089.stgit@frogsfrogsfrogs> In-Reply-To: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> References: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> 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 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 1a2371c33e4..d737d4163dd 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]; @@ -1226,7 +1252,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++) { @@ -2529,14 +2555,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 1f5b3c3f0de..091750b2d42 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 Fri May 26 02:20:02 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: 13256294 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 827D2C77B7E for ; Fri, 26 May 2023 02:20:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233533AbjEZCUF (ORCPT ); Thu, 25 May 2023 22:20:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjEZCUE (ORCPT ); Thu, 25 May 2023 22:20:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63B5AF7 for ; Thu, 25 May 2023 19:20:03 -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 dfw.source.kernel.org (Postfix) with ESMTPS id ECBA06157B for ; Fri, 26 May 2023 02:20:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AC2AC433D2; Fri, 26 May 2023 02:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685067602; bh=qshdKuJeerNsC1eFKmPBPrqXEXpUsYuTJrHbcPK0lqA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=QLeHnFO8RwJFlak5BeIfGuuGpulVWdA4vLmHAkH3F7uMbBifkamnHUuND/CL39Wkq +3Fsl9N+amg3ebwh+zxCbjgTqnsSJUAsg7pu/JL6NTVI92m/eEupLSUYiV/S5ImGPf e6l6r8jnOYPDpmPKC1W5Ies/bSM0NC32uxMjzkY04GXir3Io2btCl6uGTZ64Y7AibH 6yK4AKDLrFpIOoBi7xp2QcWR3SExJrS2yruPK79G3FWCecxXyfnUOJbWc45mSlY7L+ DUNW8ayFiKJH1wBgRzzI3eYvJySby+78mCfrwKoyDcAEpjJPr8F8ZtPFQG3QOK0Ymq Y16EoD8APetYQ== Date: Thu, 25 May 2023 19:20:02 -0700 Subject: [PATCH 03/10] xfs: preserve NVLOOKUP in xfs_attr_set From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com, catherine.hoang@oracle.com Message-ID: <168506077475.3749126.14868951985736989646.stgit@frogsfrogsfrogs> In-Reply-To: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> References: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> 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 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 b131a8f2662..a4227f6379d 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -984,11 +984,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 Fri May 26 02:20: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: 13256295 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 DA06EC77B7E for ; Fri, 26 May 2023 02:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229689AbjEZCUV (ORCPT ); Thu, 25 May 2023 22:20:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjEZCUU (ORCPT ); Thu, 25 May 2023 22:20:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4180BB2 for ; Thu, 25 May 2023 19:20:18 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 7E76264A68 for ; Fri, 26 May 2023 02:20:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFBAFC433EF; Fri, 26 May 2023 02:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685067617; bh=QmAnVbYJvYX3jHeum40MbtLhQYAdbwJkSiOwr89dq0I=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=IX1eYOxrZgOzpFjUfWPqQl7YdY77gJ3DX9K08txs1yFHYOJjBdp12+1JgBg+OBTBv NuU09P8EIYUNCpfca7gjWCWxeEyzJRC3/SZQQqpmQuNfNXO/qx7T0Q3nU/rVbv1+rt jhVGJ0NKr80dG3SffO3pi9iy7WpP6ZFWqdRds94Wha1S9aofjZtpNLVTznFnLaudq9 Gq22TwrySPdZuwrStWc2oyYS9zi2DRuKVLxACX8gNMCFvL8jZ1NSkbkbTz51M/1CeQ XzCUK6yfhOZQHbIJ7nEqvC+O+SsAjSss0pk1O2tODxnbjN2QrH20PQonrr3OwhnTwA 1A5zJOsKWeh/g== Date: Thu, 25 May 2023 19:20:17 -0700 Subject: [PATCH 04/10] xfs: restructure xfs_attr_complete_op a bit From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com, catherine.hoang@oracle.com Message-ID: <168506077489.3749126.7311222685035659749.stgit@frogsfrogsfrogs> In-Reply-To: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> References: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> 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 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 a4227f6379d..4a2c48d050d 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 Fri May 26 02:20:33 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: 13256296 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 4436BC77B7A for ; Fri, 26 May 2023 02:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233448AbjEZCUh (ORCPT ); Thu, 25 May 2023 22:20:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbjEZCUg (ORCPT ); Thu, 25 May 2023 22:20:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7885D187 for ; Thu, 25 May 2023 19:20:34 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1612D64A68 for ; Fri, 26 May 2023 02:20:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 752ABC433D2; Fri, 26 May 2023 02:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685067633; bh=eMMGTxutoh2MbA5Irl799e1xcj5R7cCP5D1WwCk6JkA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=A3xvNRR+pa+0cyA0UpOWSM0MGpZLSB6nGlVwMXvIvG813y/QZP/kZ5jT1wRpevU1A SDVd4RKRzgx5EvTNd5yLqgx7wI+sM/ATbkDpJcNnjj++juKiq+vdm/7O98FJNM2/aO fWJBV0Pe5Zq9KEwwZdhUbNIe3a/N4NGVhNNYivnEx5/om/vghXpSvc5cwegDfmrMfX PqCxGnLIEC0BD9KpLrZ5MMsTkRjTD4K6SQt+YY5/Mrv8voqFBKI60P1m7sSmVX4+H5 ry5g8Jm2kAMYmIPZDiThyBfJb7/7UZ2Xgcrxwl/UExGvXAP2db620KF+VFbz9bXZpX SHRFCyCEPiyvw== Date: Thu, 25 May 2023 19:20:33 -0700 Subject: [PATCH 05/10] xfs: use helpers to extract xattr op from opflags From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com, catherine.hoang@oracle.com Message-ID: <168506077502.3749126.16260179667138628033.stgit@frogsfrogsfrogs> In-Reply-To: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> References: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> 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 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 e4f55008552..4bacafa59a4 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 Fri May 26 02:20: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: 13256297 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 84E78C77B7E for ; Fri, 26 May 2023 02:20:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229523AbjEZCU6 (ORCPT ); Thu, 25 May 2023 22:20:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbjEZCU5 (ORCPT ); Thu, 25 May 2023 22:20:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AD67198 for ; Thu, 25 May 2023 19:20:50 -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 dfw.source.kernel.org (Postfix) with ESMTPS id ADFAA64C49 for ; Fri, 26 May 2023 02:20:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1939EC433EF; Fri, 26 May 2023 02:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685067649; bh=cihNjOi+YigbFUkEiQi6gTb1iQlR+5v9NgZ8t8464Do=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=q+IopDDFykP9+luYDcBjAsxIHhq5JkNuHPja8AjYc7ZSFXZNQZh1J90PlsEBc19SB lMh3EesQP2c8cDuczMUyTJXgEwp0vtnjJbIa9xJ7FLgU7+iDhQIgOLeLhlHugjH2FI Og8Er3hn5QJjAmlPwIMNpmB6ivEbeJ+n8s8lJzI8iVXRUi2hEU0ECLZFKW0J6nGbu3 NcEBk62kI7nSz+kzMs7XigUWWnBHq9zh3gFtDiC0LCKY/sSKjJpBf0+jOBFD8a3Znw k4eOQND6Hx1/oiKDZbq6Sjd98xtnvSfhDmkxRWkG0qItrd0nGlgMZY3X06I2zi+Itw iCwV656JkqdGQ== Date: Thu, 25 May 2023 19:20:48 -0700 Subject: [PATCH 06/10] xfs: log NVLOOKUP xattr removal operations From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com, catherine.hoang@oracle.com Message-ID: <168506077516.3749126.14068005851620425458.stgit@frogsfrogsfrogs> In-Reply-To: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> References: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> 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 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 | 6 +++++- libxfs/xfs_log_format.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 4a2c48d050d..a3c65665d38 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -940,9 +940,13 @@ xfs_attr_defer_remove( { struct xfs_attr_intent *new; + int op_flag = XFS_ATTRI_OP_FLAGS_REMOVE; int error; - error = xfs_attr_intent_init(args, XFS_ATTRI_OP_FLAGS_REMOVE, &new); + if (args->op_flags & XFS_DA_OP_NVLOOKUP) + op_flag = XFS_ATTRI_OP_FLAGS_NVREMOVE; + + error = xfs_attr_intent_init(args, op_flag, &new); if (error) return error; diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index c7d02bb04f4..0eb8362e91d 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -1036,6 +1036,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 Fri May 26 02:21: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: 13256298 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 29494C77B7E for ; Fri, 26 May 2023 02:21:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233074AbjEZCVL (ORCPT ); Thu, 25 May 2023 22:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233920AbjEZCVK (ORCPT ); Thu, 25 May 2023 22:21:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF699195 for ; Thu, 25 May 2023 19:21:05 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 5C6AA64C49 for ; Fri, 26 May 2023 02:21:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1922C433D2; Fri, 26 May 2023 02:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685067664; bh=03/sAiBliwj9m0mylF0z7B/jDRBVuI8qV7AF6JKL+/g=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=UGzk/ctXfxDCnEGeJkjrUhSMql0lTTxE63vRAUWcIwybwLKTyf4YDwhsRVYKORL2B f3Dj5yQ0uSJ0tcOiY/4cKGWJXWuS1ndUPmLWlMhiW7i3zA2kxsLT7O0Gt/qO652SpS pht+DtziZQ6y3MiOVMaWtPnahT5FGLDnM7+/g4ProsDJ/Q8wfYo7YvpBNkcKpCZDSr hRZ0Wgac2Sf9x8nOXvqpz+t5fQGHWZ8gFNnk7kgV5rbWkfpF6p2as5swW42pDwAGKq q4fwZuTtHpwunKFbRA99sKHAFjXJAtLW0cBesJIP6Xg760t7aNm0EJeNHcuGmyZvSW wYQJKdsmQQQHA== Date: Thu, 25 May 2023 19:21:04 -0700 Subject: [PATCH 07/10] xfs: log NVLOOKUP xattr setting operations From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com, catherine.hoang@oracle.com Message-ID: <168506077529.3749126.16323276787761035199.stgit@frogsfrogsfrogs> In-Reply-To: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> References: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> 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 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 | 6 +++++- libxfs/xfs_log_format.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index a3c65665d38..8fa5b4f2819 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -901,9 +901,13 @@ xfs_attr_defer_add( struct xfs_da_args *args) { struct xfs_attr_intent *new; + int op_flag = XFS_ATTRI_OP_FLAGS_SET; int error = 0; - error = xfs_attr_intent_init(args, XFS_ATTRI_OP_FLAGS_SET, &new); + if (args->op_flags & XFS_DA_OP_NVLOOKUP) + op_flag = XFS_ATTRI_OP_FLAGS_NVSET; + + error = xfs_attr_intent_init(args, op_flag, &new); if (error) return error; diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index 0eb8362e91d..7b848b1d8aa 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -1037,6 +1037,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 Fri May 26 02:21: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: 13256299 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 55E47C77B7A for ; Fri, 26 May 2023 02:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229567AbjEZCV0 (ORCPT ); Thu, 25 May 2023 22:21:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233928AbjEZCVZ (ORCPT ); Thu, 25 May 2023 22:21:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58F9F19D for ; Thu, 25 May 2023 19:21: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 dfw.source.kernel.org (Postfix) with ESMTPS id E94D164C49 for ; Fri, 26 May 2023 02:21:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 589DEC433EF; Fri, 26 May 2023 02:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685067680; bh=aH8aS7Z92kOkeEzjo7GWtvOuIXCkLZmz1cidHB4Cylw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=nrNtX8B0nQ7jrcBrWN4UsLPC8uAvzC5TNLzB9FKBZDPc4TrTehuiucCfWa12/wFQj m51lhm7s+vzAba5GOj5e8G8p6cl6utzEjJLCbJxJnf4kbAH9rP4K5zwSU7OCbbh5tq 9PXI6UbkyJQ/Jtxy8xE1lwke7F+/y90NItSd1Bm/XPY/1NO94WS2osg4eNAxy06tjR vxgHR7Dle0Lr68praOgHU/G1XsHEyWMHt77v2BwqIFASoWFBynL1GKRXTa0I0/CJ8c hed0+I5PZfzG/ZaU1SukPihHYJJC4a+Qr0YKOhscKOkPLboYNnJ7pb21HgTdcxsANH sCnIu4N4LJYgQ== Date: Thu, 25 May 2023 19:21:19 -0700 Subject: [PATCH 08/10] xfs: log NVLOOKUP xattr nvreplace operations From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Allison Henderson , linux-xfs@vger.kernel.org, allison.henderson@oracle.com, catherine.hoang@oracle.com Message-ID: <168506077543.3749126.15762548958386388902.stgit@frogsfrogsfrogs> In-Reply-To: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> References: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 | 20 +++++++++++++++++++- libxfs/xfs_attr.h | 4 ++-- libxfs/xfs_da_btree.h | 6 +++++- libxfs/xfs_log_format.h | 27 +++++++++++++++++++++++---- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 8fa5b4f2819..2e6b6d6576e 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; } @@ -924,9 +938,13 @@ xfs_attr_defer_replace( struct xfs_da_args *args) { struct xfs_attr_intent *new; + int op_flag = XFS_ATTRI_OP_FLAGS_REPLACE; int error = 0; - error = xfs_attr_intent_init(args, XFS_ATTRI_OP_FLAGS_REPLACE, &new); + if (args->op_flags & XFS_DA_OP_NVLOOKUP) + op_flag = XFS_ATTRI_OP_FLAGS_NVREPLACE; + + error = xfs_attr_intent_init(args, op_flag, &new); if (error) return error; diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 4bacafa59a4..bb1776b8a6c 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 091750b2d42..c2255250c58 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 7b848b1d8aa..21fbe1f49b6 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 @@ -1038,6 +1040,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 */ /* @@ -1055,11 +1058,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 Fri May 26 02:21: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: 13256300 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 AEC82C7EE2E for ; Fri, 26 May 2023 02:21:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbjEZCVj (ORCPT ); Thu, 25 May 2023 22:21:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbjEZCVi (ORCPT ); Thu, 25 May 2023 22:21:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D16E0B2 for ; Thu, 25 May 2023 19:21:36 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 72DEA64C49 for ; Fri, 26 May 2023 02:21:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D28AFC433EF; Fri, 26 May 2023 02:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685067695; bh=wFL97SFPOMPzyf6NDCVCHFJpOJGzV1YH7/b6K1Banqs=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=MaNcq/RWYV7jA3GL6KKP4gAl8BNbQNHFw+cwfni+4dlOf0qDNy7fqZqvvZ4H5Koaw s0jNJffpr5JRkqak29gJmEfxXlc/Xl6uVzxp7YmAXWh35Zuy8Bu1aBLxIJHTisGaAg 4oGHGnmX5mlTS/07H4vsfLRiv2aV+RhvhyZa1cvBAGoSR3bQ1x543Kz2gutSQCLVkh R2ZXOlpaLXxGs0jSJYNjnFBeUAbyXhHQoUZNFw01jYdYkNN3fTzXBmlNOcVr4iCzqQ +tBPAtO3dppcyri1TnbAb4mxYGEOJ2xDDwo7gEvnOQ5vwdhn/wo5PjIsn5tTngFPuC jmUu+E01p7JAw== Date: Thu, 25 May 2023 19:21:35 -0700 Subject: [PATCH 09/10] xfs_logprint: dump new attr log item fields From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com, catherine.hoang@oracle.com Message-ID: <168506077557.3749126.13546809186832151071.stgit@frogsfrogsfrogs> In-Reply-To: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> References: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> 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 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 Fri May 26 02:21: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: 13256301 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 10971C7EE2F for ; Fri, 26 May 2023 02:22:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235273AbjEZCWB (ORCPT ); Thu, 25 May 2023 22:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234501AbjEZCV4 (ORCPT ); Thu, 25 May 2023 22:21:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85C90F7 for ; Thu, 25 May 2023 19:21:52 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 06B2664C49 for ; Fri, 26 May 2023 02:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 675A8C433D2; Fri, 26 May 2023 02:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685067711; bh=Q8Raf/qaui75K0YXpRdV+CyGxv1OvElKBNrmPljuyqY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=u3xcKW5yYL594K3PnaQQonqi8IrXlXEGxbsDsvnx0BQcSaI3/95ZVe8tX9Muo2dKg ZiqHHw41nk3wxGuBHm2z0R1jVGXRZrcQ4x2wKZtDkTnr+N9XHwv7NEctgIitIE9OVt jWTBuS50QKk2qBO5rHpNpcPK5l/FdOKI+TDOXhkyx+xckOQpduJSxGbPY7KjHBFL5C /UrZ2n0GfKwyqO5iTNw/2ywdFFyu23AbFi11u9flen0h95JsK3imsz6tBCSOKAHr5L 0URhP5lTKZniKsGeJzTVX0rzAmPuptLssFhKgUvr3io9M11t3eJiWfw3cMrEEN+PL8 VCuIwwzUaUErw== Date: Thu, 25 May 2023 19:21:51 -0700 Subject: [PATCH 10/10] xfs_logprint: print missing attri header fields From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com, catherine.hoang@oracle.com Message-ID: <168506077570.3749126.10426446233502380332.stgit@frogsfrogsfrogs> In-Reply-To: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> References: <168506077431.3749126.3177791326683307311.stgit@frogsfrogsfrogs> 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 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,