From patchwork Thu Mar 16 19:26:10 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: 13178230 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 ED6C3C6FD1F for ; Thu, 16 Mar 2023 19:26:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229644AbjCPT0O (ORCPT ); Thu, 16 Mar 2023 15:26:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbjCPT0N (ORCPT ); Thu, 16 Mar 2023 15:26:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2FAABDD22 for ; Thu, 16 Mar 2023 12:26:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 37761620F9 for ; Thu, 16 Mar 2023 19:26:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92A53C433D2; Thu, 16 Mar 2023 19:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678994770; bh=kh8noAaNt2RzSwuZOW2CBf/JKZXoFZdjWaPXA2gWetI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Rjpt/BptgIISVBXlNIabSEOdTE+k3q7pdOGvE5LRC4jI7+oVNj9UseE9dEcCCpAc1 uI+ez8WmTtB+11kRpUBv+HuvdDXWlgHsr4umTPeGNBv+Ba/AI/mZvB+CDkJ1KLqOX4 7WnRK10yK3r8VwdkMJUYwRZHM+4YQpdZ3uU/8TCKWj3yqZTF7I8fCp9zs8LQh7KUBV 3EyJLew4sb1qByTUuXyLlY/f0BjCBs0HnATTBOf/OpAnRHD9NQpssi+JqX7yKGTko7 rDwY+c0wDVbbdREhilmyr3F5yYvXu/IGmDYz55ak+TbtKTwbgphqjybozSOb0TzFSb DYyhvFzfXaCaQ== Date: Thu, 16 Mar 2023 12:26:10 -0700 Subject: [PATCH 1/9] libxfs: initialize the slab cache for parent defer items From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167899415390.16278.7244343000757925685.stgit@frogsfrogsfrogs> In-Reply-To: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> References: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Initialize the slab cache for parent defer items. We'll need this in an upcoming patch. Signed-off-by: Darrick J. Wong --- include/libxfs.h | 1 + libxfs/init.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/libxfs.h b/include/libxfs.h index b28781d19..cc57e8887 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -78,6 +78,7 @@ struct iomap; #include "xfs_refcount_btree.h" #include "xfs_refcount.h" #include "xfs_btree_staging.h" +#include "xfs_parent.h" #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) diff --git a/libxfs/init.c b/libxfs/init.c index fda36ba0f..59cd547d6 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -258,6 +258,8 @@ init_caches(void) "xfs_extfree_item"); xfs_trans_cache = kmem_cache_init( sizeof(struct xfs_trans), "xfs_trans"); + xfs_parent_intent_cache = kmem_cache_init( + sizeof(struct xfs_parent_defer), "xfs_parent_defer"); } static int @@ -275,6 +277,7 @@ destroy_caches(void) xfs_btree_destroy_cur_caches(); leaked += kmem_cache_destroy(xfs_extfree_item_cache); leaked += kmem_cache_destroy(xfs_trans_cache); + leaked += kmem_cache_destroy(xfs_parent_intent_cache); return leaked; } From patchwork Thu Mar 16 19:26:25 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: 13178231 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 2F6CAC6FD19 for ; Thu, 16 Mar 2023 19:26:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbjCPT03 (ORCPT ); Thu, 16 Mar 2023 15:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbjCPT02 (ORCPT ); Thu, 16 Mar 2023 15:26:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4385F4393E for ; Thu, 16 Mar 2023 12:26:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CEFC6620F5 for ; Thu, 16 Mar 2023 19:26:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34FD9C433EF; Thu, 16 Mar 2023 19:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678994786; bh=AmApFvqePLIKF4FAie0JOquoAlMKO/Af0U4G6HlmnZU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=o/A0vRXkukkNzxG8OcQUKZbEfv/1K8GKH5XvNjTjXOMX9H1ZUfZfqI5+mr6NVIKvl aKIlfChhg8BNSmmKAeoC8GfR8MbRFDCJ5DLxmnu+QKpapsIAUk1WWMAYqJWNoENyiY oKkQaIQBSV6ST7s/eoXtH390uiu7Ys2bRCWH6Kbv1bUZd5xwjZp1olLOvKja+b90Eu /gujJIdgyb8dkStRQX2yWt/C6AdGRp+8Z9BtLHdsaXKPAW6qPCNMAHQVt9EmyaNCFa zMRxo4PYtTOaO8YeNG9F9bgiGa7g50j75jrRB992btNBJO+TWCFTiiXTHkcRE0Yl43 BaaBvE6p6S0+g== Date: Thu, 16 Mar 2023 12:26:25 -0700 Subject: [PATCH 2/9] mkfs: fix libxfs api misuse From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167899415403.16278.8241552212949054742.stgit@frogsfrogsfrogs> In-Reply-To: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> References: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Fix libxfs usage problems as pointed out by xfs/437. Signed-off-by: Darrick J. Wong --- libxfs/libxfs_api_defs.h | 1 + mkfs/proto.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index f8efcce77..e44b0b29e 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -124,6 +124,7 @@ #define xfs_initialize_perag libxfs_initialize_perag #define xfs_initialize_perag_data libxfs_initialize_perag_data #define xfs_init_local_fork libxfs_init_local_fork +#define xfs_init_parent_name_rec libxfs_init_parent_name_rec #define xfs_inobt_maxrecs libxfs_inobt_maxrecs #define xfs_inobt_stage_cursor libxfs_inobt_stage_cursor diff --git a/mkfs/proto.c b/mkfs/proto.c index 36d8cde21..ac7ffbe9d 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -613,8 +613,8 @@ parseproto( .value = (void *)xname.name, .valuelen = xname.len, }; - xfs_init_parent_name_rec(&rec, pip, offset); - error = xfs_attr_set(&args); + libxfs_init_parent_name_rec(&rec, pip, offset); + error = -libxfs_attr_set(&args); if (error) fail(_("Error creating parent pointer"), error); } From patchwork Thu Mar 16 19:26:41 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: 13178232 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 AD19EC6FD19 for ; Thu, 16 Mar 2023 19:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbjCPT0o (ORCPT ); Thu, 16 Mar 2023 15:26:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjCPT0n (ORCPT ); Thu, 16 Mar 2023 15:26:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC703C8888 for ; Thu, 16 Mar 2023 12:26:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 65EDA620DC for ; Thu, 16 Mar 2023 19:26:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C614CC433D2; Thu, 16 Mar 2023 19:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678994801; bh=1KEN42LiXPBKOY3IuYH/aqO+L+wW1zQtez9mGWda0vw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=dJmPw1IpwMYWvpb8QKLdkXwB3FH4O3k8Q6aoKqGLvq1p2kCOPdtNy8XDgA0VWviMP Rl4ZUFtthak1dYvUHWjWMsuKtZrTZ6aOmfi/Rkmva1rPiX4GtuShiGegTzaG+2JpiT sNr7NfsobP9C1qOJamN5JDL/gGwUipXqrhEs5VdPQ3apB1IZwStHIieLgq4L8Ayai1 oC+1G8vLBvI5YFrvYX3K86jwpoqUzvLPtW/DRY9ICFlVZBS83IvmCF3B4MNNNNUmgw QdTuuz651cLBTWQB4CIjZGbo86xNlwWXggPnK/J8VQgvH0y/nixIEBNV6aJyQ0pAxz CBmI8T2NysN6A== Date: Thu, 16 Mar 2023 12:26:41 -0700 Subject: [PATCH 3/9] libxfs: create new files with attr forks if necessary From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167899415416.16278.13396714496427226116.stgit@frogsfrogsfrogs> In-Reply-To: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> References: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Create new files with attr forks if they're going to have parent pointers. In the next patch we'll fix mkfs to use the same parent creation functions as the kernel, so we're going to need this. Signed-off-by: Darrick J. Wong --- libxfs/init.c | 4 ++++ libxfs/util.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/libxfs/init.c b/libxfs/init.c index 59cd547d6..101b77602 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -746,14 +746,18 @@ void libxfs_compute_all_maxlevels( struct xfs_mount *mp) { + struct xfs_ino_geometry *igeo = M_IGEO(mp); + xfs_alloc_compute_maxlevels(mp); xfs_bmap_compute_maxlevels(mp, XFS_DATA_FORK); xfs_bmap_compute_maxlevels(mp, XFS_ATTR_FORK); + igeo->attr_fork_offset = xfs_bmap_compute_attr_offset(mp); xfs_ialloc_setup_geometry(mp); xfs_rmapbt_compute_maxlevels(mp); xfs_refcountbt_compute_maxlevels(mp); xfs_agbtree_compute_maxlevels(mp); + } /* diff --git a/libxfs/util.c b/libxfs/util.c index 6525f63de..bea5f1c71 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -322,6 +322,20 @@ libxfs_init_new_inode( ASSERT(0); } + /* + * If we need to create attributes immediately after allocating the + * inode, initialise an empty attribute fork right now. We use the + * default fork offset for attributes here as we don't know exactly what + * size or how many attributes we might be adding. We can do this + * safely here because we know the data fork is completely empty and + * this saves us from needing to run a separate transaction to set the + * fork offset in the immediate future. + */ + if (xfs_has_parent(tp->t_mountp) && xfs_has_attr(tp->t_mountp)) { + ip->i_forkoff = xfs_default_attroffset(ip) >> 3; + xfs_ifork_init_attr(ip, XFS_DINODE_FMT_EXTENTS, 0); + } + /* * Log the new values stuffed into the inode. */ From patchwork Thu Mar 16 19:26:56 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: 13178233 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 28364C6FD1F for ; Thu, 16 Mar 2023 19:27:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229516AbjCPT1C (ORCPT ); Thu, 16 Mar 2023 15:27:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbjCPT1B (ORCPT ); Thu, 16 Mar 2023 15:27:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8132C8888 for ; Thu, 16 Mar 2023 12:26:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9E695B82302 for ; Thu, 16 Mar 2023 19:26:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52B67C433D2; Thu, 16 Mar 2023 19:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678994817; bh=Ok2jL3S8Vqn4hmBKjtxLAMT7WDu6JiaR443/ItGyegY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=euv2/iqKUrDxoK57IcXjzBys6uUTlNwPcRSzcIdpKxjvSTIINhASgQdV5L/BgZuxr eTEChVJQqYB99HjiLfsllOEWcrHSYxh9IDqt64Rv6jTRtZ5fkHttJBkRMkOx62vMmy hRxTRwQfaoKgy366Vrl8phhciVpqzzMJxOGtwnsp+tL3FWO4d6jLRs64zDyE8Ke76u X/X5AzciXpDmah+LxSM0mnlgMP9Q0ZmMCdD98J0oBo3E/cfwx8UiMDAWa+91t7kVvu BIwkMMmt1TOWjwHmAEq1KcWNlvUMEo6W0YAHeljT+I8R+1jmQnPcyumroGmR3QN4iA x+DbmUxLIY14g== Date: Thu, 16 Mar 2023 12:26:56 -0700 Subject: [PATCH 4/9] mkfs: fix subdir parent pointer creation From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167899415429.16278.5259298733491430583.stgit@frogsfrogsfrogs> In-Reply-To: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> References: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Rework the protofile code so that it uses the same deferred parent pointer ops that the kernel uses to create parent pointers. While we're at it, make it so that subdirs of the root directory and reserved files also get parent pointers. Found by xfs/019. Signed-off-by: Darrick J. Wong --- libxfs/libxfs_api_defs.h | 3 ++ mkfs/proto.c | 65 +++++++++++++++++++++++++++++++++------------- 2 files changed, 50 insertions(+), 18 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index e44b0b29e..055d2862a 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -140,6 +140,9 @@ #define xfs_log_get_max_trans_res libxfs_log_get_max_trans_res #define xfs_log_sb libxfs_log_sb #define xfs_mode_to_ftype libxfs_mode_to_ftype +#define xfs_parent_defer_add libxfs_parent_defer_add +#define xfs_parent_finish libxfs_parent_finish +#define xfs_parent_start libxfs_parent_start #define xfs_perag_get libxfs_perag_get #define xfs_perag_put libxfs_perag_put #define xfs_prealloc_blocks libxfs_prealloc_blocks diff --git a/mkfs/proto.c b/mkfs/proto.c index ac7ffbe9d..e0131df50 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -8,7 +8,6 @@ #include #include "libfrog/convert.h" #include "proto.h" -#include "xfs_parent.h" /* * Prototypes for internal functions. @@ -349,6 +348,20 @@ newdirectory( fail(_("directory create error"), error); } +static struct xfs_parent_defer * +newpptr( + struct xfs_mount *mp) +{ + struct xfs_parent_defer *ret; + int error; + + error = -libxfs_parent_start(mp, &ret); + if (error) + fail(_("initializing parent pointer"), error); + + return ret; +} + static void parseproto( xfs_mount_t *mp, @@ -384,6 +397,7 @@ parseproto( char *value; struct xfs_name xname; xfs_dir2_dataptr_t offset; + struct xfs_parent_defer *parent = NULL; memset(&creds, 0, sizeof(creds)); mstr = getstr(pp); @@ -458,6 +472,7 @@ parseproto( case IF_REGULAR: buf = newregfile(pp, &len); tp = getres(mp, XFS_B_TO_FSB(mp, len)); + parent = newpptr(mp); error = -libxfs_dir_ialloc(&tp, pip, mode|S_IFREG, 1, 0, &creds, fsxp, &ip); if (error) @@ -481,7 +496,7 @@ parseproto( exit(1); } tp = getres(mp, XFS_B_TO_FSB(mp, llen)); - + parent = newpptr(mp); error = -libxfs_dir_ialloc(&tp, pip, mode|S_IFREG, 1, 0, &creds, fsxp, &ip); if (error) @@ -492,15 +507,24 @@ parseproto( xname.type = XFS_DIR3_FT_REG_FILE; newdirent(mp, tp, pip, &xname, ip->i_ino, &offset); libxfs_trans_log_inode(tp, ip, flags); + if (parent) { + error = -libxfs_parent_defer_add(tp, parent, pip, + &xname, offset, ip); + if (error) + fail(_("committing parent pointers failed."), + error); + } error = -libxfs_trans_commit(tp); if (error) fail(_("Space preallocation failed."), error); + libxfs_parent_finish(mp, parent); rsvfile(mp, ip, llen); libxfs_irele(ip); return; case IF_BLOCK: tp = getres(mp, 0); + parent = newpptr(mp); majdev = getnum(getstr(pp), 0, 0, false); mindev = getnum(getstr(pp), 0, 0, false); error = -libxfs_dir_ialloc(&tp, pip, mode|S_IFBLK, 1, @@ -516,6 +540,7 @@ parseproto( case IF_CHAR: tp = getres(mp, 0); + parent = newpptr(mp); majdev = getnum(getstr(pp), 0, 0, false); mindev = getnum(getstr(pp), 0, 0, false); error = -libxfs_dir_ialloc(&tp, pip, mode|S_IFCHR, 1, @@ -530,6 +555,7 @@ parseproto( case IF_FIFO: tp = getres(mp, 0); + parent = newpptr(mp); error = -libxfs_dir_ialloc(&tp, pip, mode|S_IFIFO, 1, 0, &creds, fsxp, &ip); if (error) @@ -542,6 +568,7 @@ parseproto( buf = getstr(pp); len = (int)strlen(buf); tp = getres(mp, XFS_B_TO_FSB(mp, len)); + parent = newpptr(mp); error = -libxfs_dir_ialloc(&tp, pip, mode|S_IFLNK, 1, 0, &creds, fsxp, &ip); if (error) @@ -564,6 +591,7 @@ parseproto( libxfs_log_sb(tp); isroot = 1; } else { + parent = newpptr(mp); libxfs_trans_ijoin(tp, pip, 0); xname.type = XFS_DIR3_FT_DIR; newdirent(mp, tp, pip, &xname, ip->i_ino, &offset); @@ -572,9 +600,19 @@ parseproto( } newdirectory(mp, tp, ip, pip); libxfs_trans_log_inode(tp, ip, flags); + if (parent) { + error = -libxfs_parent_defer_add(tp, parent, pip, + &xname, offset, ip); + if (error) + fail(_("committing parent pointers failed."), + error); + } error = -libxfs_trans_commit(tp); if (error) fail(_("Directory inode allocation failed."), error); + + libxfs_parent_finish(mp, parent); + /* * RT initialization. Do this here to ensure that * the RT inodes get placed after the root inode. @@ -597,28 +635,19 @@ parseproto( fail(_("Unknown format"), EINVAL); } libxfs_trans_log_inode(tp, ip, flags); + if (parent) { + error = -libxfs_parent_defer_add(tp, parent, pip, &xname, + offset, ip); + if (error) + fail(_("committing parent pointers failed."), error); + } error = -libxfs_trans_commit(tp); if (error) { fail(_("Error encountered creating file from prototype file"), error); } - if (xfs_has_parent(mp)) { - struct xfs_parent_name_rec rec; - struct xfs_da_args args = { - .dp = ip, - .name = (const unsigned char *)&rec, - .namelen = sizeof(rec), - .attr_filter = XFS_ATTR_PARENT, - .value = (void *)xname.name, - .valuelen = xname.len, - }; - libxfs_init_parent_name_rec(&rec, pip, offset); - error = -libxfs_attr_set(&args); - if (error) - fail(_("Error creating parent pointer"), error); - } - + libxfs_parent_finish(mp, parent); libxfs_irele(ip); } From patchwork Thu Mar 16 19:27:12 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: 13178234 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 2D3EAC6FD1F for ; Thu, 16 Mar 2023 19:27:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229549AbjCPT1S (ORCPT ); Thu, 16 Mar 2023 15:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjCPT1R (ORCPT ); Thu, 16 Mar 2023 15:27:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC40DCD66C for ; Thu, 16 Mar 2023 12:27:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5C40AB82302 for ; Thu, 16 Mar 2023 19:27:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0B55C433EF; Thu, 16 Mar 2023 19:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678994833; bh=Ju9MdpdeEQUlgZK2fVnT5yTcHmdA4LE9JQlaKk7P/1s=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=XsdVQ2LdLoOOaCuEeVm8Ms5ji01a2DHHd4PEgNKEXZGGpEu1PT40dBZEaqGxGT0aB 2Qvm0oMFdsSQwV/GwHoXVBXzvk1huhdcVSLLrSd9yTm2EDrvRJl2lA61zPeaBhD4jZ y/gh2FUIt6y506wcBV/K7/XHy2xzDiML9K6lCBUJRblxoAbdq8aJ0QPFYRmADjuZ6u eJBSUdOwRUsplMQX73r0nlGC1gPU0PljVaOkjgOkKYCxR+VgN0DX8+WjYQiP0WCSZZ 0vTSk4iwYmll0bBWFTeZTCx6bqbxwMunaWId/41mVzbhplay8hloHJ54ToN+IaYyV8 ChP9PWQ+SJofA== Date: Thu, 16 Mar 2023 12:27:12 -0700 Subject: [PATCH 5/9] xfs_db: report parent pointer keys From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167899415442.16278.1927282731092038026.stgit@frogsfrogsfrogs> In-Reply-To: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> References: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Decode the parent pointer inode, generation, and diroffset fields. Signed-off-by: Darrick J. Wong --- db/attr.c | 31 +++++++++++++++++++++++++++++++ db/attrshort.c | 25 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/db/attr.c b/db/attr.c index f29e4a544..db7cf54b5 100644 --- a/db/attr.c +++ b/db/attr.c @@ -19,6 +19,7 @@ static int attr_leaf_entries_count(void *obj, int startoff); static int attr_leaf_hdr_count(void *obj, int startoff); static int attr_leaf_name_local_count(void *obj, int startoff); static int attr_leaf_name_local_name_count(void *obj, int startoff); +static int attr_leaf_name_pptr_count(void *obj, int startoff); static int attr_leaf_name_local_value_count(void *obj, int startoff); static int attr_leaf_name_local_value_offset(void *obj, int startoff, int idx); @@ -111,6 +112,8 @@ const field_t attr_leaf_map_flds[] = { #define LNOFF(f) bitize(offsetof(xfs_attr_leaf_name_local_t, f)) #define LVOFF(f) bitize(offsetof(xfs_attr_leaf_name_remote_t, f)) +#define PPOFF(f) bitize(offsetof(xfs_attr_leaf_name_local_t, nameval) + \ + offsetof(struct xfs_parent_name_rec, f)) const field_t attr_leaf_name_flds[] = { { "valuelen", FLDT_UINT16D, OI(LNOFF(valuelen)), attr_leaf_name_local_count, FLD_COUNT, TYP_NONE }, @@ -118,6 +121,12 @@ const field_t attr_leaf_name_flds[] = { attr_leaf_name_local_count, FLD_COUNT, TYP_NONE }, { "name", FLDT_CHARNS, OI(LNOFF(nameval)), attr_leaf_name_local_name_count, FLD_COUNT, TYP_NONE }, + { "parent_ino", FLDT_INO, OI(PPOFF(p_ino)), + attr_leaf_name_pptr_count, FLD_COUNT, TYP_INODE }, + { "parent_gen", FLDT_UINT32D, OI(PPOFF(p_gen)), + attr_leaf_name_pptr_count, FLD_COUNT, TYP_NONE }, + { "parent_diroffset", FLDT_UINT32D, OI(PPOFF(p_diroffset)), + attr_leaf_name_pptr_count, FLD_COUNT, TYP_NONE }, { "value", FLDT_CHARNS, attr_leaf_name_local_value_offset, attr_leaf_name_local_value_count, FLD_COUNT|FLD_OFFSET, TYP_NONE }, { "valueblk", FLDT_UINT32X, OI(LVOFF(valueblk)), @@ -273,6 +282,26 @@ attr_leaf_name_local_count( __attr_leaf_name_local_count); } +static int +__attr_leaf_name_pptr_count( + struct xfs_attr_leafblock *leaf, + struct xfs_attr_leaf_entry *e, + int i) +{ + if (e->flags & XFS_ATTR_PARENT) + return 1; + return 0; +} + +static int +attr_leaf_name_pptr_count( + void *obj, + int startoff) +{ + return attr_leaf_entry_walk(obj, startoff, + __attr_leaf_name_pptr_count); +} + static int __attr_leaf_name_local_name_count( struct xfs_attr_leafblock *leaf, @@ -283,6 +312,8 @@ __attr_leaf_name_local_name_count( if (!(e->flags & XFS_ATTR_LOCAL)) return 0; + if (e->flags & XFS_ATTR_PARENT) + return 0; l = xfs_attr3_leaf_name_local(leaf, i); return l->namelen; diff --git a/db/attrshort.c b/db/attrshort.c index 872d771d5..7c8ac485d 100644 --- a/db/attrshort.c +++ b/db/attrshort.c @@ -13,6 +13,7 @@ #include "attrshort.h" static int attr_sf_entry_name_count(void *obj, int startoff); +static int attr_sf_entry_pptr_count(void *obj, int startoff); static int attr_sf_entry_value_count(void *obj, int startoff); static int attr_sf_entry_value_offset(void *obj, int startoff, int idx); static int attr_shortform_list_count(void *obj, int startoff); @@ -34,6 +35,8 @@ const field_t attr_sf_hdr_flds[] = { }; #define EOFF(f) bitize(offsetof(struct xfs_attr_sf_entry, f)) +#define PPOFF(f) bitize(offsetof(struct xfs_attr_sf_entry, nameval) + \ + offsetof(struct xfs_parent_name_rec, f)) const field_t attr_sf_entry_flds[] = { { "namelen", FLDT_UINT8D, OI(EOFF(namelen)), C1, 0, TYP_NONE }, { "valuelen", FLDT_UINT8D, OI(EOFF(valuelen)), C1, 0, TYP_NONE }, @@ -49,11 +52,31 @@ const field_t attr_sf_entry_flds[] = { TYP_NONE }, { "name", FLDT_CHARNS, OI(EOFF(nameval)), attr_sf_entry_name_count, FLD_COUNT, TYP_NONE }, + { "parent_ino", FLDT_INO, OI(PPOFF(p_ino)), attr_sf_entry_pptr_count, + FLD_COUNT, TYP_INODE }, + { "parent_gen", FLDT_UINT32D, OI(PPOFF(p_gen)), attr_sf_entry_pptr_count, + FLD_COUNT, TYP_NONE }, + { "parent_diroffset", FLDT_UINT32D, OI(PPOFF(p_diroffset)), + attr_sf_entry_pptr_count, FLD_COUNT, TYP_NONE }, { "value", FLDT_CHARNS, attr_sf_entry_value_offset, attr_sf_entry_value_count, FLD_COUNT|FLD_OFFSET, TYP_NONE }, { NULL } }; +static int +attr_sf_entry_pptr_count( + void *obj, + int startoff) +{ + struct xfs_attr_sf_entry *e; + + ASSERT(bitoffs(startoff) == 0); + e = (struct xfs_attr_sf_entry *)((char *)obj + byteize(startoff)); + if (e->flags & XFS_ATTR_PARENT) + return 1; + return 0; +} + static int attr_sf_entry_name_count( void *obj, @@ -63,6 +86,8 @@ attr_sf_entry_name_count( ASSERT(bitoffs(startoff) == 0); e = (struct xfs_attr_sf_entry *)((char *)obj + byteize(startoff)); + if (e->flags & XFS_ATTR_PARENT) + return 0; return e->namelen; } From patchwork Thu Mar 16 19:27:28 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: 13178235 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 5AB15C6FD19 for ; Thu, 16 Mar 2023 19:27:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229692AbjCPT1b (ORCPT ); Thu, 16 Mar 2023 15:27:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjCPT1a (ORCPT ); Thu, 16 Mar 2023 15:27:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91108D7C00 for ; Thu, 16 Mar 2023 12:27:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2BE22620EB for ; Thu, 16 Mar 2023 19:27:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F83FC4339B; Thu, 16 Mar 2023 19:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678994848; bh=i7CXCh4FAtKDbIKENXZhNTHLf9zTdYGD7SEWRZnoTpA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=JDC1ywIXjRPn0VaL7s8wB7p0AXdK3wWD0XXrWOaeIRktar/7MhV58CVXeu7uagtDp sxJjjZYVWDpIprBGM1sp5KuJEmL65J9Yehx0eEiMbNTnuxrC3U9nArcsmsEOWEfe0/ uEkRMuU5Dw7NaBpWKXD9bOh+wTpai/QEFWWtIiFGwlF98sxs6uEIVstICbmSgOisK5 k6Z3wQHHUiLmyAZM2tlGkJECEuRI4xpwTyJ13D6YmJbXqxTufgnJlp99k65w+piwND 5dR5jbgv79XZRbZ8JGBQV/McE1vyv4ueWYBJoJz84S1++V6gbo32F0pkATQdk6G5Nq V5xlwP/0S3G8w== Date: Thu, 16 Mar 2023 12:27:28 -0700 Subject: [PATCH 6/9] xfs_db: obfuscate dirent and pptr names consistently From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167899415455.16278.13189026677929037459.stgit@frogsfrogsfrogs> In-Reply-To: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> References: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong When someone wants to perform an obfuscated metadump of a filesystem where parent pointers are enabled, we have to use the *exact* same obfuscated name for both the directory entry and the parent pointer. Instead of using an RNG to influence the obfuscated name, use the dirent inode number to start the obfuscated name. This makes them consistent, though the resulting names aren't quite so full of control characters. Signed-off-by: Darrick J. Wong --- db/metadump.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 27d1df432..bb441fbbb 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -740,12 +740,14 @@ nametable_add(xfs_dahash_t hash, int namelen, unsigned char *name) #define rol32(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) static inline unsigned char -random_filename_char(void) +random_filename_char(xfs_ino_t ino) { static unsigned char filename_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789-_"; + if (ino) + return filename_alphabet[ino % (sizeof filename_alphabet - 1)]; return filename_alphabet[random() % (sizeof filename_alphabet - 1)]; } @@ -815,6 +817,7 @@ in_lost_found( */ static void obfuscate_name( + xfs_ino_t ino, xfs_dahash_t hash, size_t name_len, unsigned char *name) @@ -842,7 +845,7 @@ obfuscate_name( * Accumulate its new hash value as we go. */ for (i = 0; i < name_len - 5; i++) { - *newp = random_filename_char(); + *newp = random_filename_char(ino); new_hash = *newp ^ rol32(new_hash, 7); newp++; } @@ -1207,7 +1210,10 @@ generate_obfuscated_name( /* Obfuscate the name (if possible) */ hash = libxfs_da_hashname(name, namelen); - obfuscate_name(hash, namelen, name); + if (xfs_has_parent(mp)) + obfuscate_name(ino, hash, namelen, name); + else + obfuscate_name(0, hash, namelen, name); /* * Make sure the name is not something already seen. If we @@ -1320,7 +1326,7 @@ obfuscate_path_components( /* last (or single) component */ namelen = strnlen((char *)comp, len); hash = libxfs_da_hashname(comp, namelen); - obfuscate_name(hash, namelen, comp); + obfuscate_name(0, hash, namelen, comp); break; } namelen = slash - (char *)comp; @@ -1331,7 +1337,7 @@ obfuscate_path_components( continue; } hash = libxfs_da_hashname(comp, namelen); - obfuscate_name(hash, namelen, comp); + obfuscate_name(0, hash, namelen, comp); comp += namelen + 1; len -= namelen + 1; } @@ -1407,10 +1413,15 @@ process_sf_attr( } if (obfuscate) { - generate_obfuscated_name(0, asfep->namelen, - &asfep->nameval[0]); - memset(&asfep->nameval[asfep->namelen], 'v', - asfep->valuelen); + if (asfep->flags & XFS_ATTR_PARENT) { + generate_obfuscated_name(cur_ino, asfep->valuelen, + &asfep->nameval[asfep->namelen]); + } else { + generate_obfuscated_name(0, asfep->namelen, + &asfep->nameval[0]); + memset(&asfep->nameval[asfep->namelen], 'v', + asfep->valuelen); + } } asfep = (struct xfs_attr_sf_entry *)((char *)asfep + @@ -1785,7 +1796,7 @@ process_attr_block( (long long)cur_ino); break; } - if (obfuscate) { + if (obfuscate && !(entry->flags & XFS_ATTR_PARENT)) { generate_obfuscated_name(0, local->namelen, &local->nameval[0]); memset(&local->nameval[local->namelen], 'v', @@ -1797,6 +1808,9 @@ process_attr_block( zlen = xfs_attr_leaf_entsize_local(nlen, vlen) - (sizeof(xfs_attr_leaf_name_local_t) - 1 + nlen + vlen); + if (obfuscate && (entry->flags & XFS_ATTR_PARENT)) + generate_obfuscated_name(cur_ino, vlen, + &local->nameval[nlen]); if (zero_stale_data) memset(&local->nameval[nlen + vlen], 0, zlen); } else { From patchwork Thu Mar 16 19:27:43 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: 13178236 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 48CEBC6FD1F for ; Thu, 16 Mar 2023 19:27:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbjCPT1q (ORCPT ); Thu, 16 Mar 2023 15:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjCPT1p (ORCPT ); Thu, 16 Mar 2023 15:27:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 364F22E0D9 for ; Thu, 16 Mar 2023 12:27:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C4AB7620EB for ; Thu, 16 Mar 2023 19:27:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29BBBC433D2; Thu, 16 Mar 2023 19:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678994864; bh=LlwwJUKG4Kjf76h58g2uNo30ACo51TmhB6fO2Ckq6U8=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=p1rWtOOe9O0t66xhWCqtyniUSaGOH7uBaZcODjTntsyBsf1xJAW1IS0P4F7OEt3/t e2O9LzmtrcJeDXTSNRkzAH8h28qO4/UpPDn4llXJ8NNDXNcmWtcC3Ml2aReI9JPzJw kDdkbBz8nzMwgEY8mYdECdU5rfLwjCnHb6FMcK0bb7hZ8aXjq/E62X+uTXN5ONPKYo k1k4dnjMVtUCOowagGXFuVAZhci+MXPnF7APw8Z5ORK8qtJRJjZOoLdcP7JesYJR7j 8s3sy/4z4K81EC8zntmSa3HQEl6lYniHsw+fpQxpdlGsXacjeXnUxixhxkK2SUevpY v2cEnIgKhpgtQ== Date: Thu, 16 Mar 2023 12:27:43 -0700 Subject: [PATCH 7/9] xfs_io: print path in path_print From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167899415468.16278.3065032307974617782.stgit@frogsfrogsfrogs> In-Reply-To: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> References: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Actually print the path string once we've bothered to construct it into a string buffer. Signed-off-by: Darrick J. Wong --- io/parent.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/io/parent.c b/io/parent.c index a6f3fa0ca..b18e02c4b 100644 --- a/io/parent.c +++ b/io/parent.c @@ -87,6 +87,8 @@ path_print( ret = path_list_to_string(path, buf + ret, len - ret); if (ret < 0) return ret; + + printf("%s\n", buf); return 0; } From patchwork Thu Mar 16 19:27:59 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: 13178237 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 758C0C6FD1F for ; Thu, 16 Mar 2023 19:28:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229541AbjCPT2G (ORCPT ); Thu, 16 Mar 2023 15:28:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbjCPT2F (ORCPT ); Thu, 16 Mar 2023 15:28:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5704977E08 for ; Thu, 16 Mar 2023 12:28:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 71F1F620DC for ; Thu, 16 Mar 2023 19:28:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA19AC4339C; Thu, 16 Mar 2023 19:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678994879; bh=9fJd78QrYq4Ag6uwblqrjwOAKaC6AYqzK5FVV+4gDPc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=r1cSQxFRgjL3uPjEtQB7BwUrR/SgX3XOlqw/vPWbW951pGkOtLlk63w+E6lLfbdih e9PO53Ncy7/KmwXonaJZsE4mR+hig/1WdHuGx1mRlDLqmXA7iWSrkOnXN/AXWmwdnN gpYcyFq9K8ewJvc9XIZatNw/0/RfprZ1/Vk0boY/vyVuOW8BdAEAyBuh+/5F8VWLKt UAj0bvp/NKCMIrORwW3l2Z0nWMvFGzjGTfWa5IlrcmlUJy32mMHUPR3TGXwyuoza3a NFG8oeK+5ZD3RQqOzlfzikLAvykw5Ywn84ONHmTUj2L7wpLrys0k0Y4vUV3iFPd/2l 1tTn2WQk6QFDw== Date: Thu, 16 Mar 2023 12:27:59 -0700 Subject: [PATCH 8/9] xfs_io: parent command is not experts-only From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167899415481.16278.10590382222132683875.stgit@frogsfrogsfrogs> In-Reply-To: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> References: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong This command isn't dangerous, so don't make it experts-only. Signed-off-by: Darrick J. Wong --- io/parent.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/io/parent.c b/io/parent.c index b18e02c4b..6af342820 100644 --- a/io/parent.c +++ b/io/parent.c @@ -250,6 +250,5 @@ parent_init(void) parent_cmd.oneline = _("print parent inodes"); parent_cmd.help = parent_help; - if (expert) - add_command(&parent_cmd); + add_command(&parent_cmd); } From patchwork Thu Mar 16 19:28:15 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: 13178239 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 939E4C6FD19 for ; Thu, 16 Mar 2023 19:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229895AbjCPT2U (ORCPT ); Thu, 16 Mar 2023 15:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbjCPT2T (ORCPT ); Thu, 16 Mar 2023 15:28:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0924B13527 for ; Thu, 16 Mar 2023 12:28:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AB9A0B8231F for ; Thu, 16 Mar 2023 19:28:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61AF5C433EF; Thu, 16 Mar 2023 19:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678994895; bh=jiwFHXZktiKxZsaRVJyoGRvgthhI+8QDBIJ5awuct/M=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=VPlaL0kecVG1Wv5DnDlL/vEybPZpr4egIKLdjLk/q5OsVEe8IVnXKkq2qTuNMANZi KOi0WECV8hIudOeIbzjBnbiz53gDEQAwS9genkTDGbk0e5SM/xybJ9Qe8VeAGyzZo9 VW/ggbW3tYDMD+fNd8JWk3lF0Pw6nrBfrsPMdRpbOjshEJv9QLtDTLqrwxYLIjzcE0 cGKsekxUBWQs3uvM73tHOg5BQaJzEpV1HJ3gfssd1BhjK6GB5QqoTU9ajVeNStbX/W 9Ylt09hMjJwa46Pfq9O8FtsZLkB845KKnOfC2bz7PBn2Y2A6W35tjt3AB9C0Lc4X1s PzyZ+cMVL9H2Q== Date: Thu, 16 Mar 2023 12:28:15 -0700 Subject: [PATCH 9/9] xfs_repair: fix incorrect dabtree hashval comparison From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167899415493.16278.8913999236747348438.stgit@frogsfrogsfrogs> In-Reply-To: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> References: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong If an xattr structure contains enough names with the same hash value to fill multiple xattr leaf blocks with names all hashing to the same value, then the dabtree nodes will contain consecutive entries with the same hash value. This causes false corruption reports in xfs_repair because it's not expecting such a huge same-hashing structure. Fix that. Signed-off-by: Darrick J. Wong --- repair/da_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repair/da_util.c b/repair/da_util.c index 7239c2e2c..b229422c8 100644 --- a/repair/da_util.c +++ b/repair/da_util.c @@ -330,7 +330,7 @@ _("%s block used/count inconsistency - %d/%hu\n"), /* * hash values monotonically increasing ??? */ - if (cursor->level[this_level].hashval >= + if (cursor->level[this_level].hashval > be32_to_cpu(nodehdr.btree[entry].hashval)) { do_warn( _("%s block hashvalue inconsistency, expected > %u / saw %u\n"),