From patchwork Fri Mar 3 17:11:24 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: 13159036 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 2B7E0C64EC4 for ; Fri, 3 Mar 2023 17:11:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230381AbjCCRL0 (ORCPT ); Fri, 3 Mar 2023 12:11:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229974AbjCCRL0 (ORCPT ); Fri, 3 Mar 2023 12:11:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 831651EFD5 for ; Fri, 3 Mar 2023 09:11:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 240D46182C for ; Fri, 3 Mar 2023 17:11:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80536C433A1; Fri, 3 Mar 2023 17:11:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863484; bh=5PCIZT1EQB1EqvLBdFvGVjEZHWpOPtUxuybz0t+9ojI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=aZmLuGuMGBMLiApXy+MVW9zpLtU2Us+R6f9D12TnL1cv6O8mBDKypet2zLQXj4MaU haV42SOBjrjL1wI5Zpqzl1iDvnd86q0XEeRW2Entcov3xJ/UNHnk+65BjSWPz9XChH W76ZkuV4wUxZqgN+74h/mIT/8IHcQ+RdhwPGQBLIA9ScJG2p0EhWCqIsf+YK7O70nr njMgmQdam0VKS+pNqGc+dnqoBqlYjvzP1EjSuKZJOtJ6xOKMcV8Lv+BYR4HJR5mxdS NzqdGdIJnhYhYzqMETg0quIqj3zxd0FyA5wzSxAbdpqsjYZ/a5k051ix9n434/98fT ACneW1Aen0+bg== Subject: [PATCH 01/13] 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 Date: Fri, 03 Mar 2023 09:11:24 -0800 Message-ID: <167786348406.1543331.16739128076405218565.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong In the next patch we're going to add the ability to look up local/sf xattrs based on the attr name and value matching. As a result, we need callers of xfs_attr_set to declare explicitly that they want to remove an xattr. Passing in NULL value will no longer suffice. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 9 +++++---- fs/xfs/libxfs/xfs_parent.c | 1 + fs/xfs/xfs_xattr.c | 5 +++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 3065dd622102..756d93526075 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -977,6 +977,7 @@ xfs_attr_set( struct xfs_inode *dp = args->dp; struct xfs_mount *mp = dp->i_mount; struct xfs_trans_res tres; + bool is_remove = args->op_flags & XFS_DA_OP_REMOVE; bool rsvd; int error, local; int rmt_blks = 0; @@ -1004,7 +1005,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); @@ -1038,7 +1039,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) @@ -1052,7 +1053,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; } @@ -1064,7 +1065,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. */ diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c index f7fecee93894..387f3c65287f 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -460,6 +460,7 @@ xfs_parent_unset( scr->args.geo = ip->i_mount->m_attr_geo; scr->args.name = (const unsigned char *)&scr->rec; scr->args.namelen = reclen; + scr->args.op_flags = XFS_DA_OP_REMOVE; scr->args.whichfork = XFS_ATTR_FORK; return xfs_attr_set(&scr->args); diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 85edd7e05fde..8f8aa13bf7eb 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -103,6 +103,11 @@ xfs_attr_change( use_logging = true; } + if (args->value) + args->op_flags &= ~XFS_DA_OP_REMOVE; + else + args->op_flags |= XFS_DA_OP_REMOVE; + error = xfs_attr_set(args); if (use_logging) From patchwork Fri Mar 3 17:11:29 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: 13159037 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 9A25AC7EE2F for ; Fri, 3 Mar 2023 17:11:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230407AbjCCRLc (ORCPT ); Fri, 3 Mar 2023 12:11:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjCCRLc (ORCPT ); Fri, 3 Mar 2023 12:11:32 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F771EFD5 for ; Fri, 3 Mar 2023 09:11:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C89C8618A6 for ; Fri, 3 Mar 2023 17:11:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34BB3C433D2; Fri, 3 Mar 2023 17:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863490; bh=KFpT2qnjF/Ux5m3WRTPqeCFTIXWDEy2tfUqdHI/3bxY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=APlU850h8EJ4ug+uwyjmR4Q1KnZOXr1Mch+elxRZ3EW1Zb6CoYyxnA+fMronykHfW iEk/SQ3G4zsIg+Ae19y1uSCpbFHKnbydYXk6M7dv+BuGi3WbW/LFUi4a/1FHBFEJUx RocLsaNjsFUNLNJ6cRWPjoB19N07QT/D+xldN5OtQyi2bG0M0Cu9ToA6cFZac/OjLp mBx7cwQx2gagR0VPcbKvjquipev+6N9gOdKHuJXOy/jgLjogOIthO4EWQRSZVZLH4n 0QR8PGe1sKxKzHXmXIDs7PSrEeMtOASsuRalS17DzLILzLkkmrQWzdhF10RwWWq9F6 VIolvu9HMZXFw== Subject: [PATCH 02/13] xfs: allow xattr matching on value for local/sf attrs From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:11:29 -0800 Message-ID: <167786348969.1543331.17889734281722303103.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr_leaf.c | 41 +++++++++++++++++++++++++++++++++++------ fs/xfs/libxfs/xfs_da_btree.h | 4 +++- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index e6c4c8b52a55..d05f2c5cc0cc 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -473,10 +473,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) @@ -484,6 +486,23 @@ xfs_attr_match( if (memcmp(args->name, name, namelen) != 0) return false; + if (args->op_flags & XFS_DA_OP_VLOOKUP) { + 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)) @@ -502,6 +521,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_VLOOKUP) + return 0; + /* * No copy if all we have to do is get the length */ @@ -726,6 +749,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; @@ -896,6 +920,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; } @@ -923,6 +948,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); @@ -2484,14 +2510,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/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index 90b86d00258f..0ef32f629e1b 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -96,6 +96,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_VLOOKUP (1u << 9) /* Compare attr value during lookup */ #define XFS_DA_OP_FLAGS \ { XFS_DA_OP_JUSTCHECK, "JUSTCHECK" }, \ @@ -106,7 +107,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_VLOOKUP, "VLOOKUP" } /* * Storage for holding state during Btree searches and split/join ops. From patchwork Fri Mar 3 17:11: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: 13159038 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 8ADF6C64EC4 for ; Fri, 3 Mar 2023 17:11:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231173AbjCCRLj (ORCPT ); Fri, 3 Mar 2023 12:11:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjCCRLj (ORCPT ); Fri, 3 Mar 2023 12:11:39 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46EDE1E5F7 for ; Fri, 3 Mar 2023 09:11:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 073A8B81992 for ; Fri, 3 Mar 2023 17:11:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC8A2C433D2; Fri, 3 Mar 2023 17:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863495; bh=7unI4aM4kWj0c4FF4eod83BtE4iRejRvVLdrHGZCPqI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=K6Kc6kgCcdtQzNEOnCiXeEgmC9+lLNHteRJ2pZPlUDH/DTIKi8MDSoltvrIelH5Jy L2fe3ErbOw0HQClL83Dkq9PjUKc0k1zAikaQ7FcaUIKmYaxVuWszym3rbAHdeOpS+e hC7oNaURQtf3Qd2da4lC8+3aOrCg+UHlaFF9cNEDFSPKeNmOb215j3wcCB/T5ZOR/z VBOUAt++nvYJ0LrYsRYwgSQIPJQ7RRsIRcXZW1oi1f+HAHOCZOc/BbU7MehrefVKEw 5wSVkctkljyQBXbwj4VP8Y8RRgf246PRCS8ukrp3mdkaVyneTIOPcJHLU1wbey9NAg F9gBcYAyebmgA== Subject: [PATCH 03/13] xfs: preserve VLOOKUP in xfs_attr_set From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:11:35 -0800 Message-ID: <167786349536.1543331.16786039072000569273.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong 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 --- fs/xfs/libxfs/xfs_attr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 756d93526075..86672061c99e 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -999,11 +999,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_VLOOKUP); + args->op_flags |= XFS_DA_OP_OKNOENT; if (!is_remove) { XFS_STATS_INC(mp, xs_attr_set); From patchwork Fri Mar 3 17:11:40 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: 13159039 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 801BAC64EC4 for ; Fri, 3 Mar 2023 17:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231196AbjCCRLp (ORCPT ); Fri, 3 Mar 2023 12:11:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjCCRLp (ORCPT ); Fri, 3 Mar 2023 12:11:45 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD5181E5F7 for ; Fri, 3 Mar 2023 09:11:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A1B73B8191F for ; Fri, 3 Mar 2023 17:11:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65EC5C433EF; Fri, 3 Mar 2023 17:11:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863501; bh=n0+2D2TJFJm5z0gr0gdoJVNRMdiZoXMhillFRrYe4cY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=tEcCI+kyBXu6y/j+NJJ8ZDEGlWFaGLf17YGXolm1Q0XgGc5329J7KJo17y8TAxjwj 4hmHk+m/lr3ORsOgSxPhAHNVp6TnQs/K5/dokwgDQSqcb0TEDfrQN0wx0BU8KIwrZb Gk0MZr08KkyIui1+SPHwh9GL2/9WQx9X448lqn7ICG5T6WUkrfv0bKUyI+LvskHrir qJMtBUiat0G+S0CxvLYlYYfxFKkVVF7ndO4TcTl51lSik/JBUBZqqGcBSdU+9cT7tX rF+RN0f+VNuhJsC3g2HaFbE2dvzdeSPDpjLbMk2s8t6dBz/oeaBJWLU7aWWGAA/tcQ Zc6QDkKND8JDQ== Subject: [PATCH 04/13] xfs: log VLOOKUP xattr removal operations From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:11:40 -0800 Message-ID: <167786350094.1543331.12664403111045148085.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong If high level code wants to do a deferred xattr remove operation with the VLOOKUP flag set, we need to push this through the log. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 6 +++++- fs/xfs/libxfs/xfs_log_format.h | 1 + fs/xfs/xfs_attr_item.c | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 86672061c99e..6468286d2d71 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -953,9 +953,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_VLOOKUP) + op_flag = XFS_ATTRI_OP_FLAGS_NVREMOVE; + + error = xfs_attr_intent_init(args, op_flag, &new); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index 727b5a858028..a3d95a3d8476 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -959,6 +959,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_NVREPLACE 4 /* Replace attr name and val */ +#define XFS_ATTRI_OP_FLAGS_NVREMOVE 5 /* Remove attr w/ vlookup */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 792c01a49749..08cb26d6b37b 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -544,6 +544,7 @@ xfs_attri_validate( case XFS_ATTRI_OP_FLAGS_REPLACE: case XFS_ATTRI_OP_FLAGS_REMOVE: case XFS_ATTRI_OP_FLAGS_NVREPLACE: + case XFS_ATTRI_OP_FLAGS_NVREMOVE: break; default: return false; @@ -643,6 +644,11 @@ xfs_attri_item_recover( else attr->xattri_dela_state = xfs_attr_init_add_state(args); break; + case XFS_ATTRI_OP_FLAGS_NVREMOVE: + args->op_flags |= XFS_DA_OP_VLOOKUP; + args->value = nv->value.i_addr; + args->valuelen = nv->value.i_len; + fallthrough; case XFS_ATTRI_OP_FLAGS_REMOVE: if (!xfs_inode_hasattr(args->dp)) goto out; @@ -769,6 +775,7 @@ xlog_recover_attri_commit_pass2( switch (op) { case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: + case XFS_ATTRI_OP_FLAGS_NVREMOVE: if (item->ri_total != 3 && item->ri_total != 2) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, attri_formatp, len); From patchwork Fri Mar 3 17:11: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: 13159040 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 849B1C64EC4 for ; Fri, 3 Mar 2023 17:11:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231313AbjCCRLu (ORCPT ); Fri, 3 Mar 2023 12:11:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjCCRLs (ORCPT ); Fri, 3 Mar 2023 12:11:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21ED41E5F7 for ; Fri, 3 Mar 2023 09:11:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AF053618A2 for ; Fri, 3 Mar 2023 17:11:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 188C5C433D2; Fri, 3 Mar 2023 17:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863507; bh=YEDcSc1cJfiDX6zloYDQzLyEcNJ9ichsgku5ugFJXr4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Org0wuEo6nwqx9M6Qq2x/LooLQRISyinVHUNf8PG4JGbtiz92PLn0Zuivc5bQEsMo TfJX89MctBldUBoMeIU2NWwwyMc4C7aNFduv9oeX/uzGGvmKnjPpBMJyfa5/4wtrke JYMe9ZwzH2Obyz6KixSNmeCrNbs/LJZZoUWcozXn4Ju3qPF3hLDX8FrUDJkBZoTqf3 h+RY4UMtpPqrYLISibGO9gCELQCYWJmDKuDvTA3FR08u2wAkxpH4abhuA5uq5DBgJc z/CxNMO8gAufExNzmskXaML1mbhOhEw+B4pbwuq/xtVqvEkkONyWynsz6jokocheyo 1Qo8ArpYGvtIg== Subject: [PATCH 05/13] xfs: log VLOOKUP xattr setting operations From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:11:46 -0800 Message-ID: <167786350657.1543331.8819703939606652496.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong If high level code wants to do a deferred xattr set operation with the VLOOKUP flag set, we need to push this through the log. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 6 +++++- fs/xfs/libxfs/xfs_log_format.h | 1 + fs/xfs/xfs_attr_item.c | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 6468286d2d71..ba8ad232b306 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -910,9 +910,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_VLOOKUP) + op_flag = XFS_ATTRI_OP_FLAGS_NVSET; + + error = xfs_attr_intent_init(args, op_flag, &new); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index a3d95a3d8476..1fe9f7394812 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -960,6 +960,7 @@ struct xfs_icreate_log { #define XFS_ATTRI_OP_FLAGS_REPLACE 3 /* Replace the attribute */ #define XFS_ATTRI_OP_FLAGS_NVREPLACE 4 /* Replace attr name and val */ #define XFS_ATTRI_OP_FLAGS_NVREMOVE 5 /* Remove attr w/ vlookup */ +#define XFS_ATTRI_OP_FLAGS_NVSET 6 /* Set attr with w/ vlookup */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 08cb26d6b37b..79a459e8d51a 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -545,6 +545,7 @@ xfs_attri_validate( case XFS_ATTRI_OP_FLAGS_REMOVE: case XFS_ATTRI_OP_FLAGS_NVREPLACE: case XFS_ATTRI_OP_FLAGS_NVREMOVE: + case XFS_ATTRI_OP_FLAGS_NVSET: break; default: return false; @@ -633,6 +634,9 @@ xfs_attri_item_recover( ASSERT(xfs_sb_version_haslogxattrs(&mp->m_sb)); switch (attr->xattri_op_flags) { + case XFS_ATTRI_OP_FLAGS_NVSET: + args->op_flags |= XFS_DA_OP_VLOOKUP; + fallthrough; case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: case XFS_ATTRI_OP_FLAGS_NVREPLACE: @@ -773,6 +777,7 @@ xlog_recover_attri_commit_pass2( op = attri_formatp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK; switch (op) { + case XFS_ATTRI_OP_FLAGS_NVSET: case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: case XFS_ATTRI_OP_FLAGS_NVREMOVE: From patchwork Fri Mar 3 17:11:52 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: 13159041 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 2419DC64EC4 for ; Fri, 3 Mar 2023 17:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231510AbjCCRL5 (ORCPT ); Fri, 3 Mar 2023 12:11:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjCCRL4 (ORCPT ); Fri, 3 Mar 2023 12:11:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B5B02384A for ; Fri, 3 Mar 2023 09:11:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 15B82B8191F for ; Fri, 3 Mar 2023 17:11:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAD9AC433EF; Fri, 3 Mar 2023 17:11:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863512; bh=YCcxwSsquDG9EOlPhKO4rGkl5BOg21++RqNBfLaRo7Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=pJ92VwKVTfjNSpv6PQ0j7OTRLNRnQ29Y0D+WZN8d0bZ6wp+bmHnd+d/KfkJ15Xzgy t/+Xvn81dZ12I7OOnGvfIUSX0vGRrVOtrgpTjq/EwCr/rpavV1j4vaeDkHSHsnQ/zR E2lSDXD6r7g3CFTWH1rYkf//Jv8JfgPi9sYGZFKxg2QOUr3IXJ4daJSj76tynpYOIf 6YADlB0qbRpBKKoNc9gdZinlAJOeIsCCPf4sZZpeHfvz5I/SDgPYJAo2Z6E6CQGwuZ qiLNmq8kc3dcu+draYH8IS+7Fqzyx7GQGpYPe/TxIZM+Q+Ve5qXrRFX0MGiRLBpWWH tV8gdBAAwkPww== Subject: [PATCH 06/13] xfs: refactor extracting attri ops from alfi_op_flags From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:11:52 -0800 Message-ID: <167786351226.1543331.5452828411615681184.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Refactor this very long expression into a helper before we start adding more of them. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_attr_item.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 79a459e8d51a..6dce2110a871 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -374,6 +374,12 @@ xfs_xattri_finish_update( return error; } +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; +} + /* Log an attr to the intent item. */ STATIC void xfs_attr_log_item( @@ -525,8 +531,7 @@ xfs_attri_validate( struct xfs_mount *mp, struct xfs_attri_log_format *attrp) { - unsigned int op = attrp->alfi_op_flags & - XFS_ATTRI_OP_FLAGS_TYPE_MASK; + unsigned int op = xfs_attr_log_item_op(attrp); if (attrp->alfi_op_flags != XFS_ATTRI_OP_FLAGS_NVREPLACE && attrp->alfi_nname_len != 0) @@ -608,8 +613,7 @@ xfs_attri_item_recover( args = (struct xfs_da_args *)(attr + 1); attr->xattri_da_args = args; - attr->xattri_op_flags = attrp->alfi_op_flags & - XFS_ATTRI_OP_FLAGS_TYPE_MASK; + attr->xattri_op_flags = xfs_attr_log_item_op(attrp); /* * We're reconstructing the deferred work state structure from the @@ -775,7 +779,7 @@ xlog_recover_attri_commit_pass2( return -EFSCORRUPTED; } - op = attri_formatp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK; + op = xfs_attr_log_item_op(attri_formatp); switch (op) { case XFS_ATTRI_OP_FLAGS_NVSET: case XFS_ATTRI_OP_FLAGS_SET: From patchwork Fri Mar 3 17:11:57 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: 13159042 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 98794C64EC4 for ; Fri, 3 Mar 2023 17:12:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231377AbjCCRMD (ORCPT ); Fri, 3 Mar 2023 12:12:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbjCCRMA (ORCPT ); Fri, 3 Mar 2023 12:12:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E3725975 for ; Fri, 3 Mar 2023 09:11:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ED7AB615DA for ; Fri, 3 Mar 2023 17:11:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50170C433EF; Fri, 3 Mar 2023 17:11:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863518; bh=5JPOZ3u6ZnWuvsmfekFnah4UkWkBRdblHoejQenowPE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ghdN3P/ZlxJXhn/mB+ucHoHdy2DYHnJPOfHFurgvDEt1d0gnMngifHrASZTMayExv 0TGRlaSsdbSkpffiWBncAXT6FB9hbyBpK5QDuViLSqZNPABfRLcjk4Qopy7zs6/Bpg /T0HYYVnyebkxsMATruiI+f/NE9n2P00DVUF/3miG3CS9djT3qwpN3T059I7EzJCZ9 NAuGqQ5SCx0UkabZEaQwao8ILAGMLvbA407Scd5gWt1OVcm/lf6OZ98MsVf4PkIISh 96uReSHJzXAfP4TMLxozhb+qtTqNpFzY+hFR60nzcH+zHYPA6Hp04bAOdN/2FtIifH NtIbUewJKI5jA== Subject: [PATCH 07/13] xfs: overlay alfi_nname_len atop alfi_name_len for NVREPLACE From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:11:57 -0800 Message-ID: <167786351788.1543331.14769917906504208002.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong In preparation for being able to log the old attr value in a NVREPLACE operation, encode the old and new name lengths in the alfi_name_len field. We haven't shipped a kernel with XFS_ATTRI_OP_FLAGS_NVREPLACE, so we can still tweak the ondisk log item format. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_log_format.h | 14 ++++++- fs/xfs/xfs_attr_item.c | 81 ++++++++++++++++++++++++---------------- 2 files changed, 60 insertions(+), 35 deletions(-) diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index 1fe9f7394812..32035786135b 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -979,11 +979,21 @@ 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 alfi_nname_len; /* attr new name length */ + uint32_t __pad; /* pad to 64 bit aligned */ 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_oldname_len; + uint16_t alfi_newname_len; + }; + }; uint32_t alfi_value_len; /* attr value length */ uint32_t alfi_attr_filter;/* attr filter flags */ }; diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 6dce2110a871..6042ba34f705 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -402,8 +402,14 @@ xfs_attr_log_item( ASSERT(!(attr->xattri_op_flags & ~XFS_ATTRI_OP_FLAGS_TYPE_MASK)); attrp->alfi_op_flags = attr->xattri_op_flags; attrp->alfi_value_len = attr->xattri_nameval->value.i_len; - attrp->alfi_name_len = attr->xattri_nameval->name.i_len; - attrp->alfi_nname_len = attr->xattri_nameval->nname.i_len; + + if (xfs_attr_log_item_op(attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { + attrp->alfi_oldname_len = attr->xattri_nameval->name.i_len; + attrp->alfi_newname_len = attr->xattri_nameval->nname.i_len; + } else { + attrp->alfi_name_len = attr->xattri_nameval->name.i_len; + } + ASSERT(!(attr->xattri_da_args->attr_filter & ~XFS_ATTRI_FILTER_MASK)); attrp->alfi_attr_filter = attr->xattri_da_args->attr_filter; } @@ -533,10 +539,6 @@ xfs_attri_validate( { unsigned int op = xfs_attr_log_item_op(attrp); - if (attrp->alfi_op_flags != XFS_ATTRI_OP_FLAGS_NVREPLACE && - attrp->alfi_nname_len != 0) - return false; - if (attrp->alfi_op_flags & ~XFS_ATTRI_OP_FLAGS_TYPE_MASK) return false; @@ -545,29 +547,37 @@ xfs_attri_validate( /* alfi_op_flags should be either a set or remove */ switch (op) { + case XFS_ATTRI_OP_FLAGS_REMOVE: + if (attrp->alfi_value_len != 0) + return false; + if (attrp->alfi_name_len == 0 || + attrp->alfi_name_len > XATTR_NAME_MAX) + return false; + break; case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: - case XFS_ATTRI_OP_FLAGS_REMOVE: - case XFS_ATTRI_OP_FLAGS_NVREPLACE: case XFS_ATTRI_OP_FLAGS_NVREMOVE: case XFS_ATTRI_OP_FLAGS_NVSET: + if (attrp->alfi_name_len == 0 || + attrp->alfi_name_len > XATTR_NAME_MAX) + return false; + if (attrp->alfi_value_len > XATTR_SIZE_MAX) + return false; + break; + case XFS_ATTRI_OP_FLAGS_NVREPLACE: + if (attrp->alfi_oldname_len == 0 || + attrp->alfi_oldname_len > XATTR_NAME_MAX) + return false; + if (attrp->alfi_newname_len == 0 || + attrp->alfi_newname_len > XATTR_NAME_MAX) + return false; + if (attrp->alfi_value_len > XATTR_SIZE_MAX) + return false; break; default: return false; } - if (attrp->alfi_value_len > XATTR_SIZE_MAX) - return false; - - if ((attrp->alfi_name_len > XATTR_NAME_MAX) || - (attrp->alfi_nname_len > XATTR_NAME_MAX) || - (attrp->alfi_name_len == 0)) - return false; - - if (op == XFS_ATTRI_OP_FLAGS_REMOVE && - attrp->alfi_value_len != 0) - return false; - return xfs_verify_ino(mp, attrp->alfi_ino); } @@ -737,8 +747,12 @@ xfs_attri_item_relog( new_attrp->alfi_ino = old_attrp->alfi_ino; new_attrp->alfi_op_flags = old_attrp->alfi_op_flags; new_attrp->alfi_value_len = old_attrp->alfi_value_len; - new_attrp->alfi_name_len = old_attrp->alfi_name_len; - new_attrp->alfi_nname_len = old_attrp->alfi_nname_len; + if (xfs_attr_log_item_op(old_attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { + new_attrp->alfi_newname_len = old_attrp->alfi_newname_len; + new_attrp->alfi_oldname_len = old_attrp->alfi_oldname_len; + } else { + new_attrp->alfi_name_len = old_attrp->alfi_name_len; + } new_attrp->alfi_attr_filter = old_attrp->alfi_attr_filter; xfs_trans_add_item(tp, &new_attrip->attri_item); @@ -762,6 +776,7 @@ xlog_recover_attri_commit_pass2( const void *attr_name; size_t len; const void *attr_nname = NULL; + unsigned int name_len = 0, newname_len = 0; int op, i = 0; /* Validate xfs_attri_log_format before the large memory allocation */ @@ -790,6 +805,7 @@ xlog_recover_attri_commit_pass2( attri_formatp, len); return -EFSCORRUPTED; } + name_len = attri_formatp->alfi_name_len; break; case XFS_ATTRI_OP_FLAGS_REMOVE: if (item->ri_total != 2) { @@ -797,6 +813,7 @@ xlog_recover_attri_commit_pass2( attri_formatp, len); return -EFSCORRUPTED; } + name_len = attri_formatp->alfi_name_len; break; case XFS_ATTRI_OP_FLAGS_NVREPLACE: if (item->ri_total != 3 && item->ri_total != 4) { @@ -804,6 +821,8 @@ xlog_recover_attri_commit_pass2( attri_formatp, len); return -EFSCORRUPTED; } + name_len = attri_formatp->alfi_oldname_len; + newname_len = attri_formatp->alfi_newname_len; break; default: XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, @@ -813,15 +832,14 @@ xlog_recover_attri_commit_pass2( i++; /* Validate the attr name */ - if (item->ri_buf[i].i_len != - xlog_calc_iovec_len(attri_formatp->alfi_name_len)) { + if (item->ri_buf[i].i_len != xlog_calc_iovec_len(name_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, attri_formatp, len); return -EFSCORRUPTED; } attr_name = item->ri_buf[i].i_addr; - if (!xfs_attr_namecheck(mp, attr_name, attri_formatp->alfi_name_len, + if (!xfs_attr_namecheck(mp, attr_name, name_len, attri_formatp->alfi_attr_filter)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, item->ri_buf[i].i_addr, item->ri_buf[i].i_len); @@ -829,10 +847,9 @@ xlog_recover_attri_commit_pass2( } i++; - if (attri_formatp->alfi_nname_len) { + if (newname_len > 0) { /* Validate the attr nname */ - if (item->ri_buf[i].i_len != - xlog_calc_iovec_len(attri_formatp->alfi_nname_len)) { + if (item->ri_buf[i].i_len != xlog_calc_iovec_len(newname_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, item->ri_buf[i].i_addr, item->ri_buf[i].i_len); @@ -840,8 +857,7 @@ xlog_recover_attri_commit_pass2( } attr_nname = item->ri_buf[i].i_addr; - if (!xfs_attr_namecheck(mp, attr_nname, - attri_formatp->alfi_nname_len, + if (!xfs_attr_namecheck(mp, attr_nname, newname_len, attri_formatp->alfi_attr_filter)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, item->ri_buf[i].i_addr, @@ -868,9 +884,8 @@ xlog_recover_attri_commit_pass2( * name/value buffer to the recovered incore log item and drop our * reference. */ - nv = xfs_attri_log_nameval_alloc(attr_name, - attri_formatp->alfi_name_len, attr_nname, - attri_formatp->alfi_nname_len, attr_value, + nv = xfs_attri_log_nameval_alloc(attr_name, name_len, attr_nname, + newname_len, attr_value, attri_formatp->alfi_value_len); attrip = xfs_attri_init(mp, nv); From patchwork Fri Mar 3 17:12: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: 13159043 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 C8E7CC7EE2D for ; Fri, 3 Mar 2023 17:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbjCCRMH (ORCPT ); Fri, 3 Mar 2023 12:12:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231515AbjCCRMG (ORCPT ); Fri, 3 Mar 2023 12:12:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AF0323C71 for ; Fri, 3 Mar 2023 09:12:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A5DEA615DA for ; Fri, 3 Mar 2023 17:12:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FA4EC433D2; Fri, 3 Mar 2023 17:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863524; bh=VcHsW0sRAlywqvexAzokuDHAOHWQOHcj7RPWVMi+sD4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=qSYtYzGbH8wy0ifKoWHmpmOeUmxfVqZ9y9qkZ7FZeFU6tqIFPQ7M02gWVloAfiDIu slcWjd0iTeU+7ewXlKZvCC/LYT+1h6111KnmC4OHmpFY6yu0hDNeWlTU5eiB4T+mcs qisbqXi0C+JvxtsTArSFAXqT9DretkvWTpWduApXIHyb6Dd+QKBYGU3OBaL3Lu2yQc BXb65kPNFNR9JmM9b7JsP4hf3iTEnT1pUFOnfhEkp69y1JQKO+XzC2Z0L7Wz0E5vCk stYnNOGNUZh1B2YqzoOXqrNeXJMeqnQkV4kUN7OLj7rNP6qX9qm+FcjZoJ9ZYiUe4t G2c0LzVgj5fuw== Subject: [PATCH 08/13] xfs: rename nname to newname From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:12:03 -0800 Message-ID: <167786352351.1543331.16080812326506289061.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Burn a couple of extra bytes to make it clear what this does. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_log_format.h | 2 +- fs/xfs/xfs_attr_item.c | 48 ++++++++++++++++++++-------------------- fs/xfs/xfs_attr_item.h | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index 32035786135b..8b16ae27c2fd 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -117,7 +117,7 @@ struct xfs_unmount_log_format { #define XLOG_REG_TYPE_ATTRD_FORMAT 28 #define XLOG_REG_TYPE_ATTR_NAME 29 #define XLOG_REG_TYPE_ATTR_VALUE 30 -#define XLOG_REG_TYPE_ATTR_NNAME 31 +#define XLOG_REG_TYPE_ATTR_NEWNAME 31 #define XLOG_REG_TYPE_MAX 31 diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 6042ba34f705..83e83aa05f94 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -75,8 +75,8 @@ static inline struct xfs_attri_log_nameval * xfs_attri_log_nameval_alloc( const void *name, unsigned int name_len, - const void *nname, - unsigned int nname_len, + const void *newname, + unsigned int newname_len, const void *value, unsigned int value_len) { @@ -87,25 +87,25 @@ xfs_attri_log_nameval_alloc( * this. But kvmalloc() utterly sucks, so we use our own version. */ nv = xlog_kvmalloc(sizeof(struct xfs_attri_log_nameval) + - name_len + nname_len + value_len); + name_len + newname_len + value_len); nv->name.i_addr = nv + 1; nv->name.i_len = name_len; nv->name.i_type = XLOG_REG_TYPE_ATTR_NAME; memcpy(nv->name.i_addr, name, name_len); - if (nname_len) { - nv->nname.i_addr = nv->name.i_addr + name_len; - nv->nname.i_len = nname_len; - memcpy(nv->nname.i_addr, nname, nname_len); + if (newname_len) { + nv->newname.i_addr = nv->name.i_addr + name_len; + nv->newname.i_len = newname_len; + memcpy(nv->newname.i_addr, newname, newname_len); } else { - nv->nname.i_addr = NULL; - nv->nname.i_len = 0; + nv->newname.i_addr = NULL; + nv->newname.i_len = 0; } - nv->nname.i_type = XLOG_REG_TYPE_ATTR_NNAME; + nv->newname.i_type = XLOG_REG_TYPE_ATTR_NEWNAME; if (value_len) { - nv->value.i_addr = nv->name.i_addr + nname_len + name_len; + nv->value.i_addr = nv->name.i_addr + newname_len + name_len; nv->value.i_len = value_len; memcpy(nv->value.i_addr, value, value_len); } else { @@ -159,9 +159,9 @@ xfs_attri_item_size( *nbytes += sizeof(struct xfs_attri_log_format) + xlog_calc_iovec_len(nv->name.i_len); - if (nv->nname.i_len) { + if (nv->newname.i_len) { *nvecs += 1; - *nbytes += xlog_calc_iovec_len(nv->nname.i_len); + *nbytes += xlog_calc_iovec_len(nv->newname.i_len); } if (nv->value.i_len) { @@ -197,7 +197,7 @@ xfs_attri_item_format( ASSERT(nv->name.i_len > 0); attrip->attri_format.alfi_size++; - if (nv->nname.i_len > 0) + if (nv->newname.i_len > 0) attrip->attri_format.alfi_size++; if (nv->value.i_len > 0) @@ -208,8 +208,8 @@ xfs_attri_item_format( sizeof(struct xfs_attri_log_format)); xlog_copy_from_iovec(lv, &vecp, &nv->name); - if (nv->nname.i_len > 0) - xlog_copy_from_iovec(lv, &vecp, &nv->nname); + if (nv->newname.i_len > 0) + xlog_copy_from_iovec(lv, &vecp, &nv->newname); if (nv->value.i_len > 0) xlog_copy_from_iovec(lv, &vecp, &nv->value); @@ -405,7 +405,7 @@ xfs_attr_log_item( if (xfs_attr_log_item_op(attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { attrp->alfi_oldname_len = attr->xattri_nameval->name.i_len; - attrp->alfi_newname_len = attr->xattri_nameval->nname.i_len; + attrp->alfi_newname_len = attr->xattri_nameval->newname.i_len; } else { attrp->alfi_name_len = attr->xattri_nameval->name.i_len; } @@ -638,8 +638,8 @@ xfs_attri_item_recover( args->whichfork = XFS_ATTR_FORK; args->name = nv->name.i_addr; args->namelen = nv->name.i_len; - args->new_name = nv->nname.i_addr; - args->new_namelen = nv->nname.i_len; + args->new_name = nv->newname.i_addr; + args->new_namelen = nv->newname.i_len; args->hashval = xfs_da_hashname(args->name, args->namelen); args->attr_filter = attrp->alfi_attr_filter & XFS_ATTRI_FILTER_MASK; args->op_flags = XFS_DA_OP_RECOVERY | XFS_DA_OP_OKNOENT | @@ -775,7 +775,7 @@ xlog_recover_attri_commit_pass2( const void *attr_value = NULL; const void *attr_name; size_t len; - const void *attr_nname = NULL; + const void *attr_newname = NULL; unsigned int name_len = 0, newname_len = 0; int op, i = 0; @@ -848,7 +848,7 @@ xlog_recover_attri_commit_pass2( i++; if (newname_len > 0) { - /* Validate the attr nname */ + /* Validate the attr newname */ if (item->ri_buf[i].i_len != xlog_calc_iovec_len(newname_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, item->ri_buf[i].i_addr, @@ -856,8 +856,8 @@ xlog_recover_attri_commit_pass2( return -EFSCORRUPTED; } - attr_nname = item->ri_buf[i].i_addr; - if (!xfs_attr_namecheck(mp, attr_nname, newname_len, + attr_newname = item->ri_buf[i].i_addr; + if (!xfs_attr_namecheck(mp, attr_newname, newname_len, attri_formatp->alfi_attr_filter)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, item->ri_buf[i].i_addr, @@ -884,7 +884,7 @@ xlog_recover_attri_commit_pass2( * name/value buffer to the recovered incore log item and drop our * reference. */ - nv = xfs_attri_log_nameval_alloc(attr_name, name_len, attr_nname, + nv = xfs_attri_log_nameval_alloc(attr_name, name_len, attr_newname, newname_len, attr_value, attri_formatp->alfi_value_len); diff --git a/fs/xfs/xfs_attr_item.h b/fs/xfs/xfs_attr_item.h index 24d4968dd6cc..e374712ba06b 100644 --- a/fs/xfs/xfs_attr_item.h +++ b/fs/xfs/xfs_attr_item.h @@ -13,7 +13,7 @@ struct kmem_zone; struct xfs_attri_log_nameval { struct xfs_log_iovec name; - struct xfs_log_iovec nname; + struct xfs_log_iovec newname; struct xfs_log_iovec value; refcount_t refcount; From patchwork Fri Mar 3 17:12:09 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: 13159044 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 CA944C7EE2D for ; Fri, 3 Mar 2023 17:12:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231514AbjCCRMZ (ORCPT ); Fri, 3 Mar 2023 12:12:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231202AbjCCRMZ (ORCPT ); Fri, 3 Mar 2023 12:12:25 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9153130EB9 for ; Fri, 3 Mar 2023 09:12:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0764DB8191E for ; Fri, 3 Mar 2023 17:12:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3158C433D2; Fri, 3 Mar 2023 17:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863529; bh=hdXbtNyhTki/Q/3JZtvqohwmVFXl8UFL0szbD+fA0WQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Rri0zgtwXsUldC6gK8eH2daPJWc8swvoykUdGRCVZvAhGVCxTKKnikKzZWgjW2aR0 4GRZhsWWfghsAQGGN3lUcMm5z12KFMWKXvKBJmdmyZRErd4ymUxVIAJeymnus2EsRV 7MbVrNrfupbRtPxP5TKKNwPFqxKKmSjDIax/InBIVBoACv5w+5okro8RvduLkwichh S9ZWMfdXt+dhblzzsFG2pmGf4XWlC5yuO/tIbuWUHZPCred373K2qnaC2+oo4QgnvM E7S4pcRgrkcgy3OWs+LXEuzbKo3a8PKFaBNaZ5WyfVhQHwZ+HquQjgrppO/dmb2t+Z R4GFFWe8WCYYA== Subject: [PATCH 09/13] xfs: log VLOOKUP xattr nvreplace operations From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:12:09 -0800 Message-ID: <167786352923.1543331.16240053109176341528.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong If high level code wants to do a deferred xattr nvreplace operation with the VLOOKUP flag set, we need to push this through the log. To avoid breaking the parent pointer code, we'll temporarily create a new NVREPLACEXXX flag that connects to the VLOOKUP flag. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 15 +++++++++++---- fs/xfs/libxfs/xfs_log_format.h | 1 + fs/xfs/xfs_attr_item.c | 13 +++++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index ba8ad232b306..b9178c4efdeb 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -424,7 +424,12 @@ xfs_attr_complete_op( args->op_flags &= ~XFS_DA_OP_REPLACE; if (do_replace) { args->attr_filter &= ~XFS_ATTR_INCOMPLETE; - if (args->new_namelen > 0) { + if (args->op_flags & XFS_DA_OP_VLOOKUP) { + args->name = args->new_name; + args->namelen = args->new_namelen; + args->hashval = xfs_da_hashname(args->name, + args->namelen); + } else if (args->new_namelen > 0) { args->name = args->new_name; args->namelen = args->new_namelen; args->hashval = xfs_da_hashname(args->name, @@ -933,11 +938,13 @@ xfs_attr_defer_replace( struct xfs_da_args *args) { struct xfs_attr_intent *new; - int op_flag; + int op_flag = XFS_ATTRI_OP_FLAGS_REPLACE; int error = 0; - op_flag = args->new_namelen == 0 ? XFS_ATTRI_OP_FLAGS_REPLACE : - XFS_ATTRI_OP_FLAGS_NVREPLACE; + if (args->op_flags & XFS_DA_OP_VLOOKUP) + op_flag = XFS_ATTRI_OP_FLAGS_NVREPLACEXXX; + else if (args->new_namelen > 0) + op_flag = XFS_ATTRI_OP_FLAGS_NVREPLACE; error = xfs_attr_intent_init(args, op_flag, &new); if (error) diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index 8b16ae27c2fd..a1581dc6f131 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -961,6 +961,7 @@ struct xfs_icreate_log { #define XFS_ATTRI_OP_FLAGS_NVREPLACE 4 /* Replace attr name and val */ #define XFS_ATTRI_OP_FLAGS_NVREMOVE 5 /* Remove attr w/ vlookup */ #define XFS_ATTRI_OP_FLAGS_NVSET 6 /* Set attr with w/ vlookup */ +#define XFS_ATTRI_OP_FLAGS_NVREPLACEXXX 7 /* Replace attr name and val */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 83e83aa05f94..0dd49c5f235a 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -403,7 +403,10 @@ xfs_attr_log_item( attrp->alfi_op_flags = attr->xattri_op_flags; attrp->alfi_value_len = attr->xattri_nameval->value.i_len; - if (xfs_attr_log_item_op(attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { + if (xfs_attr_log_item_op(attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACEXXX) { + attrp->alfi_oldname_len = attr->xattri_nameval->name.i_len; + attrp->alfi_newname_len = attr->xattri_nameval->newname.i_len; + } else if (xfs_attr_log_item_op(attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { attrp->alfi_oldname_len = attr->xattri_nameval->name.i_len; attrp->alfi_newname_len = attr->xattri_nameval->newname.i_len; } else { @@ -564,6 +567,7 @@ xfs_attri_validate( if (attrp->alfi_value_len > XATTR_SIZE_MAX) return false; break; + case XFS_ATTRI_OP_FLAGS_NVREPLACEXXX: case XFS_ATTRI_OP_FLAGS_NVREPLACE: if (attrp->alfi_oldname_len == 0 || attrp->alfi_oldname_len > XATTR_NAME_MAX) @@ -649,6 +653,7 @@ xfs_attri_item_recover( switch (attr->xattri_op_flags) { case XFS_ATTRI_OP_FLAGS_NVSET: + case XFS_ATTRI_OP_FLAGS_NVREPLACEXXX: args->op_flags |= XFS_DA_OP_VLOOKUP; fallthrough; case XFS_ATTRI_OP_FLAGS_SET: @@ -747,7 +752,10 @@ xfs_attri_item_relog( new_attrp->alfi_ino = old_attrp->alfi_ino; new_attrp->alfi_op_flags = old_attrp->alfi_op_flags; new_attrp->alfi_value_len = old_attrp->alfi_value_len; - if (xfs_attr_log_item_op(old_attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { + if (xfs_attr_log_item_op(old_attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACEXXX) { + new_attrp->alfi_newname_len = old_attrp->alfi_newname_len; + new_attrp->alfi_oldname_len = old_attrp->alfi_oldname_len; + } else if (xfs_attr_log_item_op(old_attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { new_attrp->alfi_newname_len = old_attrp->alfi_newname_len; new_attrp->alfi_oldname_len = old_attrp->alfi_oldname_len; } else { @@ -815,6 +823,7 @@ xlog_recover_attri_commit_pass2( } name_len = attri_formatp->alfi_name_len; break; + case XFS_ATTRI_OP_FLAGS_NVREPLACEXXX: case XFS_ATTRI_OP_FLAGS_NVREPLACE: if (item->ri_total != 3 && item->ri_total != 4) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, From patchwork Fri Mar 3 17:12: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: 13159045 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 76C0CC7EE2F for ; Fri, 3 Mar 2023 17:12:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231523AbjCCRM3 (ORCPT ); Fri, 3 Mar 2023 12:12:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbjCCRM2 (ORCPT ); Fri, 3 Mar 2023 12:12:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEF792DE55 for ; Fri, 3 Mar 2023 09:12:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9BAEDB8191F for ; Fri, 3 Mar 2023 17:12:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54F9BC433D2; Fri, 3 Mar 2023 17:12:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863535; bh=lsNdcMBG80ShdVkJ+qHiu1JG8vhkxpYd5Ooadbw1mkc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=pcNoZ9BDBlTTjIlNKRPgfGKrJIAjYKpZd7ivuhAJZI6L1iOTq9JNkq74ACYa7Mwy5 NBIim9EH84eTnNIjgO3H/jAbknHxut++2pBNPftH1T/ABBmWcUG/U+Z1lqcYazdlxk nJE6n7yzfTJwWIT0YP1W8VSuVNNFMzrnkl180pQ/0s7cUP9+rfJ2qIy+rjLNK5jQFn gXJJOGBI9X1OSfkqBunBpBKTytQMU77xGDTKLo9k9Co0fQYhN8XIZ3Eqi5sfYUi7KU T5BuR8uWIOget3VzoHwQxkaQhmXAHu7PeC/2QZ/OAmjgg0opCpNWmN6G6rs+Z/OFbC 1LewCFz7GAMqw== Subject: [PATCH 10/13] xfs: log old xattr values for NVREPLACEXXX operations From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:12:14 -0800 Message-ID: <167786353490.1543331.6210511448533901672.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong For NVREPLACEXXX operations, make it possible to log the old and new attr values, since this variant does VLOOKUP operations. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 2 + fs/xfs/libxfs/xfs_da_btree.h | 2 + fs/xfs/libxfs/xfs_log_format.h | 14 +++++--- fs/xfs/xfs_attr_item.c | 74 +++++++++++++++++++++++++++++++++++----- fs/xfs/xfs_attr_item.h | 3 +- 5 files changed, 80 insertions(+), 15 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index b9178c4efdeb..d807692b259c 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -429,6 +429,8 @@ xfs_attr_complete_op( args->namelen = args->new_namelen; args->hashval = xfs_da_hashname(args->name, args->namelen); + args->value = args->new_value; + args->valuelen = args->new_valuelen; } else if (args->new_namelen > 0) { args->name = args->new_name; args->namelen = args->new_namelen; diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index 0ef32f629e1b..cbea5233159c 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -60,7 +60,9 @@ typedef struct xfs_da_args { 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 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/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index a1581dc6f131..ed406738847d 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -115,11 +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_ATTR_NEWNAME 31 -#define XLOG_REG_TYPE_MAX 31 - +#define XLOG_REG_TYPE_ATTR_NEWVALUE 32 +#define XLOG_REG_TYPE_MAX 32 /* * Flags to log operation header @@ -980,7 +980,13 @@ 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_newvalue_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 */ diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 0dd49c5f235a..57cc426b1e22 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -78,7 +78,9 @@ xfs_attri_log_nameval_alloc( const void *newname, unsigned int newname_len, const void *value, - unsigned int value_len) + unsigned int value_len, + const void *newvalue, + unsigned int newvalue_len) { struct xfs_attri_log_nameval *nv; @@ -87,7 +89,8 @@ xfs_attri_log_nameval_alloc( * this. But kvmalloc() utterly sucks, so we use our own version. */ nv = xlog_kvmalloc(sizeof(struct xfs_attri_log_nameval) + - name_len + newname_len + value_len); + name_len + newname_len + value_len + + newvalue_len); nv->name.i_addr = nv + 1; nv->name.i_len = name_len; @@ -114,6 +117,17 @@ xfs_attri_log_nameval_alloc( } nv->value.i_type = XLOG_REG_TYPE_ATTR_VALUE; + if (newvalue_len) { + nv->newvalue.i_addr = nv->name.i_addr + newname_len + + name_len + value_len; + nv->newvalue.i_len = newvalue_len; + memcpy(nv->newvalue.i_addr, newvalue, newvalue_len); + } else { + nv->newvalue.i_addr = NULL; + nv->newvalue.i_len = 0; + } + nv->newvalue.i_type = XLOG_REG_TYPE_ATTR_NEWVALUE; + refcount_set(&nv->refcount, 1); return nv; } @@ -168,6 +182,11 @@ xfs_attri_item_size( *nvecs += 1; *nbytes += xlog_calc_iovec_len(nv->value.i_len); } + + if (nv->newvalue.i_len) { + *nvecs += 1; + *nbytes += xlog_calc_iovec_len(nv->newvalue.i_len); + } } /* @@ -203,6 +222,9 @@ xfs_attri_item_format( if (nv->value.i_len > 0) attrip->attri_format.alfi_size++; + if (nv->newvalue.i_len > 0) + attrip->attri_format.alfi_size++; + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRI_FORMAT, &attrip->attri_format, sizeof(struct xfs_attri_log_format)); @@ -213,6 +235,9 @@ xfs_attri_item_format( if (nv->value.i_len > 0) xlog_copy_from_iovec(lv, &vecp, &nv->value); + + if (nv->newvalue.i_len > 0) + xlog_copy_from_iovec(lv, &vecp, &nv->newvalue); } /* @@ -406,6 +431,7 @@ xfs_attr_log_item( if (xfs_attr_log_item_op(attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACEXXX) { attrp->alfi_oldname_len = attr->xattri_nameval->name.i_len; attrp->alfi_newname_len = attr->xattri_nameval->newname.i_len; + attrp->alfi_newvalue_len = attr->xattri_nameval->newvalue.i_len; } else if (xfs_attr_log_item_op(attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { attrp->alfi_oldname_len = attr->xattri_nameval->name.i_len; attrp->alfi_newname_len = attr->xattri_nameval->newname.i_len; @@ -455,7 +481,8 @@ xfs_attr_create_intent( */ attr->xattri_nameval = xfs_attri_log_nameval_alloc(args->name, args->namelen, args->new_name, - args->new_namelen, args->value, args->valuelen); + args->new_namelen, args->value, args->valuelen, + args->new_value, args->new_valuelen); } attrip = xfs_attri_init(mp, attr->xattri_nameval); @@ -556,6 +583,8 @@ xfs_attri_validate( if (attrp->alfi_name_len == 0 || attrp->alfi_name_len > XATTR_NAME_MAX) return false; + if (attrp->alfi_newvalue_len != 0) + return false; break; case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: @@ -566,6 +595,8 @@ xfs_attri_validate( return false; if (attrp->alfi_value_len > XATTR_SIZE_MAX) return false; + if (attrp->alfi_newvalue_len != 0) + return false; break; case XFS_ATTRI_OP_FLAGS_NVREPLACEXXX: case XFS_ATTRI_OP_FLAGS_NVREPLACE: @@ -577,6 +608,8 @@ xfs_attri_validate( return false; if (attrp->alfi_value_len > XATTR_SIZE_MAX) return false; + if (attrp->alfi_newvalue_len > XATTR_SIZE_MAX) + return false; break; default: return false; @@ -652,8 +685,11 @@ xfs_attri_item_recover( ASSERT(xfs_sb_version_haslogxattrs(&mp->m_sb)); switch (attr->xattri_op_flags) { - case XFS_ATTRI_OP_FLAGS_NVSET: case XFS_ATTRI_OP_FLAGS_NVREPLACEXXX: + args->new_value = nv->newvalue.i_addr; + args->new_valuelen = nv->newvalue.i_len; + fallthrough; + case XFS_ATTRI_OP_FLAGS_NVSET: args->op_flags |= XFS_DA_OP_VLOOKUP; fallthrough; case XFS_ATTRI_OP_FLAGS_SET: @@ -755,6 +791,7 @@ xfs_attri_item_relog( if (xfs_attr_log_item_op(old_attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACEXXX) { new_attrp->alfi_newname_len = old_attrp->alfi_newname_len; new_attrp->alfi_oldname_len = old_attrp->alfi_oldname_len; + new_attrp->alfi_newvalue_len = old_attrp->alfi_newvalue_len; } else if (xfs_attr_log_item_op(old_attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { new_attrp->alfi_newname_len = old_attrp->alfi_newname_len; new_attrp->alfi_oldname_len = old_attrp->alfi_oldname_len; @@ -781,10 +818,12 @@ xlog_recover_attri_commit_pass2( struct xfs_attri_log_format *attri_formatp; struct xfs_attri_log_nameval *nv; const void *attr_value = NULL; + const void *attr_newvalue = NULL; const void *attr_name; size_t len; const void *attr_newname = NULL; unsigned int name_len = 0, newname_len = 0; + unsigned int value_len = 0, newvalue_len = 0; int op, i = 0; /* Validate xfs_attri_log_format before the large memory allocation */ @@ -814,6 +853,7 @@ xlog_recover_attri_commit_pass2( return -EFSCORRUPTED; } name_len = attri_formatp->alfi_name_len; + value_len = attri_formatp->alfi_value_len; break; case XFS_ATTRI_OP_FLAGS_REMOVE: if (item->ri_total != 2) { @@ -822,16 +862,19 @@ xlog_recover_attri_commit_pass2( return -EFSCORRUPTED; } name_len = attri_formatp->alfi_name_len; + value_len = attri_formatp->alfi_value_len; break; case XFS_ATTRI_OP_FLAGS_NVREPLACEXXX: case XFS_ATTRI_OP_FLAGS_NVREPLACE: - if (item->ri_total != 3 && item->ri_total != 4) { + if (item->ri_total < 3 || item->ri_total > 5) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, attri_formatp, len); return -EFSCORRUPTED; } name_len = attri_formatp->alfi_oldname_len; newname_len = attri_formatp->alfi_newname_len; + value_len = attri_formatp->alfi_value_len; + newvalue_len = attri_formatp->alfi_newvalue_len; break; default: XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, @@ -876,16 +919,27 @@ xlog_recover_attri_commit_pass2( i++; } - /* Validate the attr value, if present */ - if (attri_formatp->alfi_value_len != 0) { - if (item->ri_buf[i].i_len != xlog_calc_iovec_len(attri_formatp->alfi_value_len)) { + if (value_len > 0) { + if (item->ri_buf[i].i_len != xlog_calc_iovec_len(value_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, attri_formatp, len); return -EFSCORRUPTED; } attr_value = item->ri_buf[i].i_addr; + i++; + } + + /* Validate the old attr value, if present */ + if (newvalue_len > 0) { + if (item->ri_buf[i].i_len != xlog_calc_iovec_len(newvalue_len)) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + + attr_newvalue = item->ri_buf[i].i_addr; } /* @@ -894,8 +948,8 @@ xlog_recover_attri_commit_pass2( * reference. */ nv = xfs_attri_log_nameval_alloc(attr_name, name_len, attr_newname, - newname_len, attr_value, - attri_formatp->alfi_value_len); + newname_len, attr_value, attri_formatp->alfi_value_len, + attr_newvalue, newvalue_len); attrip = xfs_attri_init(mp, nv); memcpy(&attrip->attri_format, attri_formatp, len); diff --git a/fs/xfs/xfs_attr_item.h b/fs/xfs/xfs_attr_item.h index e374712ba06b..d15fe4b1ce28 100644 --- a/fs/xfs/xfs_attr_item.h +++ b/fs/xfs/xfs_attr_item.h @@ -13,8 +13,9 @@ struct kmem_zone; struct xfs_attri_log_nameval { struct xfs_log_iovec name; - struct xfs_log_iovec newname; + struct xfs_log_iovec newname; /* NVREPLACE only */ struct xfs_log_iovec value; + struct xfs_log_iovec newvalue; /* NVREPLACE only */ refcount_t refcount; /* name and value follow the end of this struct */ From patchwork Fri Mar 3 17:12:20 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: 13159046 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 14D4FC7EE2D for ; Fri, 3 Mar 2023 17:12:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231202AbjCCRMd (ORCPT ); Fri, 3 Mar 2023 12:12:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231515AbjCCRMc (ORCPT ); Fri, 3 Mar 2023 12:12:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0AC630285 for ; Fri, 3 Mar 2023 09:12:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3C4DFB81992 for ; Fri, 3 Mar 2023 17:12:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9C7CC433D2; Fri, 3 Mar 2023 17:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863541; bh=YPf5vIXwMTWiRgfkV6w1FNaxOyyhR3eR/hj/qxkhZg0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=jLMVWiW3p0QWii9LSvw3OHUR2RpWvAIL/itqdrOtU8kdEmTY1rPRLeDdFL058SD9i rICFFZSQ0uGbbkQkapRsgIUjK/HTmXivI2uVfYjUvGinZr+FaZg3XFIFUMxl4Sbkh/ EGg+z9yNBddP9c+lbmVJOR1/yTvlfVesdZiFANritNCRd8EZt2jsds0oN8q3UNaj2S dJE/+X/yov7Cif8LP97W47r3bWLWT4h4AMysfY7Pr+gVVamblUUNslLwrn5GlCBiUN 8UQ2lkZLdj78rutyb5PC1XnRpc9OqKNrQ4x4ZE77m1k2dD0YVVyI/4wTUjwfQ7iaXM AJ/dhxsJ/RQig== Subject: [PATCH 11/13] xfs: use VLOOKUP mode to avoid hashing parent pointer names From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:12:20 -0800 Message-ID: <167786354052.1543331.13941648758151757902.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Hashing the parent pointer name is fugly because no hashing function can be collision proof. Since we store as much of the dirent name as we can in the xattr name and spill the rest to the xattr value, use VLOOKUP mode so that we can match on name and value. Then we can get rid of the hashing stuff. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_da_format.h | 34 ++-- fs/xfs/libxfs/xfs_parent.c | 303 +++++++++++++--------------------------- fs/xfs/libxfs/xfs_parent.h | 16 -- fs/xfs/libxfs/xfs_trans_resv.c | 1 fs/xfs/scrub/dir.c | 38 +---- fs/xfs/scrub/parent.c | 61 +------- fs/xfs/scrub/parent_repair.c | 34 +--- fs/xfs/xfs_ondisk.h | 3 8 files changed, 136 insertions(+), 354 deletions(-) diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index 55f510f82e8d..dd569286b3be 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -824,22 +824,12 @@ static inline unsigned int xfs_dir2_dirblock_bytes(struct xfs_sb *sbp) xfs_failaddr_t xfs_da3_blkinfo_verify(struct xfs_buf *bp, struct xfs_da3_blkinfo *hdr3); -/* We use sha512 for the parent pointer name hash. */ -#define XFS_PARENT_NAME_SHA512_SIZE (64) - /* * Parent pointer attribute format definition * - * The EA name encodes the parent inode number, generation and a collision - * resistant hash computed from the dirent name. The hash is defined to be - * one of the following: - * - * - The dirent name, as long as it does not use the last possible byte of the - * EA name space. - * - * - The truncated dirent name, with the sha512 hash of the child inode - * generation number and dirent name. The hash is written at the end of the - * EA name. + * The EA name encodes the parent inode number, generation and as much of the + * dirent name as fits. In other words, it contains up to 243 bytes of the + * dirent name. * * The EA value contains however much of the dirent name that does not fit in * the EA name. @@ -847,30 +837,30 @@ xfs_failaddr_t xfs_da3_blkinfo_verify(struct xfs_buf *bp, struct xfs_parent_name_rec { __be64 p_ino; __be32 p_gen; - __u8 p_namehash[]; + __u8 p_dname[]; } __attribute__((packed)); /* Maximum size of a parent pointer EA name. */ #define XFS_PARENT_NAME_MAX_SIZE \ (MAXNAMELEN - 1) -/* Maximum size of a parent pointer name hash. */ -#define XFS_PARENT_NAME_MAX_HASH_SIZE \ +/* Maximum number of dirent name bytes stored in p_dname. */ +#define XFS_PARENT_MAX_DNAME_SIZE \ (XFS_PARENT_NAME_MAX_SIZE - sizeof(struct xfs_parent_name_rec)) -/* Offset of the sha512 hash, if used. */ -#define XFS_PARENT_NAME_SHA512_OFFSET \ - (XFS_PARENT_NAME_MAX_HASH_SIZE - XFS_PARENT_NAME_SHA512_SIZE) +/* Maximum number of dirent name bytes stored in the xattr value. */ +#define XFS_PARENT_MAX_DNAME_VALUELEN \ + sizeof(struct xfs_parent_name_rec) static inline unsigned int xfs_parent_name_rec_sizeof( - unsigned int hashlen) + unsigned int dnamelen) { - return sizeof(struct xfs_parent_name_rec) + hashlen; + return sizeof(struct xfs_parent_name_rec) + dnamelen; } static inline unsigned int -xfs_parent_name_hashlen( +xfs_parent_name_dnamelen( unsigned int rec_sizeof) { return rec_sizeof - sizeof(struct xfs_parent_name_rec); diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c index 387f3c65287f..af412ebe65a4 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -26,7 +26,6 @@ #include "xfs_xattr.h" #include "xfs_parent.h" #include "xfs_trans_space.h" -#include "xfs_sha512.h" struct kmem_cache *xfs_parent_intent_cache; @@ -56,8 +55,11 @@ xfs_parent_namecheck( { xfs_ino_t p_ino; - if (reclen <= xfs_parent_name_rec_sizeof(0) || - reclen > xfs_parent_name_rec_sizeof(XFS_PARENT_NAME_MAX_HASH_SIZE)) + if (!(attr_flags & XFS_ATTR_PARENT)) + return false; + + if (reclen <= sizeof(struct xfs_parent_name_rec) || + reclen > XFS_PARENT_NAME_MAX_SIZE) return false; /* Only one namespace bit allowed. */ @@ -86,7 +88,7 @@ xfs_parent_valuecheck( return false; if (namelen == XFS_PARENT_NAME_MAX_SIZE && - valuelen >= MAXNAMELEN - XFS_PARENT_NAME_SHA512_OFFSET) + valuelen > XFS_PARENT_MAX_DNAME_VALUELEN) return false; if (value == NULL) @@ -95,7 +97,10 @@ xfs_parent_valuecheck( return true; } -/* Initializes a xfs_parent_name_rec to be stored as an attribute name */ +/* + * Initializes a xfs_parent_name_rec to be stored as an attribute name. + * Returns the number of name bytes stored in p_dname. + */ static inline int xfs_init_parent_name_rec( struct xfs_parent_name_rec *rec, @@ -103,23 +108,14 @@ xfs_init_parent_name_rec( const struct xfs_name *name, struct xfs_inode *ip) { + int dnamelen; + rec->p_ino = cpu_to_be64(dp->i_ino); rec->p_gen = cpu_to_be32(VFS_IC(dp)->i_generation); - return xfs_parent_namehash(ip, name, rec->p_namehash, - XFS_PARENT_NAME_MAX_HASH_SIZE); -} -/* Compute the number of name bytes that can be encoded in the namehash. */ -static inline unsigned int -xfs_parent_valuelen_adj( - int hashlen) -{ - ASSERT(hashlen > 0); - - if (hashlen == XFS_PARENT_NAME_MAX_HASH_SIZE) - return XFS_PARENT_NAME_SHA512_OFFSET; - - return hashlen; + dnamelen = min_t(int, name->len, XFS_PARENT_MAX_DNAME_SIZE); + memcpy(rec->p_dname, name->name, dnamelen); + return dnamelen; } /* @@ -134,48 +130,30 @@ xfs_parent_irec_from_disk( const void *value, int valuelen) { + int dnamelen; + irec->p_ino = be64_to_cpu(rec->p_ino); irec->p_gen = be32_to_cpu(rec->p_gen); - irec->hashlen = xfs_parent_name_hashlen(reclen); - memcpy(irec->p_namehash, rec->p_namehash, irec->hashlen); - memset(irec->p_namehash + irec->hashlen, 0, - sizeof(irec->p_namehash) - irec->hashlen); if (!value) { irec->p_namelen = 0; return; } - ASSERT(valuelen < MAXNAMELEN); + ASSERT(valuelen <= XFS_PARENT_MAX_DNAME_VALUELEN); - if (irec->hashlen == XFS_PARENT_NAME_MAX_HASH_SIZE) { - ASSERT(valuelen > 0); - ASSERT(valuelen <= MAXNAMELEN - XFS_PARENT_NAME_SHA512_OFFSET); - - valuelen = min_t(int, valuelen, - MAXNAMELEN - XFS_PARENT_NAME_SHA512_OFFSET); - - memcpy(irec->p_name, irec->p_namehash, - XFS_PARENT_NAME_SHA512_OFFSET); - memcpy(&irec->p_name[XFS_PARENT_NAME_SHA512_OFFSET], - value, valuelen); - irec->p_namelen = XFS_PARENT_NAME_SHA512_OFFSET + valuelen; - } else { - ASSERT(valuelen == 0); - - memcpy(irec->p_name, irec->p_namehash, irec->hashlen); - irec->p_namelen = irec->hashlen; - } - - memset(&irec->p_name[irec->p_namelen], 0, - sizeof(irec->p_name) - irec->p_namelen); + dnamelen = xfs_parent_name_dnamelen(reclen); + irec->p_namelen = dnamelen + valuelen; + memcpy(irec->p_name, rec->p_dname, dnamelen); + if (valuelen > 0) + memcpy(irec->p_name + dnamelen, value, valuelen); } /* - * Convert an incore parent_name record to its ondisk format. If @value or - * @valuelen are NULL, they will not be written to. + * Convert an incore parent_name record to its ondisk format. If @valuelen is + * NULL, neither it nor @value will be written to. */ -void +int xfs_parent_irec_to_disk( struct xfs_parent_name_rec *rec, int *reclen, @@ -183,25 +161,23 @@ xfs_parent_irec_to_disk( int *valuelen, const struct xfs_parent_name_irec *irec) { + int dnamelen; + rec->p_ino = cpu_to_be64(irec->p_ino); rec->p_gen = cpu_to_be32(irec->p_gen); - *reclen = xfs_parent_name_rec_sizeof(irec->hashlen); - memcpy(rec->p_namehash, irec->p_namehash, irec->hashlen); + dnamelen = min_t(int, irec->p_namelen, XFS_PARENT_MAX_DNAME_SIZE); + *reclen = xfs_parent_name_rec_sizeof(dnamelen); + memcpy(rec->p_dname, irec->p_name, dnamelen); - if (valuelen) { - ASSERT(*valuelen > 0); - ASSERT(*valuelen >= irec->p_namelen); - ASSERT(*valuelen < MAXNAMELEN); + if (!valuelen) + return dnamelen; - if (irec->hashlen == XFS_PARENT_NAME_MAX_HASH_SIZE) - *valuelen = irec->p_namelen - XFS_PARENT_NAME_SHA512_OFFSET; - else - *valuelen = 0; - } + *valuelen = irec->p_namelen - dnamelen; + if (*valuelen) + memcpy(value, rec->p_dname + XFS_PARENT_MAX_DNAME_SIZE, + *valuelen); - if (value && irec->hashlen == XFS_PARENT_NAME_MAX_HASH_SIZE) - memcpy(value, irec->p_name + XFS_PARENT_NAME_SHA512_OFFSET, - irec->p_namelen - XFS_PARENT_NAME_SHA512_OFFSET); + return dnamelen; } /* @@ -235,7 +211,8 @@ __xfs_parent_init( parent->args.geo = mp->m_attr_geo; parent->args.whichfork = XFS_ATTR_FORK; parent->args.attr_filter = XFS_ATTR_PARENT; - parent->args.op_flags = XFS_DA_OP_OKNOENT | XFS_DA_OP_LOGGED; + parent->args.op_flags = XFS_DA_OP_OKNOENT | XFS_DA_OP_LOGGED | + XFS_DA_OP_VLOOKUP; parent->args.name = (const uint8_t *)&parent->rec; parent->args.namelen = 0; @@ -253,25 +230,22 @@ xfs_parent_add( struct xfs_inode *child) { struct xfs_da_args *args = &parent->args; - int hashlen; - unsigned int name_adj; + int dnamelen; - hashlen = xfs_init_parent_name_rec(&parent->rec, dp, parent_name, + dnamelen = xfs_init_parent_name_rec(&parent->rec, dp, parent_name, child); - if (hashlen < 0) - return hashlen; - args->namelen = xfs_parent_name_rec_sizeof(hashlen); + args->namelen = xfs_parent_name_rec_sizeof(dnamelen); args->hashval = xfs_da_hashname(args->name, args->namelen); - name_adj = xfs_parent_valuelen_adj(hashlen); - args->trans = tp; args->dp = child; - if (parent_name) { - parent->args.value = (void *)parent_name->name + name_adj; - parent->args.valuelen = parent_name->len - name_adj; - } + + parent->args.valuelen = parent_name->len - dnamelen; + if (parent->args.valuelen > 0) + parent->args.value = (void *)parent_name->name + dnamelen; + else + parent->args.value = NULL; return xfs_attr_defer_add(args); } @@ -286,16 +260,21 @@ xfs_parent_remove( struct xfs_inode *child) { struct xfs_da_args *args = &parent->args; - int hashlen; + int dnamelen; - hashlen = xfs_init_parent_name_rec(&parent->rec, dp, name, child); - if (hashlen < 0) - return hashlen; + dnamelen = xfs_init_parent_name_rec(&parent->rec, dp, name, child); - args->namelen = xfs_parent_name_rec_sizeof(hashlen); + args->namelen = xfs_parent_name_rec_sizeof(dnamelen); args->trans = tp; args->dp = child; args->hashval = xfs_da_hashname(args->name, args->namelen); + + parent->args.valuelen = name->len - dnamelen; + if (parent->args.valuelen > 0) + parent->args.value = (void *)name->name + dnamelen; + else + parent->args.value = NULL; + return xfs_attr_defer_remove(args); } @@ -311,29 +290,31 @@ xfs_parent_replace( struct xfs_inode *child) { struct xfs_da_args *args = &new_parent->args; - int old_hashlen, new_hashlen; - int new_name_adj; + int old_dnamelen, new_dnamelen; - old_hashlen = xfs_init_parent_name_rec(&new_parent->old_rec, old_dp, + old_dnamelen = xfs_init_parent_name_rec(&new_parent->old_rec, old_dp, old_name, child); - if (old_hashlen < 0) - return old_hashlen; - new_hashlen = xfs_init_parent_name_rec(&new_parent->rec, new_dp, + new_dnamelen = xfs_init_parent_name_rec(&new_parent->rec, new_dp, new_name, child); - if (new_hashlen < 0) - return new_hashlen; - - new_name_adj = xfs_parent_valuelen_adj(new_hashlen); new_parent->args.name = (const uint8_t *)&new_parent->old_rec; - new_parent->args.namelen = xfs_parent_name_rec_sizeof(old_hashlen); + new_parent->args.namelen = xfs_parent_name_rec_sizeof(old_dnamelen); new_parent->args.new_name = (const uint8_t *)&new_parent->rec; - new_parent->args.new_namelen = xfs_parent_name_rec_sizeof(new_hashlen); + new_parent->args.new_namelen = xfs_parent_name_rec_sizeof(new_dnamelen); args->trans = tp; args->dp = child; - new_parent->args.value = (void *)new_name->name + new_name_adj; - new_parent->args.valuelen = new_name->len - new_name_adj; + new_parent->args.new_valuelen = new_name->len - new_dnamelen; + if (new_parent->args.new_valuelen > 0) + new_parent->args.new_value = (void *)new_name->name + new_dnamelen; + else + new_parent->args.new_value = NULL; + + new_parent->args.valuelen = old_name->len - old_dnamelen; + if (new_parent->args.valuelen > 0) + new_parent->args.value = (void *)old_name->name + old_dnamelen; + else + new_parent->args.value = NULL; args->hashval = xfs_da_hashname(args->name, args->namelen); return xfs_attr_defer_replace(args); @@ -363,26 +344,22 @@ xfs_pptr_calc_space_res( } /* - * Look up the @name associated with the parent pointer (@pptr) of @ip. Caller - * must hold at least ILOCK_SHARED. Returns the length of the dirent name, or - * a negative errno. The scratchpad need not be initialized. + * Look up the @name associated with the parent pointer (@pptr) of @ip. + * Caller must hold at least ILOCK_SHARED. Returns 0 if the pointer is found, + * -ENOATTR if there is no match, or a negative errno. The scratchpad need not + * be initialized. */ int xfs_parent_lookup( struct xfs_trans *tp, struct xfs_inode *ip, const struct xfs_parent_name_irec *pptr, - unsigned char *name, - unsigned int namelen, struct xfs_parent_scratch *scr) { + int dnamelen; int reclen; - int name_adj; - int error; - xfs_parent_irec_to_disk(&scr->rec, &reclen, NULL, NULL, pptr); - - name_adj = xfs_parent_valuelen_adj(pptr->hashlen); + dnamelen = xfs_parent_irec_to_disk(&scr->rec, &reclen, NULL, NULL, pptr); memset(&scr->args, 0, sizeof(struct xfs_da_args)); scr->args.attr_filter = XFS_ATTR_PARENT; @@ -390,20 +367,17 @@ xfs_parent_lookup( scr->args.geo = ip->i_mount->m_attr_geo; scr->args.name = (const unsigned char *)&scr->rec; scr->args.namelen = reclen; - scr->args.op_flags = XFS_DA_OP_OKNOENT; + scr->args.op_flags = XFS_DA_OP_OKNOENT | XFS_DA_OP_VLOOKUP; scr->args.trans = tp; - scr->args.valuelen = namelen - name_adj; - scr->args.value = name + name_adj; + scr->args.valuelen = pptr->p_namelen - dnamelen; scr->args.whichfork = XFS_ATTR_FORK; + if (scr->args.valuelen) + scr->args.value = (void *)pptr->p_name + dnamelen; + scr->args.hashval = xfs_da_hashname(scr->args.name, scr->args.namelen); - error = xfs_attr_get_ilocked(&scr->args); - if (error) - return error; - - memcpy(name, pptr->p_namehash, name_adj); - return scr->args.valuelen + name_adj; + return xfs_attr_get_ilocked(&scr->args); } /* @@ -418,12 +392,10 @@ xfs_parent_set( const struct xfs_parent_name_irec *pptr, struct xfs_parent_scratch *scr) { + int dnamelen; int reclen; - int name_adj; - xfs_parent_irec_to_disk(&scr->rec, &reclen, NULL, NULL, pptr); - - name_adj = xfs_parent_valuelen_adj(pptr->hashlen); + dnamelen = xfs_parent_irec_to_disk(&scr->rec, &reclen, NULL, NULL, pptr); memset(&scr->args, 0, sizeof(struct xfs_da_args)); scr->args.attr_filter = XFS_ATTR_PARENT; @@ -431,10 +403,13 @@ xfs_parent_set( scr->args.geo = ip->i_mount->m_attr_geo; scr->args.name = (const unsigned char *)&scr->rec; scr->args.namelen = reclen; - scr->args.valuelen = pptr->p_namelen - name_adj; - scr->args.value = (void *)pptr->p_name + name_adj; + scr->args.op_flags = XFS_DA_OP_VLOOKUP; + scr->args.valuelen = pptr->p_namelen - dnamelen; scr->args.whichfork = XFS_ATTR_FORK; + if (scr->args.valuelen) + scr->args.value = (void *)pptr->p_name + dnamelen; + return xfs_attr_set(&scr->args); } @@ -450,9 +425,10 @@ xfs_parent_unset( const struct xfs_parent_name_irec *pptr, struct xfs_parent_scratch *scr) { + int dnamelen; int reclen; - xfs_parent_irec_to_disk(&scr->rec, &reclen, NULL, NULL, pptr); + dnamelen = xfs_parent_irec_to_disk(&scr->rec, &reclen, NULL, NULL, pptr); memset(&scr->args, 0, sizeof(struct xfs_da_args)); scr->args.attr_filter = XFS_ATTR_PARENT; @@ -460,89 +436,12 @@ xfs_parent_unset( scr->args.geo = ip->i_mount->m_attr_geo; scr->args.name = (const unsigned char *)&scr->rec; scr->args.namelen = reclen; - scr->args.op_flags = XFS_DA_OP_REMOVE; + scr->args.op_flags = XFS_DA_OP_REMOVE | XFS_DA_OP_VLOOKUP; + scr->args.valuelen = pptr->p_namelen - dnamelen; scr->args.whichfork = XFS_ATTR_FORK; + if (scr->args.valuelen) + scr->args.value = (void *)pptr->p_name + dnamelen; + return xfs_attr_set(&scr->args); } - -/* - * Compute the parent pointer namehash for the given child file and dirent - * name. Returns the length of the hash in bytes, or a negative errno. - */ -int -xfs_parent_namehash( - struct xfs_inode *ip, - const struct xfs_name *name, - void *namehash, - unsigned int namehash_len) -{ - SHA512_DESC_ON_STACK(ip->i_mount, shash); - __be32 gen = cpu_to_be32(VFS_I(ip)->i_generation); - int error; - - ASSERT(SHA512_DIGEST_SIZE == - crypto_shash_digestsize(ip->i_mount->m_sha512)); - - if (namehash_len != XFS_PARENT_NAME_MAX_HASH_SIZE) { - ASSERT(0); - return -EINVAL; - } - - if (name->len < XFS_PARENT_NAME_MAX_HASH_SIZE) { - /* - * If the dirent name is shorter than the size of the namehash - * field, write it directly into the namehash field. - */ - memcpy(namehash, name->name, name->len); - memset(namehash + name->len, 0, namehash_len - name->len); - return name->len; - } - - error = sha512_init(&shash); - if (error) - goto out; - - error = sha512_process(&shash, (const u8 *)&gen, sizeof(gen)); - if (error) - goto out; - - error = sha512_process(&shash, name->name, name->len); - if (error) - goto out; - - /* - * The sha512 hash of the child gen and dirent name is placed at the - * end of the namehash, and as many bytes as will fit are copied from - * the dirent name to the start of the namehash. - */ - error = sha512_done(&shash, namehash + XFS_PARENT_NAME_SHA512_OFFSET); - if (error) - goto out; - - memcpy(namehash, name->name, XFS_PARENT_NAME_SHA512_OFFSET); - error = XFS_PARENT_NAME_MAX_HASH_SIZE; -out: - sha512_erase(&shash); - return error; -} - -/* Recalculate the name hash of this parent pointer. */ -int -xfs_parent_irec_hash( - struct xfs_inode *ip, - struct xfs_parent_name_irec *pptr) -{ - struct xfs_name xname = { - .name = pptr->p_name, - .len = pptr->p_namelen, - }; - int hashlen; - - hashlen = xfs_parent_namehash(ip, &xname, &pptr->p_namehash, - sizeof(pptr->p_namehash)); - if (hashlen < 0) - return hashlen; - pptr->hashlen = hashlen; - return 0; -} diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index 6f6136165efe..0b3e0b94d6cb 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -23,10 +23,6 @@ struct xfs_parent_name_irec { /* Key fields for looking up a particular parent pointer. */ xfs_ino_t p_ino; uint32_t p_gen; - uint8_t hashlen; - uint8_t p_namehash[XFS_PARENT_NAME_MAX_HASH_SIZE]; - - /* Attributes of a parent pointer. */ uint8_t p_namelen; unsigned char p_name[MAXNAMELEN]; }; @@ -34,7 +30,7 @@ struct xfs_parent_name_irec { void xfs_parent_irec_from_disk(struct xfs_parent_name_irec *irec, const struct xfs_parent_name_rec *rec, int reclen, const void *value, int valuelen); -void xfs_parent_irec_to_disk(struct xfs_parent_name_rec *rec, int *reclen, +int xfs_parent_irec_to_disk(struct xfs_parent_name_rec *rec, int *reclen, void *value, int *valuelen, const struct xfs_parent_name_irec *irec); @@ -107,12 +103,6 @@ xfs_parent_finish( __xfs_parent_cancel(mp, p); } -int xfs_parent_namehash(struct xfs_inode *ip, const struct xfs_name *name, - void *namehash, unsigned int namehash_len); - -int xfs_parent_irec_hash(struct xfs_inode *ip, - struct xfs_parent_name_irec *pptr); - unsigned int xfs_pptr_calc_space_res(struct xfs_mount *mp, unsigned int namelen); @@ -126,8 +116,8 @@ struct xfs_parent_scratch { }; int xfs_parent_lookup(struct xfs_trans *tp, struct xfs_inode *ip, - const struct xfs_parent_name_irec *pptr, unsigned char *name, - unsigned int namelen, struct xfs_parent_scratch *scratch); + const struct xfs_parent_name_irec *pptr, + struct xfs_parent_scratch *scratch); int xfs_parent_set(struct xfs_inode *ip, const struct xfs_parent_name_irec *pptr, diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index 0e625c6b0153..a8afe2333194 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -439,6 +439,7 @@ static inline unsigned int xfs_calc_pptr_replace_overhead(void) return sizeof(struct xfs_attri_log_format) + xlog_calc_iovec_len(XATTR_NAME_MAX) + xlog_calc_iovec_len(XATTR_NAME_MAX) + + xlog_calc_iovec_len(XFS_PARENT_NAME_MAX_SIZE) + xlog_calc_iovec_len(XFS_PARENT_NAME_MAX_SIZE); } diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c index 87cff40b15f1..23cb7519c8f0 100644 --- a/fs/xfs/scrub/dir.c +++ b/fs/xfs/scrub/dir.c @@ -78,7 +78,7 @@ struct xchk_dir { /* If we've cycled the ILOCK, we must revalidate deferred dirents. */ bool need_revalidate; - /* Name buffer for pptr validation and dirent revalidation. */ + /* Name buffer for dirent revalidation. */ uint8_t namebuf[MAXNAMELEN]; }; @@ -143,42 +143,16 @@ xchk_dir_parent_pointer( struct xfs_inode *ip) { struct xfs_scrub *sc = sd->sc; - int pptr_namelen; - int hashlen; + int error; sd->pptr.p_ino = sc->ip->i_ino; sd->pptr.p_gen = VFS_I(sc->ip)->i_generation; + sd->pptr.p_namelen = name->len; + memcpy(sd->pptr.p_name, name->name, name->len); - hashlen = xfs_parent_namehash(ip, name, &sd->pptr.p_namehash, - sizeof(sd->pptr.p_namehash)); - if (hashlen < 0) { - xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, - &hashlen); - return hashlen; - } - sd->pptr.hashlen = hashlen; - - pptr_namelen = xfs_parent_lookup(sc->tp, ip, &sd->pptr, sd->namebuf, - MAXNAMELEN, &sd->pptr_scratch); - if (pptr_namelen == -ENOATTR) { - xchk_fblock_xref_set_corrupt(sc, XFS_DATA_FORK, 0); - return 0; - } - if (pptr_namelen < 0) { - xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, - &pptr_namelen); - return pptr_namelen; - } - - if (pptr_namelen != name->len) { - xchk_fblock_xref_set_corrupt(sc, XFS_DATA_FORK, 0); - return 0; - } - - if (memcmp(sd->namebuf, name->name, name->len)) { + error = xfs_parent_lookup(sc->tp, ip, &sd->pptr, &sd->pptr_scratch); + if (error == -ENOATTR) xchk_fblock_xref_set_corrupt(sc, XFS_DATA_FORK, 0); - return 0; - } return 0; } diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c index f3b1d7cbe415..fbe6fb709e2e 100644 --- a/fs/xfs/scrub/parent.c +++ b/fs/xfs/scrub/parent.c @@ -348,12 +348,6 @@ struct xchk_pptrs { /* xattr key and da args for parent pointer revalidation. */ struct xfs_parent_scratch pptr_scratch; - - /* Name hashes */ - uint8_t child_namehash[XFS_PARENT_NAME_MAX_HASH_SIZE]; - - /* Name buffer for revalidation. */ - uint8_t namebuf[MAXNAMELEN]; }; /* Look up the dotdot entry so that we can check it as we walk the pptrs. */ @@ -526,12 +520,10 @@ xchk_parent_scan_attr( unsigned int valuelen, void *priv) { - struct xfs_name xname = { }; struct xchk_pptrs *pp = priv; struct xfs_inode *dp = NULL; const struct xfs_parent_name_rec *rec = (const void *)name; unsigned int lockmode; - int hashlen; int error; /* Ignore incomplete xattrs */ @@ -555,29 +547,6 @@ xchk_parent_scan_attr( xfs_parent_irec_from_disk(&pp->pptr, rec, namelen, value, valuelen); - xname.name = pp->pptr.p_name; - xname.len = pp->pptr.p_namelen; - - /* - * Does the namehash in the parent pointer match the actual name? - * If not, there's no point in checking further. - */ - hashlen = xfs_parent_namehash(sc->ip, &xname, pp->child_namehash, - sizeof(pp->child_namehash)); - if (hashlen < 0) { - xchk_fblock_xref_process_error(sc, XFS_ATTR_FORK, 0, &hashlen); - return hashlen; - } - - if (hashlen != pp->pptr.hashlen || - memcmp(pp->pptr.p_namehash, pp->child_namehash, - pp->pptr.hashlen)) { - trace_xchk_parent_bad_namehash(sc->ip, pp->pptr.p_ino, - xname.name, xname.len); - xchk_fblock_xref_set_corrupt(sc, XFS_ATTR_FORK, 0); - return 0; - } - error = xchk_parent_iget(pp, &dp); if (error) return error; @@ -630,28 +599,16 @@ xchk_parent_revalidate_pptr( struct xchk_pptrs *pp) { struct xfs_scrub *sc = pp->sc; - int namelen; + int error; - namelen = xfs_parent_lookup(sc->tp, sc->ip, &pp->pptr, pp->namebuf, - MAXNAMELEN, &pp->pptr_scratch); - if (namelen == -ENOATTR) { - /* Parent pointer went away, nothing to revalidate. */ + error = xfs_parent_lookup(sc->tp, sc->ip, &pp->pptr, + &pp->pptr_scratch); + if (error == -ENOATTR) { + /* Parent pointer went away, nothing to revalidate. */ return -ENOENT; } - if (namelen < 0 && namelen != -EEXIST) - return namelen; - /* - * The dirent name changed length while we were unlocked. No need - * to revalidate this. - */ - if (namelen != pp->pptr.p_namelen) - return -ENOENT; - - /* The dirent name itself changed; there's nothing to revalidate. */ - if (memcmp(pp->namebuf, pp->pptr.p_name, pp->pptr.p_namelen)) - return -ENOENT; - return 0; + return error; } /* @@ -679,10 +636,6 @@ xchk_parent_slow_pptr( pp->pptr.p_name[MAXNAMELEN - 1] = 0; pp->pptr.p_namelen = pptr->namelen; - error = xfs_parent_irec_hash(sc->ip, &pp->pptr); - if (error) - return error; - /* Check that the deferred parent pointer still exists. */ if (pp->need_revalidate) { error = xchk_parent_revalidate_pptr(pp); @@ -714,7 +667,7 @@ xchk_parent_slow_pptr( xchk_iunlock(sc, sc->ilock_flags); pp->need_revalidate = true; - trace_xchk_parent_slowpath(sc->ip, pp->namebuf, pptr->namelen, + trace_xchk_parent_slowpath(sc->ip, pp->pptr.p_name, pptr->namelen, dp->i_ino); while (true) { diff --git a/fs/xfs/scrub/parent_repair.c b/fs/xfs/scrub/parent_repair.c index 14647e3da8c1..b55ef1506dd2 100644 --- a/fs/xfs/scrub/parent_repair.c +++ b/fs/xfs/scrub/parent_repair.c @@ -126,9 +126,6 @@ struct xrep_pptrs { /* Parent pointer names. */ struct xfblob *pptr_names; - - /* Buffer for validation. */ - unsigned char namebuf[MAXNAMELEN]; }; /* Tear down all the incore stuff we created. */ @@ -182,16 +179,11 @@ xrep_pptr_replay_update( const struct xrep_pptr *pptr) { struct xfs_scrub *sc = rp->sc; - int error; rp->pptr.p_ino = pptr->p_ino; rp->pptr.p_gen = pptr->p_gen; rp->pptr.p_namelen = pptr->namelen; - error = xfs_parent_irec_hash(sc->ip, &rp->pptr); - if (error) - return error; - if (pptr->action == XREP_PPTR_ADD) { /* Create parent pointer. */ trace_xrep_pptr_createname(sc->tempip, &rp->pptr); @@ -510,7 +502,7 @@ xrep_pptr_dump_tempptr( struct xrep_pptrs *rp = priv; const struct xfs_parent_name_rec *rec = (const void *)name; struct xfs_inode *other_ip; - int pptr_namelen; + int error; if (!(attr_flags & XFS_ATTR_PARENT)) return 0; @@ -526,29 +518,15 @@ xrep_pptr_dump_tempptr( trace_xrep_pptr_dumpname(sc->tempip, &rp->pptr); - pptr_namelen = xfs_parent_lookup(sc->tp, other_ip, &rp->pptr, - rp->namebuf, MAXNAMELEN, &rp->pptr_scratch); - if (pptr_namelen == -ENOATTR) { + error = xfs_parent_lookup(sc->tp, other_ip, &rp->pptr, + &rp->pptr_scratch); + if (error == -ENOATTR) { trace_xrep_pptr_checkname(other_ip, &rp->pptr); - ASSERT(pptr_namelen != -ENOATTR); + ASSERT(error != -ENOATTR); return -EFSCORRUPTED; } - if (pptr_namelen < 0) - return pptr_namelen; - if (pptr_namelen != rp->pptr.p_namelen) { - trace_xrep_pptr_checkname(other_ip, &rp->pptr); - ASSERT(pptr_namelen == rp->pptr.p_namelen); - return -EFSCORRUPTED; - } - - if (memcmp(rp->namebuf, rp->pptr.p_name, rp->pptr.p_namelen)) { - trace_xrep_pptr_checkname(other_ip, &rp->pptr); - ASSERT(0); - return -EFSCORRUPTED; - } - - return 0; + return error; } /* diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index b7f29b4acac3..a78a3077b41a 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -117,9 +117,6 @@ xfs_check_ondisk_structs(void) XFS_CHECK_OFFSET(xfs_dir2_sf_entry_t, name, 3); XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t, 10); XFS_CHECK_STRUCT_SIZE(struct xfs_parent_name_rec, 12); - BUILD_BUG_ON(XFS_PARENT_NAME_MAX_HASH_SIZE < SHA512_DIGEST_SIZE); - BUILD_BUG_ON(XFS_PARENT_NAME_MAX_HASH_SIZE != 243); - BUILD_BUG_ON(XFS_PARENT_NAME_SHA512_OFFSET != 179); /* log structures */ XFS_CHECK_STRUCT_SIZE(struct xfs_buf_log_format, 88); From patchwork Fri Mar 3 17:12:26 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: 13159048 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 F1DA8C7EE2F for ; Fri, 3 Mar 2023 17:12:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbjCCRMe (ORCPT ); Fri, 3 Mar 2023 12:12:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbjCCRMd (ORCPT ); Fri, 3 Mar 2023 12:12:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B168236693 for ; Fri, 3 Mar 2023 09:12:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4B6D6618A0 for ; Fri, 3 Mar 2023 17:12:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5452C433EF; Fri, 3 Mar 2023 17:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863546; bh=UvB1l4931GZoRTy8aEBLiQN7zI1tDvQwcDUphBYu9Bg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=DgKAud5oGUnsJ/k1x1+JOv9vwiEO1pG6xi0wPhTr0O65a6aGlKiaPQNophCafflFW ieRMNKTLQTdai0d63UbXGkgG19vQqA7Eb92RQpXWqgixf4meM9pRNGSlfu9jxtWjOV cbXi7YpXtz9HoM4jwxbJd+xziZzKn6EbWwJp7gRVNauAJIGOBziCw1PWXqNnv9O++a bSdNQ5d4VX47Wm7tE7RF7jNmb/7dvyuxTDrIQQRN8OuvV9ROC4Rpq7Bc4G792yMBSC R23xQ/QlipP+LwA9snjUW5siNJls0qgYFlR8tlfgwl6mJDsjOYqd5LrqpllhdPhPSS 0UNvJ0fzblx5A== Subject: [PATCH 12/13] xfs: turn NVREPLACEXXX into NVREPLACE From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:12:26 -0800 Message-ID: <167786354618.1543331.1557214035782220495.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong NVREPLACEXXX is NVREPLACE with VLOOKUP enabled. Nobody uses NVREPLACE now, so get rid of NVREPLACE and make NVREPLACEXXX take its place. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 7 ------- fs/xfs/libxfs/xfs_log_format.h | 1 - fs/xfs/xfs_attr_item.c | 15 +++------------ 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index d807692b259c..c6621aba161d 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -431,11 +431,6 @@ xfs_attr_complete_op( args->namelen); args->value = args->new_value; args->valuelen = args->new_valuelen; - } else if (args->new_namelen > 0) { - args->name = args->new_name; - args->namelen = args->new_namelen; - args->hashval = xfs_da_hashname(args->name, - args->namelen); } return replace_state; } @@ -944,8 +939,6 @@ xfs_attr_defer_replace( int error = 0; if (args->op_flags & XFS_DA_OP_VLOOKUP) - op_flag = XFS_ATTRI_OP_FLAGS_NVREPLACEXXX; - else if (args->new_namelen > 0) op_flag = XFS_ATTRI_OP_FLAGS_NVREPLACE; error = xfs_attr_intent_init(args, op_flag, &new); diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index ed406738847d..ec85af39ed91 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -961,7 +961,6 @@ struct xfs_icreate_log { #define XFS_ATTRI_OP_FLAGS_NVREPLACE 4 /* Replace attr name and val */ #define XFS_ATTRI_OP_FLAGS_NVREMOVE 5 /* Remove attr w/ vlookup */ #define XFS_ATTRI_OP_FLAGS_NVSET 6 /* Set attr with w/ vlookup */ -#define XFS_ATTRI_OP_FLAGS_NVREPLACEXXX 7 /* Replace attr name and val */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 57cc426b1e22..70d56bab4e21 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -428,13 +428,10 @@ xfs_attr_log_item( attrp->alfi_op_flags = attr->xattri_op_flags; attrp->alfi_value_len = attr->xattri_nameval->value.i_len; - if (xfs_attr_log_item_op(attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACEXXX) { + if (xfs_attr_log_item_op(attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { attrp->alfi_oldname_len = attr->xattri_nameval->name.i_len; attrp->alfi_newname_len = attr->xattri_nameval->newname.i_len; attrp->alfi_newvalue_len = attr->xattri_nameval->newvalue.i_len; - } else if (xfs_attr_log_item_op(attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { - attrp->alfi_oldname_len = attr->xattri_nameval->name.i_len; - attrp->alfi_newname_len = attr->xattri_nameval->newname.i_len; } else { attrp->alfi_name_len = attr->xattri_nameval->name.i_len; } @@ -598,7 +595,6 @@ xfs_attri_validate( if (attrp->alfi_newvalue_len != 0) return false; break; - case XFS_ATTRI_OP_FLAGS_NVREPLACEXXX: case XFS_ATTRI_OP_FLAGS_NVREPLACE: if (attrp->alfi_oldname_len == 0 || attrp->alfi_oldname_len > XATTR_NAME_MAX) @@ -685,7 +681,7 @@ xfs_attri_item_recover( ASSERT(xfs_sb_version_haslogxattrs(&mp->m_sb)); switch (attr->xattri_op_flags) { - case XFS_ATTRI_OP_FLAGS_NVREPLACEXXX: + case XFS_ATTRI_OP_FLAGS_NVREPLACE: args->new_value = nv->newvalue.i_addr; args->new_valuelen = nv->newvalue.i_len; fallthrough; @@ -694,7 +690,6 @@ xfs_attri_item_recover( fallthrough; case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: - case XFS_ATTRI_OP_FLAGS_NVREPLACE: args->value = nv->value.i_addr; args->valuelen = nv->value.i_len; args->total = xfs_attr_calc_size(args, &local); @@ -788,13 +783,10 @@ xfs_attri_item_relog( new_attrp->alfi_ino = old_attrp->alfi_ino; new_attrp->alfi_op_flags = old_attrp->alfi_op_flags; new_attrp->alfi_value_len = old_attrp->alfi_value_len; - if (xfs_attr_log_item_op(old_attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACEXXX) { + if (xfs_attr_log_item_op(old_attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { new_attrp->alfi_newname_len = old_attrp->alfi_newname_len; new_attrp->alfi_oldname_len = old_attrp->alfi_oldname_len; new_attrp->alfi_newvalue_len = old_attrp->alfi_newvalue_len; - } else if (xfs_attr_log_item_op(old_attrp) == XFS_ATTRI_OP_FLAGS_NVREPLACE) { - new_attrp->alfi_newname_len = old_attrp->alfi_newname_len; - new_attrp->alfi_oldname_len = old_attrp->alfi_oldname_len; } else { new_attrp->alfi_name_len = old_attrp->alfi_name_len; } @@ -864,7 +856,6 @@ xlog_recover_attri_commit_pass2( name_len = attri_formatp->alfi_name_len; value_len = attri_formatp->alfi_value_len; break; - case XFS_ATTRI_OP_FLAGS_NVREPLACEXXX: case XFS_ATTRI_OP_FLAGS_NVREPLACE: if (item->ri_total < 3 || item->ri_total > 5) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, From patchwork Fri Mar 3 17:12:31 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: 13159047 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 7834CC7EE39 for ; Fri, 3 Mar 2023 17:12:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231546AbjCCRMf (ORCPT ); Fri, 3 Mar 2023 12:12:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231515AbjCCRMe (ORCPT ); Fri, 3 Mar 2023 12:12:34 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DDB73644F for ; Fri, 3 Mar 2023 09:12:33 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DC2536187E for ; Fri, 3 Mar 2023 17:12:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 489D8C433EF; Fri, 3 Mar 2023 17:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677863552; bh=/iqlqNfDHlKgNNBVDDvt2m9cH0WUpZq+DxiangXpjC8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=u2jOkym3Cl++zUS49ih1l4nXRsNEw9EnkYDhk5VnUbNhcTbHYYMoiag8Fe1sI6RPh Qh7xTwj3hmEvbG7Fzxy55z7l+pTgN4ma5lT6zeTB8t9rKb+LkK1KHvCQ6FGBu7i8Q3 K3px/i8+lgA3CBJtYitINiZ81Y3vNAXn1kYMYFLOiGHftdwq7VF/7g6VIEoBmejXYt OOK7iyNvbfrThZzG6tfdU46nyts148tvvXORvpADU10c5oziE8ZD/izQtagEcvS48s m7oC8PoCPJtxHx4vFpKQyjDvqV2VMFn58RtsMmJFDGhb1nogJ5xBkEiFEWP9wqYyDh Qlr/t19CYTDDQ== Subject: [PATCH 13/13] xfs: revert "load secure hash algorithm for parent pointers" From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Date: Fri, 03 Mar 2023 09:12:31 -0800 Message-ID: <167786355185.1543331.4836262247618832123.stgit@magnolia> In-Reply-To: <167786347827.1543331.2803518928321606576.stgit@magnolia> References: <167786347827.1543331.2803518928321606576.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong We don't use this anymore, so get rid of it. Signed-off-by: Darrick J. Wong --- fs/xfs/Kconfig | 1 - fs/xfs/xfs_linux.h | 1 - fs/xfs/xfs_mount.c | 13 ------------- fs/xfs/xfs_mount.h | 3 --- fs/xfs/xfs_sha512.h | 42 ------------------------------------------ fs/xfs/xfs_super.c | 3 --- 6 files changed, 63 deletions(-) delete mode 100644 fs/xfs/xfs_sha512.h diff --git a/fs/xfs/Kconfig b/fs/xfs/Kconfig index 6422daaf8914..4798a147fd9e 100644 --- a/fs/xfs/Kconfig +++ b/fs/xfs/Kconfig @@ -5,7 +5,6 @@ config XFS_FS select EXPORTFS select LIBCRC32C select FS_IOMAP - select CRYPTO_SHA512 help XFS is a high performance journaling filesystem which originated on the SGI IRIX platform. It is completely multi-threaded, can diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index 3f93a742b896..c05f7e309c3e 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h @@ -62,7 +62,6 @@ typedef __u32 xfs_nlink_t; #include #include #include -#include #include #include diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index a5f3dce658e9..fb87ffb48f7f 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -983,19 +983,6 @@ xfs_mountfs( goto out_agresv; } - if (xfs_has_parent(mp)) { - struct crypto_shash *tfm; - - tfm = crypto_alloc_shash("sha512", 0, 0); - if (IS_ERR(tfm)) { - error = PTR_ERR(tfm); - goto out_agresv; - } - xfs_info(mp, "parent pointer hash %s", - crypto_shash_driver_name(tfm)); - mp->m_sha512 = tfm; - } - return 0; out_agresv: diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 7c8e15e84cd6..c08f55cc4f36 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -244,9 +244,6 @@ typedef struct xfs_mount { #endif /* Hook to feed file directory updates to an active online repair. */ struct xfs_hooks m_dirent_update_hooks; - - /* sha512 engine, if needed */ - struct crypto_shash *m_sha512; } xfs_mount_t; #define M_IGEO(mp) (&(mp)->m_ino_geo) diff --git a/fs/xfs/xfs_sha512.h b/fs/xfs/xfs_sha512.h deleted file mode 100644 index d9756db63aa6..000000000000 --- a/fs/xfs/xfs_sha512.h +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2023 Oracle. All Rights Reserved. - * Author: Darrick J. Wong - */ -#ifndef __XFS_SHA512_H__ -#define __XFS_SHA512_H__ - -struct sha512_state { - union { - struct shash_desc desc; - char __desc[sizeof(struct shash_desc) + HASH_MAX_DESCSIZE]; - }; -}; - -#define SHA512_DESC_ON_STACK(mp, name) \ - struct sha512_state name = { .desc.tfm = (mp)->m_sha512 } - -#define SHA512_DIGEST_SIZE 64 - -static inline int sha512_init(struct sha512_state *md) -{ - return crypto_shash_init(&md->desc); -} - -static inline int sha512_done(struct sha512_state *md, unsigned char *out) -{ - return crypto_shash_final(&md->desc, out); -} - -static inline int sha512_process(struct sha512_state *md, - const unsigned char *in, unsigned long inlen) -{ - return crypto_shash_update(&md->desc, in, inlen); -} - -static inline void sha512_erase(struct sha512_state *md) -{ - memset(md, 0, sizeof(*md)); -} - -#endif /* __XFS_SHA512_H__ */ diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 610d72353f39..0432a4a096e8 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -738,8 +738,6 @@ xfs_mount_free( { kfree(mp->m_rtname); kfree(mp->m_logname); - if (mp->m_sha512) - crypto_free_shash(mp->m_sha512); kmem_free(mp); } @@ -1963,7 +1961,6 @@ static int xfs_init_fs_context( if (fc->sb_flags & SB_SYNCHRONOUS) mp->m_features |= XFS_FEAT_WSYNC; - mp->m_sha512 = NULL; fc->s_fs_info = mp; fc->ops = &xfs_context_ops;