From patchwork Thu Apr 6 19:29:14 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: 13203952 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 28F19C7618D for ; Thu, 6 Apr 2023 19:29:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjDFT3Y (ORCPT ); Thu, 6 Apr 2023 15:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbjDFT3Q (ORCPT ); Thu, 6 Apr 2023 15:29:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3FC75272 for ; Thu, 6 Apr 2023 12:29:15 -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 6D6F264B8B for ; Thu, 6 Apr 2023 19:29:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB49EC433EF; Thu, 6 Apr 2023 19:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680809354; bh=iII8BctkB63guvAg8f4E7x/aOCOPewjgG+5xQPtbyQM=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=dxoftWUNintbwpiccnyx3+LAiWf3289tKiAxeIl4Ex6Sf0Yp6GDE9St8HZY/ObWB3 qBrb6EhQQN1B4LCECC3plhztnpLwoheHsPARzf0s5j0anzX1ayTeClNP0YHi3ToZb/ O0e7fA4ZzX3kG1Q0MHNWQ/0sDvLIpG2OGucP0bTC8X28XUrp4LQw4YfTfmuiAG03q2 HwV2VUyIpEGPi8XLdjhpwhFTtlBknDsrWsmMAEKFazxYQefWILtAscZYTzN6e+JyH1 m+tiOASpNgyyVF/f22d/aP06aR1SOqauOHWz/bzHbn2xaZhW7Hs7j0MexTVTiEw8Wn eIFwoA1kFseQg== Date: Thu, 06 Apr 2023 12:29:14 -0700 Subject: [PATCH 01/10] xfs: make xfs_attr_set require XFS_DA_OP_REMOVE From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080827129.616519.16285674158489951513.stgit@frogsfrogsfrogs> In-Reply-To: <168080827114.616519.13224581752144055912.stgit@frogsfrogsfrogs> References: <168080827114.616519.13224581752144055912.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 0d8d70a84..d493a1329 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -184,7 +184,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 2103a06b9..177962dec 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 Thu Apr 6 19:29: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: 13203953 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 4096AC7618D for ; Thu, 6 Apr 2023 19:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbjDFT3d (ORCPT ); Thu, 6 Apr 2023 15:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbjDFT3c (ORCPT ); Thu, 6 Apr 2023 15:29:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7069740DC for ; Thu, 6 Apr 2023 12:29:31 -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 0CCF764807 for ; Thu, 6 Apr 2023 19:29:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71550C433EF; Thu, 6 Apr 2023 19:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680809370; bh=EJAf33XamSKk8EUGGBNVxegld6XAVv1heYlEYEXColE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Z2RkSS1MbRTUdROT34XMGw1I7wbvX4LfzUZrbRx1TNa2zGlFcL7r+2zaWvG+PKoAp yQfy/zRYwIsQuy7wmRa27+AAaBC0qjXBTPfur31Z6/IvwluE5oxFFeRpGtM7cG8dbn WWCS2kNArta6rT/Ex3LZN2n2Ju9PTXggYoPkZ0HGoJ+0ZE+tU2uE76OSFJJF597JGu rWnA4NdDDuwB2iNG9kJxMhc2cOSbGD4xPloND/LOcpPFCfKNyYxmKDel6Uyqiim3T7 FYCKx/RZKc1rFzYchsBjVdiDnkEivKAEd1ecVJ8NYNjMHRwGp8WpMqk1T2FLS6BFKA C18Vd8t7iiwhw== Date: Thu, 06 Apr 2023 12:29:30 -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 Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080827142.616519.2987410761561141746.stgit@frogsfrogsfrogs> In-Reply-To: <168080827114.616519.13224581752144055912.stgit@frogsfrogsfrogs> References: <168080827114.616519.13224581752144055912.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 6cac25312..b095b25a6 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -470,10 +470,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) @@ -481,6 +483,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)) @@ -499,6 +518,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 */ @@ -723,6 +746,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; @@ -891,6 +915,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; } @@ -918,6 +943,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); @@ -970,7 +996,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; sfe = &sf->list[0]; for (i = 0; i < sf->hdr.count; i++) { @@ -1180,7 +1206,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; for (i = 0; i < ichdr.count; entry++, i++) { if (entry->flags & XFS_ATTR_INCOMPLETE) @@ -2479,14 +2505,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 ffa3df5b2..94a544fc8 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -93,6 +93,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" }, \ @@ -103,7 +104,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 Thu Apr 6 19:29: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: 13203954 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 73499C7618D for ; Thu, 6 Apr 2023 19:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235839AbjDFT34 (ORCPT ); Thu, 6 Apr 2023 15:29:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236339AbjDFT3r (ORCPT ); Thu, 6 Apr 2023 15:29:47 -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 0A112C3 for ; Thu, 6 Apr 2023 12:29: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 9696064B8B for ; Thu, 6 Apr 2023 19:29:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 007B2C433D2; Thu, 6 Apr 2023 19:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680809386; bh=3etMPV05LfjQTqKnICsuU/pZpDn58Nk9V7xTAnrQvcc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=TT6wY9NJnsSf6/juJnXYvDnGXMjm8kJ8dEBcQekyJLd8kBorGsVzd/PiggEAiL7pk FnieaRf3OjyDK0eq3xKfObTl2iOFPtTQIeQG70Ul09/Ok2vVYdPSrTGXL8xbZL25Qs g45eAux5seEoEUFrydxFJVDm/7PYnzqCILRKVEbnXvDZB0jDWxnDnX6W2ql9+LD4IU 32+Xs7zTmH7aK23NmmaLGHH3aSYkjxJgIHfR2Q+bSrMarjZV0jRENglUFdZRi1Jwwg lNKE1Nj9N4RPJYuBr2u+LEzzWn9R60IFwL3ddfSmGsp0jvnnD6GYHkobOtDwjE4Ym0 +a7mXM5kjCnKQ== Date: Thu, 06 Apr 2023 12:29:45 -0700 Subject: [PATCH 03/10] xfs: preserve NVLOOKUP in xfs_attr_set From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080827155.616519.12584533588194937442.stgit@frogsfrogsfrogs> In-Reply-To: <168080827114.616519.13224581752144055912.stgit@frogsfrogsfrogs> References: <168080827114.616519.13224581752144055912.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 177962dec..7782f00c1 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 Thu Apr 6 19:30: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: 13203955 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 66D81C76196 for ; Thu, 6 Apr 2023 19:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbjDFTaE (ORCPT ); Thu, 6 Apr 2023 15:30:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbjDFTaD (ORCPT ); Thu, 6 Apr 2023 15:30:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 923BD6E94 for ; Thu, 6 Apr 2023 12:30:02 -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 2AD9064807 for ; Thu, 6 Apr 2023 19:30:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C08AC433EF; Thu, 6 Apr 2023 19:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680809401; bh=h2cRsgHU4fiUE6MOtB08jMtcJhA1MR+cdxMfuODmhrw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ljGjHxnQ99wP8k1hZzCufKuueTqtirig+xwPG/DKTbi76WLQunSlRI6/TwSTre0PE tAwsZ8xxUos4nrbpdQHFvTiuxL3ykTBXgZL8kE8GnBDfAyAUlOzGWPgGPuYss0XKF0 sNTmC1dd5RcxHafCC8gNkVv8gtIWhKWFUZpcgL0AH6RtUUQS5sLDDzZrAZLr+WQohY CwReAdJtmqgFz2zObYqafz+Y2wAZJunvrPBl1HZuLLhHyZVDjBG0LxBTP3kQgYIYni wJHc/x4/7y2TkpM4r6OXQXU0HSgaEgtmURZlo35jhCzQGmKIikVoyY4bv5sqLlkiuc jsKq1ZJUHb7gA== Date: Thu, 06 Apr 2023 12:30:01 -0700 Subject: [PATCH 04/10] xfs: restructure xfs_attr_complete_op a bit From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080827168.616519.1051996710045283889.stgit@frogsfrogsfrogs> In-Reply-To: <168080827114.616519.13224581752144055912.stgit@frogsfrogsfrogs> References: <168080827114.616519.13224581752144055912.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 7782f00c1..137ba5e50 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 Thu Apr 6 19:30:16 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: 13203956 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 8BEC5C7618D for ; Thu, 6 Apr 2023 19:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229600AbjDFTaT (ORCPT ); Thu, 6 Apr 2023 15:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjDFTaS (ORCPT ); Thu, 6 Apr 2023 15:30:18 -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 1934EC3 for ; Thu, 6 Apr 2023 12:30: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 A915664B8B for ; Thu, 6 Apr 2023 19:30:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14DF9C433D2; Thu, 6 Apr 2023 19:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680809417; bh=1LBgxXge6Gg1JFkaaBCBDs2oA2cohQtg0RHFKKXAncA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=J4SW71RiqWoXW8dhGHUs9WYP8PfhQR3887cWQ2vCTuwhmzlO5TF6IRwtgPMM2uZso 0sEKb9QjmQDd22pyF0tvYBMN6KgFZMWnStivmfKzquw19SETIzkI30smp3bVLjZiOw ydwW9L0j/gIZjzXb1ZwoTfuYtu7FoycCwt/CcBecKFkDIiBM8BsttfRVTRStoTDx75 xY38uka9zXSz6gih5K0gDPC2FGWKKv8pGhmFPSEgUZct0KKQCqmijGbvWe3GCxRHb7 ahdwVkXCYZGzGsa9R2WGTHZjSawYxnS5CLwejNlx0f2Skdax9Cws27RTgWZ8Bu+bxi fIw5J24r0LMRg== Date: Thu, 06 Apr 2023 12:30:16 -0700 Subject: [PATCH 05/10] xfs: use helpers to extract xattr op from opflags From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080827181.616519.1699264842688527792.stgit@frogsfrogsfrogs> In-Reply-To: <168080827114.616519.13224581752144055912.stgit@frogsfrogsfrogs> References: <168080827114.616519.13224581752144055912.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 81be9b3e4..f0aa372ec 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 Thu Apr 6 19:30: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: 13203957 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 3644BC76196 for ; Thu, 6 Apr 2023 19:30:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229740AbjDFTaf (ORCPT ); Thu, 6 Apr 2023 15:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjDFTae (ORCPT ); Thu, 6 Apr 2023 15:30:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B387DC3 for ; Thu, 6 Apr 2023 12:30:33 -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 4B28764AD2 for ; Thu, 6 Apr 2023 19:30:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD73EC433EF; Thu, 6 Apr 2023 19:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680809432; bh=zWRQaspgWo9mrQ+lbs63wC++IaFaQYEjCAhuKqDkYOU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=J3CIA6M/Zs3Bu+sMYNyr+2NDHwD4J8aZzvLX+v1fJsoXerYyqudAAL1nnCeiSQcru ai9aYcr1qcbQybonWe8Ked4y3SqiEpHVVSIGAqF1k9rZZQguYCYr/eW7rE79qOYe+x 6MAJ5pZ/qau0iUGZ5N9U34UyYuA/ay557cQqroWSr/yMX8vIWAlLFTM1gBbb57Rhci riywuYL46azdqHz0fXfKX5Tf4ci6nWcrzxr93waOXHivpOnsPtd0SPuM2hAFoGHrkZ idalXsiSbOvsIdfXT65NJn9X1XhmA52pxaPQXQpzj1z1PhL/Oa0GYBrhBKXShN4eB7 b5s3XN+illM9A== Date: Thu, 06 Apr 2023 12:30:32 -0700 Subject: [PATCH 06/10] xfs: log NVLOOKUP xattr removal operations From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080827194.616519.17565216322382066888.stgit@frogsfrogsfrogs> In-Reply-To: <168080827114.616519.13224581752144055912.stgit@frogsfrogsfrogs> References: <168080827114.616519.13224581752144055912.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 137ba5e50..9621f8715 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 f13e0809d..ecf0ac32d 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -957,6 +957,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 Thu Apr 6 19:30:47 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: 13203958 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 DB987C7618D for ; Thu, 6 Apr 2023 19:30:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233464AbjDFTax (ORCPT ); Thu, 6 Apr 2023 15:30:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236270AbjDFTav (ORCPT ); Thu, 6 Apr 2023 15:30:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73F669004 for ; Thu, 6 Apr 2023 12:30:49 -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 E6DD764BA5 for ; Thu, 6 Apr 2023 19:30:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51EB1C433EF; Thu, 6 Apr 2023 19:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680809448; bh=vRClyRSsT11H+C7M9adEzUyAb8ceiG7dlPs99jNTiLw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=SnU8yAlXg+LQ7JQRKECcAbZG6zMlFDag2yR9MsUui48ANnAvRbXDH1an0OlfSUJBs qRGma1MBLiBxPNGid22SompnxPGbvxGZVW/hlMlxDFBJ6LXSbqkbltCer10tBAaueJ e1WPkeVgwTpT7KPDLvx+cF5mk47iwvJZ1DYP46dioWpDej06iKN2AHpzj0zqqyMJ3m /ELvdCTpsMs43grDqDgY8Lt2uIxYCyn4aL7/DOn/I1/Pw6qb06SkJ8iAhV2Et/nSs/ l0gQdtE3bDgGRJOV4ix/hLdoIldlqsqtH+/pYr3wy8r+fOiEmer0VrBo63/r/xmoRD Fnn9fFqvx+VaQ== Date: Thu, 06 Apr 2023 12:30:47 -0700 Subject: [PATCH 07/10] xfs: log NVLOOKUP xattr setting operations From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080827207.616519.9220542881940587774.stgit@frogsfrogsfrogs> In-Reply-To: <168080827114.616519.13224581752144055912.stgit@frogsfrogsfrogs> References: <168080827114.616519.13224581752144055912.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 9621f8715..a8c778bbd 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 ecf0ac32d..7a4226e20 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -958,6 +958,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 Thu Apr 6 19:31:03 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: 13203959 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 DB529C76196 for ; Thu, 6 Apr 2023 19:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbjDFTbH (ORCPT ); Thu, 6 Apr 2023 15:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236041AbjDFTbG (ORCPT ); Thu, 6 Apr 2023 15:31:06 -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 EC8F26A75 for ; Thu, 6 Apr 2023 12:31:04 -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 82C7264B8E for ; Thu, 6 Apr 2023 19:31:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCF15C433EF; Thu, 6 Apr 2023 19:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680809463; bh=mey7nnwma5hYqAueiUwPp7S1bu5hMoZ1uVeHWZ2Hrck=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=savAUZwaK5iSnqT9e/XODw32e3h+4+RpUdS4VKC36V4rkkUWOxPh2hozMLUq/B3qN g88xrzBNva9h9uFVG74hUlwcUlHpPcZ+f/7Cb5u7IaKCnXe+r/iXcpO0jcWE44J0Az p35oCRAvWcjbqnuvA9HBp0JyIph0urJRTiejBDDoCpLqBK9nDVOwnrT+jVr7XGLnCp hQHMn29tGPGsCGumuankFQfAfOR3/8X27ZAd+Abi31ljA9HuutWt1SG1fFcrk8nnKG dtCv6mptmuPRm7lEGAjits/TFyCeQoF20c+nOgNsdLB6gz0wROCkoYNxMbNXh/3g/0 ZbpbUCXSNyIwQ== Date: Thu, 06 Apr 2023 12:31:03 -0700 Subject: [PATCH 08/10] xfs: log NVLOOKUP xattr nvreplace operations From: "Darrick J. Wong" To: djwong@kernel.org Cc: Allison Henderson , allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080827220.616519.3703679355819409111.stgit@frogsfrogsfrogs> In-Reply-To: <168080827114.616519.13224581752144055912.stgit@frogsfrogsfrogs> References: <168080827114.616519.13224581752144055912.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 | 28 +++++++++++++++++++++++----- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index a8c778bbd..41d7a56c1 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 f0aa372ec..d543a6a01 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 94a544fc8..fc4dc3e87 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 7a4226e20..d666bfa5d 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -115,10 +115,11 @@ 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_MAX 30 - +#define XLOG_REG_TYPE_ATTR_NEWNAME 31 +#define XLOG_REG_TYPE_ATTR_NEWVALUE 32 +#define XLOG_REG_TYPE_MAX 32 /* * Flags to log operation header @@ -959,6 +960,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 */ /* @@ -976,11 +978,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 Thu Apr 6 19:31: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: 13203960 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 3DC3FC76196 for ; Thu, 6 Apr 2023 19:31:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233619AbjDFTbW (ORCPT ); Thu, 6 Apr 2023 15:31:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236156AbjDFTbV (ORCPT ); Thu, 6 Apr 2023 15:31:21 -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 B0D2B5580 for ; Thu, 6 Apr 2023 12:31:20 -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 2975864B8B for ; Thu, 6 Apr 2023 19:31:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 860ABC433EF; Thu, 6 Apr 2023 19:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680809479; bh=QXLpCCcZarrSHdr/5J0QMrmjwUmEdqFxrARf+RktNWc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=d4zfHVcLYuaP2u6XmGFKm3PAAIw6dNSaWXUF+TUwXjXuYBEwP1wpR/cIjy3hhqzZf PFJUrUrBDWZwDwpEQ1hX9wiZ6M6znaAbT7lA9pWI9ajfwpm+D9mx8vXSspk2lvKtJm YDS3zgXVlglrD9IQ4mMlEBdvurcQp4gc+/NoaKcF9Ur+EmMM+4UiBSMg7w2lDDPsNs eTJwn7V0INilEP5seH+69KiJ4r6lSTBzL5YFI32FdX8gHI0kPOhwuBZys0vMZBZd5F a8dHs5G+1mVvnbXWWJ6IDNDv2/oRxoIAjY4jcc++uOCeOpfHEndsehBplQyv0jFV2g VfbjfGWusBNmA== Date: Thu, 06 Apr 2023 12:31:19 -0700 Subject: [PATCH 09/10] xfs_logprint: dump new attr log item fields From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080827233.616519.15176184729186777150.stgit@frogsfrogsfrogs> In-Reply-To: <168080827114.616519.13224581752144055912.stgit@frogsfrogsfrogs> References: <168080827114.616519.13224581752144055912.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 edf7e0fbf..2eaf58918 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 b4479c240..27f1cd9a7 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 Thu Apr 6 19:31:34 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: 13203961 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 2AEF1C77B6C for ; Thu, 6 Apr 2023 19:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbjDFTbj (ORCPT ); Thu, 6 Apr 2023 15:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbjDFTbg (ORCPT ); Thu, 6 Apr 2023 15:31:36 -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 2AC2E40DC for ; Thu, 6 Apr 2023 12:31: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 BD5FF64B8E for ; Thu, 6 Apr 2023 19:31:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 255B4C4339E; Thu, 6 Apr 2023 19:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680809495; bh=Iv+KQltjEHRuGprrtcSi6sRNHtwO84ehNXxozH3HKkQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=giP709UxXBVVeRpisICjAo4guJzonj0TQdGKlFzUkgwJtpuc6PyBctYlU41FabOhp muQwMMOPMUIx1+mDbIHrUD8z/Rd0wYd4+4nL+AYcUq+mL9t8PuvHLzUvNFx/gAvmmR SsTnnRyHDwQ3kmo4gx2mkzAvWijMbILc57KrrIcDCgcYRGk10fzS9a9R0QKF833ZTH LfjEf0yGd8WWHPXHu/6SbUn7/MAnJCqghroxiwuQ+rBB7N32pV4meVUYXCuz/hxSWa AfMpxuky4PrKPVh66JVKUi0wIvNqK44r9bbMFEWxTAJdRnuqvuTtRqiIvzl0RhKLXv t4j6qSnjJTL6w== Date: Thu, 06 Apr 2023 12:31:34 -0700 Subject: [PATCH 10/10] xfs_logprint: print missing attri header fields From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080827246.616519.15352617723076593191.stgit@frogsfrogsfrogs> In-Reply-To: <168080827114.616519.13224581752144055912.stgit@frogsfrogsfrogs> References: <168080827114.616519.13224581752144055912.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 2eaf58918..8b6aa9279 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,