From patchwork Wed Nov 23 17:09:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13053983 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 1B099C4332F for ; Wed, 23 Nov 2022 17:09:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239069AbiKWRJl (ORCPT ); Wed, 23 Nov 2022 12:09:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239187AbiKWRJV (ORCPT ); Wed, 23 Nov 2022 12:09:21 -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 6AC6D59165 for ; Wed, 23 Nov 2022 09:09:03 -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 12BD7B821BD for ; Wed, 23 Nov 2022 17:09:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C063AC433D7; Wed, 23 Nov 2022 17:09:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669223340; bh=U4ieHGKygnK1z78Bj35y4xBKtb4VWdommV5vatijyWE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ff0EPrIi58jgjJW4dpgvo5iYSrtlZlevia9tuDNFIH+Uk2/wUssVX/mNVVE3jpK67 MinPND/ITbBPYoZDzvFcZE83RlJRPdXHs4f04z70dTWJFkXr8PYDXL7TdGkit/+HPE LK2/ZltDJdaqa6A6d+7GqYtFY9rU8xjW5o0+6GBtDbpgQp4hBwVRP9YmvtaqPnXO8o R0jn0USpUoHxa66JptbPBMhcBJ+uzEiBc06G0+td0YXI7vc2fHEF+RWzzPpycpseme FZxBbtM2TR/kn8IRXDpqUb0i3N6qyTO+b9WHa1PFPi6fMKWe+QdEYdWbCGc6Li32Go qqIZH1HaHPVXA== Subject: [PATCH 1/9] libxfs: consume the xfs_warn mountpoint argument From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 23 Nov 2022 09:09:00 -0800 Message-ID: <166922334040.1572664.6558090785236386982.stgit@magnolia> In-Reply-To: <166922333463.1572664.2330601679911464739.stgit@magnolia> References: <166922333463.1572664.2330601679911464739.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 Fix these warnings because xfs_warn doesn't do anything in userspace: xfs_alloc.c: In function ‘xfs_alloc_get_rec’: xfs_alloc.c:246:34: warning: unused variable ‘mp’ [-Wunused-variable] 246 | struct xfs_mount *mp = cur->bc_mp; | ^~ Signed-off-by: Darrick J. Wong --- libxfs/libxfs_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 883b22948bb..ad4b9475832 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -125,7 +125,7 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; #define xfs_info(mp,fmt,args...) cmn_err(CE_CONT, _(fmt), ## args) #define xfs_notice(mp,fmt,args...) cmn_err(CE_NOTE, _(fmt), ## args) -#define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN, _(fmt), ## args) +#define xfs_warn(mp,fmt,args...) cmn_err((mp) ? CE_WARN : CE_WARN, _(fmt), ## args) #define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT, _(fmt), ## args) #define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT, _(fmt), ## args) From patchwork Wed Nov 23 17:09:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13053984 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 B5D35C433FE for ; Wed, 23 Nov 2022 17:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239188AbiKWRJr (ORCPT ); Wed, 23 Nov 2022 12:09:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239215AbiKWRJX (ORCPT ); Wed, 23 Nov 2022 12:09:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6968732BB0 for ; Wed, 23 Nov 2022 09:09:07 -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 E752D61DEB for ; Wed, 23 Nov 2022 17:09:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 525DBC433C1; Wed, 23 Nov 2022 17:09:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669223346; bh=4ENKD6CYJIlcq3tpEQi7XM8tDGHhneeXslf5YQUx1gM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=krTvEBHOq2D2ThJD9eI7y3e57w4i1bBIqSY2zIoiu8JyafEhJZBjuV032mm9ln7U0 gRNw3NprR3eyqS3HPy1kUpHZPUWcwOhofEf9VMduHv1wWht6HM6LwdGc73xrJ+cPLC xbM44vnkAh1ik7b2NMS1MEpCXsdqxlellWDjWLKO3yt3mfIqnZqeiHEYwF5pV1I6iJ 4yZU3+qOYhBVjyT3LaUD2EIoWg/Us8KONqg//rT0V7MA6MLXcthrqAvvyjcJo87tvU ki3yKs/z0b/9YbQELlkmsGUKYVtyXy3HLACXw5z8B9lhCjr9QDdWpgLvyWK1S6qwNo h5zva0Ac1A1pw== Subject: [PATCH 2/9] misc: add static to various sourcefile-local functions From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 23 Nov 2022 09:09:05 -0800 Message-ID: <166922334592.1572664.17864426624261290357.stgit@magnolia> In-Reply-To: <166922333463.1572664.2330601679911464739.stgit@magnolia> References: <166922333463.1572664.2330601679911464739.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 These helper functions are not referenced outside the source file they're defined in. Mark them static. Signed-off-by: Darrick J. Wong --- db/namei.c | 2 +- io/pread.c | 2 +- mkfs/xfs_mkfs.c | 2 +- repair/xfs_repair.c | 2 +- scrub/inodes.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/namei.c b/db/namei.c index 4186d262940..00e8c8dc6d5 100644 --- a/db/namei.c +++ b/db/namei.c @@ -441,7 +441,7 @@ list_leafdir( } /* Read the directory, display contents. */ -int +static int listdir( struct xfs_inode *dp) { diff --git a/io/pread.c b/io/pread.c index 458a78b83c3..0f1d8b97b05 100644 --- a/io/pread.c +++ b/io/pread.c @@ -113,7 +113,7 @@ alloc_buffer( return 0; } -void +static void __dump_buffer( void *buf, off64_t offset, diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 9dd0e79c6ba..e219ec166da 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3964,7 +3964,7 @@ cfgfile_parse_ini( return 1; } -void +static void cfgfile_parse( struct cli_params *cli) { diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index c94671d8d18..871b428d7de 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -750,7 +750,7 @@ check_fs_vs_host_sectsize( } /* Clear needsrepair after a successful repair run. */ -void +static void clear_needsrepair( struct xfs_mount *mp) { diff --git a/scrub/inodes.c b/scrub/inodes.c index ffe7eb33441..78f0914b8d9 100644 --- a/scrub/inodes.c +++ b/scrub/inodes.c @@ -163,7 +163,7 @@ alloc_ichunk( return 0; } -int +static int render_ino_from_bulkstat( struct scrub_ctx *ctx, char *buf, From patchwork Wed Nov 23 17:09:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13053985 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 E30AFC433FE for ; Wed, 23 Nov 2022 17:09:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239206AbiKWRJu (ORCPT ); Wed, 23 Nov 2022 12:09:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239224AbiKWRJX (ORCPT ); Wed, 23 Nov 2022 12:09:23 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F2B527177 for ; Wed, 23 Nov 2022 09:09:15 -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 sin.source.kernel.org (Postfix) with ESMTPS id AFE39CE2497 for ; Wed, 23 Nov 2022 17:09:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC9E8C433C1; Wed, 23 Nov 2022 17:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669223352; bh=PsFSUpI4Dtk5T88JogAd7uG6ZwUeo4HDquPdeZ/XI+8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=diywI7/VYHkg+Y5puM+a0zrtWVnZExRYrIJaFkLmbTlJ5RRcgkB1w3Dzrc6PjyRzb a6hUVEZ9TnyFWracibocCezA1w7+vSSQKTiy8p89P/Zic2TdCMEz7/Y0DWbT4sqguD 30bUMFu2b2sCKeh1poCkeMiPB597EWVWeSQRz1ici6/GRBvUynIxzQjPX6yYZQdTXp oR+Dyjt4ziraPux3PSbinqK6hATZWF7KOQMF2ZPP9R/Ck6yCJPFc4bNQNE8OGBO/GG QsQXsYvnUJTU8FpHcmJMS+Po+6pX7LQXC9T12N00ZnjvnILYhJZUb4nW/bmkBAxfeG 03wNIR189P49g== Subject: [PATCH 3/9] misc: add missing includes From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 23 Nov 2022 09:09:11 -0800 Message-ID: <166922335148.1572664.9580374600448542934.stgit@magnolia> In-Reply-To: <166922333463.1572664.2330601679911464739.stgit@magnolia> References: <166922333463.1572664.2330601679911464739.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 Add missing #include directives so that the compiler can typecheck functions against their declarations. IOWs, -Wmissing-declarations found some things. Signed-off-by: Darrick J. Wong --- libfrog/linux.c | 1 + libxfs/util.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libfrog/linux.c b/libfrog/linux.c index a45d99ab5bb..0d9bd355fc3 100644 --- a/libfrog/linux.c +++ b/libfrog/linux.c @@ -12,6 +12,7 @@ #include "platform_defs.h" #include "xfs.h" #include "init.h" +#include "libfrog/platform.h" extern char *progname; static int max_block_alignment; diff --git a/libxfs/util.c b/libxfs/util.c index a41d50c4a7f..6525f63de00 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -28,6 +28,7 @@ #include "xfs_da_format.h" #include "xfs_da_btree.h" #include "xfs_dir2_priv.h" +#include "xfs_health.h" /* * Calculate the worst case log unit reservation for a given superblock From patchwork Wed Nov 23 17:09:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13053986 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 F01D8C4332F for ; Wed, 23 Nov 2022 17:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239222AbiKWRJy (ORCPT ); Wed, 23 Nov 2022 12:09:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239233AbiKWRJZ (ORCPT ); Wed, 23 Nov 2022 12:09:25 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 011AC5B859 for ; Wed, 23 Nov 2022 09:09:19 -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 B2AAFB821BC for ; Wed, 23 Nov 2022 17:09:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BFCBC433D6; Wed, 23 Nov 2022 17:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669223357; bh=DpRD44229X9amFgdS4JeB2pQvuQtapjqy1Yi7iG+D2c=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=UlZfvnD1o0YR00U4ejebbTshUZRPty46jOPsaXdOpQ6sltNohTmunFFwEtwUSvwuQ tjSmePWo/Mk4RvrloK15HZSua7yiWhPeYyfoaaGM21IWckutRCHx1RXyo7SnJ/rr8d 4fcrmiTujvxPVttGfhYVwDQQg51DRPfkspznffpOieCnl5n62sLVROi1zoMvvXtny1 fvcJcJw7FdrO5UGPCPxwzugIk7ogvbVPXoR5JoiohPk7Cz8Fixt2FMpis6+TJxu0ZM +AyOffJIPnxLhyhFB5VZ53ePAYvWk2uN+td8Ov4dAv+8r6nc97e+SPJsTgk6C9A41X 2CCX53D9SiXKQ== Subject: [PATCH 4/9] xfs_db: fix octal conversion logic From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 23 Nov 2022 09:09:17 -0800 Message-ID: <166922335710.1572664.4478914425268206526.stgit@magnolia> In-Reply-To: <166922333463.1572664.2330601679911464739.stgit@magnolia> References: <166922333463.1572664.2330601679911464739.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 Fix the backwards boolean logic here, which results in weird behavior. # xfs_db -x -c /dev/sda xfs_db> print fname fname = "\000\000\000\000\000\000\000\000\000\000\000\000" xfs_db> write fname "mo\0h5o" fname = "mo\005o\000\000\000\000\000\000\000\000" xfs_db> print fname fname = "mo\005o\000\000\000\000\000\000\000\000" Notice that we passed in octal-zero, 'h', '5', 'o', but the fs label is set to octal-5, 'o' because of the incorrect loop logic. -Wlogical-op found this one. Signed-off-by: Darrick J. Wong --- db/write.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/write.c b/db/write.c index 70cb0518d01..6c67e839a9e 100644 --- a/db/write.c +++ b/db/write.c @@ -479,7 +479,7 @@ convert_oct( if (arg[count] == '\0') break; - if ((arg[count] < '0') && (arg[count] > '7')) + if ((arg[count] < '0') || (arg[count] > '7')) break; } @@ -553,7 +553,7 @@ convert_arg( /* do octal conversion */ if (*ostr == '\\') { - if (*(ostr + 1) >= '0' || *(ostr + 1) <= '7') { + if (*(ostr + 1) >= '0' && *(ostr + 1) <= '7') { ret = convert_oct(ostr + 1, &octval); *rbuf++ = octval; ostr += ret + 1; From patchwork Wed Nov 23 17:09:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13053987 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 AEB64C3A59F for ; Wed, 23 Nov 2022 17:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238880AbiKWRJ4 (ORCPT ); Wed, 23 Nov 2022 12:09:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239241AbiKWRJZ (ORCPT ); Wed, 23 Nov 2022 12:09:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10EFFDF58 for ; Wed, 23 Nov 2022 09:09:24 -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 9F93861DF7 for ; Wed, 23 Nov 2022 17:09:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 084E7C433D6; Wed, 23 Nov 2022 17:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669223363; bh=W1HI7Nt87cDLU6WLIkKoYP6/6fdQbPDPlie8zv59qQE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=m244ulAaImaN3bfyvjwBRH4O/rZAQ0vyLYfysDZs/WQe7Oe3qeSFerey4s1FZYXhx XyFP2WVxj4Cpr+LlbjyWZ52c2zzZ3BwcVqs8fdnFwmz73tsJFovr3EhBiaVXuxeiHT JB7rkJAXY9E5yX1gmmbPDIuDjNNueOY7nOJNe27l0VXI1LBVnflEzVRTg0o+vMOTSI jBzBJriQmAmFTeXukV/eBEIM0ERILVPjSE3L16nr2nH8uoxhQYniI2nuB9nB76H6Yk oNnWJ4Vn5bavH48qbcvmxrWYhhLvTv9v4dthY6SHiAe16/ZKf95QlqQERaH8ngkUV6 NzYG6IT64T7kA== Subject: [PATCH 5/9] xfs_db: fix printing of reverse mapping record blockcounts From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 23 Nov 2022 09:09:22 -0800 Message-ID: <166922336259.1572664.1318580687689818471.stgit@magnolia> In-Reply-To: <166922333463.1572664.2330601679911464739.stgit@magnolia> References: <166922333463.1572664.2330601679911464739.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 FLDT_EXTLEN is the correct type for a 32-bit block count within an AG; FLDT_REXTLEN is the type for a 21-bit file mapping block count. This code should have been using the first type, not the second. Signed-off-by: Darrick J. Wong --- db/btblock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/btblock.c b/db/btblock.c index 24c6566980f..c563fb0389a 100644 --- a/db/btblock.c +++ b/db/btblock.c @@ -727,7 +727,7 @@ const field_t rmapbt_key_flds[] = { const field_t rmapbt_rec_flds[] = { { "startblock", FLDT_AGBLOCK, OI(RMAPBT_STARTBLOCK_BITOFF), C1, 0, TYP_DATA }, - { "blockcount", FLDT_REXTLEN, OI(RMAPBT_BLOCKCOUNT_BITOFF), C1, 0, TYP_NONE }, + { "blockcount", FLDT_EXTLEN, OI(RMAPBT_BLOCKCOUNT_BITOFF), C1, 0, TYP_NONE }, { "owner", FLDT_INT64D, OI(RMAPBT_OWNER_BITOFF), C1, 0, TYP_NONE }, { "offset", FLDT_RFILEOFFD, OI(RMAPBT_OFFSET_BITOFF), C1, 0, TYP_NONE }, { "extentflag", FLDT_REXTFLG, OI(RMAPBT_EXNTFLAG_BITOFF), C1, 0, From patchwork Wed Nov 23 17:09:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13053988 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 018CDC43217 for ; Wed, 23 Nov 2022 17:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239231AbiKWRJz (ORCPT ); Wed, 23 Nov 2022 12:09:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238880AbiKWRJa (ORCPT ); Wed, 23 Nov 2022 12:09:30 -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 946D62BE for ; Wed, 23 Nov 2022 09:09:29 -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 2E0AF61DF7 for ; Wed, 23 Nov 2022 17:09:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8585BC433D6; Wed, 23 Nov 2022 17:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669223368; bh=YLBHViVo1lCSrGBAz2g/JBFs4xFcSEqvEJAYmdnpdH4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=KdFIk0BopVJto/76M//TLDI1kjXBosQxyJKTKweBenEs3hHs6PUXKFFvZbHSy6GiV b4nRu61SN775G9YKM+xll1DWR5wPuPJbZSYcCuVogwBkk+Q69OR7kaIyoId+UOa3al aMF+apbl4ueYQz/E6K2oIyHL7iyUybr2WllDw4sQusbCblbpxfuytKlxU0yHKdiqZd WSKeqAKmiQ1drWeQmnxfbrNu0gom9mNZgYkc2mmdHvGnmjRJpMEr4xdxbdylk8vBpM xgIn4Hw39oEJOl93BdmW3gnPQ0g+aPkHZEDrAWEJEq/nKZLzRbiDhVeIRUIFR+eMSp 7Jc+kX/ymyomg== Subject: [PATCH 6/9] xfs_repair: don't crash on unknown inode parents in dry run mode From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 23 Nov 2022 09:09:28 -0800 Message-ID: <166922336819.1572664.6577394686238048762.stgit@magnolia> In-Reply-To: <166922333463.1572664.2330601679911464739.stgit@magnolia> References: <166922333463.1572664.2330601679911464739.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 Fuzz testing of directory block headers exposed a debug assertion vector in xfs_repair. In normal (aka fixit) mode, if a single-block directory has a totally trashed block, repair will zap the entire directory. Phase 4 ignores any dirents pointing to the zapped directory, phase 6 ignores the freed directory, and everything is good. However, in dry run mode, we don't actually free the inode. Phase 4 still ignores any dirents pointing to the zapped directory, but phase 6 thinks the inode is still live and tries to walk it. xfs_repair doesn't know of any parents for the zapped directory and so trips the assertion. The assertion is critical for fixit mode because we need all the parent information to ensure consistency of the directory tree. In dry run mode we don't care, because we only have to print inconsistencies and return 1. Worse yet, (our) customers file bugs when xfs_repair crashes during a -n scan, so this will generate support calls. Make everyone's life easier by downgrading the assertion to a warning if we're running in dry run mode. Found by fuzzing bhdr.hdr.bno = zeroes in xfs/471. Signed-off-by: Darrick J. Wong --- repair/phase6.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/repair/phase6.c b/repair/phase6.c index 1f9f8dee46c..0be2c9c9705 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -1836,7 +1836,14 @@ longform_dir2_entry_check_data( continue; } parent = get_inode_parent(irec, ino_offset); - ASSERT(parent != 0); + if (parent == 0) { + if (no_modify) + do_warn( + _("unknown parent for inode %" PRIu64 "\n"), + inum); + else + ASSERT(parent != 0); + } junkit = 0; /* * bump up the link counts in parent and child From patchwork Wed Nov 23 17:09:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13053989 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 18238C433FE for ; Wed, 23 Nov 2022 17:09:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236775AbiKWRJ5 (ORCPT ); Wed, 23 Nov 2022 12:09:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239045AbiKWRJh (ORCPT ); Wed, 23 Nov 2022 12:09:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ACD9A1A7 for ; Wed, 23 Nov 2022 09:09:35 -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 B95E161DF7 for ; Wed, 23 Nov 2022 17:09:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2209CC433D7; Wed, 23 Nov 2022 17:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669223374; bh=C02f+124bgIFis8q5eS522GNV2U+J7xszLHVhTiC5CA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=SEJU4PMwyHEzYMze0z/uuDhKfxOivjpfrohnubSciAlk6h+K7GzYlJPaCBCRyt88G dsVnSIcArVKfeGloZsi0nKz6zwnL+YWuofSWw7vkQFcKWz1bb2/W/0DvKdqKJ4izvH hI0m89JzIMbS9bwpnV5x90uxJ3NIGAQGhYCsA+jlmgnrh6hCKNTXhyNQRqpQX0xlQ1 xN3N3GVAXcBLR792NDwN+fQqR72DMq7fTnP19MBVcvZjuv3QJpfmoKPqhJ3DnIIOO9 jwhdMc8Uu27SHAjQXqb6nyEz+AsLnoKYmq8IWHYOr9glpHXM/tOa2NMIQYiIMtf9Pg VlLL8hQxfIFEg== Subject: [PATCH 7/9] xfs_repair: retain superblock buffer to avoid write hook deadlock From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 23 Nov 2022 09:09:33 -0800 Message-ID: <166922337370.1572664.296015052733868024.stgit@magnolia> In-Reply-To: <166922333463.1572664.2330601679911464739.stgit@magnolia> References: <166922333463.1572664.2330601679911464739.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 Every now and then I experience the following deadlock in xfs_repair when I'm running the offline repair fuzz tests: #0 futex_wait (private=0, expected=2, futex_word=0x55555566df70) at ../sysdeps/nptl/futex-internal.h:146 #1 __GI___lll_lock_wait (futex=futex@entry=0x55555566df70, private=0) at ./nptl/lowlevellock.c:49 #2 lll_mutex_lock_optimized (mutex=0x55555566df70) at ./nptl/pthread_mutex_lock.c:48 #3 ___pthread_mutex_lock (mutex=mutex@entry=0x55555566df70) at ./nptl/pthread_mutex_lock.c:93 #4 cache_shake (cache=cache@entry=0x55555566de60, priority=priority@entry=2, purge=purge@entry=false) at cache.c:231 #5 cache_node_get (cache=cache@entry=0x55555566de60, key=key@entry=0x7fffe55e01b0, nodep=nodep@entry=0x7fffe55e0168) at cache.c:452 #6 __cache_lookup (key=key@entry=0x7fffe55e01b0, flags=0, bpp=bpp@entry=0x7fffe55e0228) at rdwr.c:405 #7 libxfs_getbuf_flags (btp=0x55555566de00, blkno=0, len=, flags=, bpp=0x7fffe55e0228) at rdwr.c:457 #8 libxfs_buf_read_map (btp=0x55555566de00, map=map@entry=0x7fffe55e0280, nmaps=nmaps@entry=1, flags=flags@entry=0, bpp=bpp@entry=0x7fffe55e0278, ops=0x5555556233e0 ) at rdwr.c:704 #9 libxfs_buf_read (ops=, bpp=0x7fffe55e0278, flags=0, numblks=, blkno=0, target=) at /storage/home/djwong/cdev/work/xfsprogs/build-x86_64/libxfs/libxfs_io.h:195 #10 libxfs_getsb (mp=mp@entry=0x7fffffffd690) at rdwr.c:162 #11 force_needsrepair (mp=0x7fffffffd690) at xfs_repair.c:924 #12 repair_capture_writeback (bp=) at xfs_repair.c:1000 #13 libxfs_bwrite (bp=0x7fffe011e530) at rdwr.c:869 #14 cache_shake (cache=cache@entry=0x55555566de60, priority=priority@entry=2, purge=purge@entry=false) at cache.c:240 #15 cache_node_get (cache=cache@entry=0x55555566de60, key=key@entry=0x7fffe55e0470, nodep=nodep@entry=0x7fffe55e0428) at cache.c:452 #16 __cache_lookup (key=key@entry=0x7fffe55e0470, flags=1, bpp=bpp@entry=0x7fffe55e0538) at rdwr.c:405 #17 libxfs_getbuf_flags (btp=0x55555566de00, blkno=12736, len=, flags=, bpp=0x7fffe55e0538) at rdwr.c:457 #18 __libxfs_buf_get_map (btp=, map=map@entry=0x7fffe55e05b0, nmaps=, flags=flags@entry=1, bpp=bpp@entry=0x7fffe55e0538) at rdwr.c:501 #19 libxfs_buf_get_map (btp=, map=map@entry=0x7fffe55e05b0, nmaps=, flags=flags@entry=1, bpp=bpp@entry=0x7fffe55e0538) at rdwr.c:525 #20 pf_queue_io (args=args@entry=0x5555556722c0, map=map@entry=0x7fffe55e05b0, nmaps=, flag=flag@entry=11) at prefetch.c:124 #21 pf_read_bmbt_reclist (args=0x5555556722c0, rp=, numrecs=78) at prefetch.c:220 #22 pf_scan_lbtree (dbno=dbno@entry=1211, level=level@entry=1, isadir=isadir@entry=1, args=args@entry=0x5555556722c0, func=0x55555557f240 ) at prefetch.c:298 #23 pf_read_btinode (isadir=1, dino=, args=0x5555556722c0) at prefetch.c:385 #24 pf_read_inode_dirs (args=args@entry=0x5555556722c0, bp=bp@entry=0x7fffdc023790) at prefetch.c:459 #25 pf_read_inode_dirs (bp=, args=0x5555556722c0) at prefetch.c:411 #26 pf_batch_read (args=args@entry=0x5555556722c0, which=which@entry=PF_PRIMARY, buf=buf@entry=0x7fffd001d000) at prefetch.c:609 #27 pf_io_worker (param=0x5555556722c0) at prefetch.c:673 #28 start_thread (arg=) at ./nptl/pthread_create.c:442 #29 clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81 From this stack trace, we see that xfs_repair's prefetch module is getting some xfs_buf objects ahead of initiating a read (#19). The buffer cache has hit its limit, so it calls cache_shake (#14) to free some unused xfs_bufs. The buffer it finds is a dirty buffer, so it calls libxfs_bwrite to flush it out to disk, which in turn invokes the buffer write hook that xfs_repair set up in 3b7667cb to mark the ondisk filesystem's superblock as NEEDSREPAIR until repair actually completes. Unfortunately, the NEEDSREPAIR handler itself needs to grab the superblock buffer, so it makes another call into the buffer cache (#9), which sees that the cache is full and tries to shake it(#4). Hence we deadlock on cm_mutex because shaking is not reentrant. Fix this by retaining a reference to the superblock buffer when possible so that the writeback hook doesn't have to access the buffer cache to set NEEDSREPAIR. Fixes: 3b7667cb ("xfs_repair: set NEEDSREPAIR the first time we write to a filesystem") Signed-off-by: Darrick J. Wong --- libxfs/libxfs_api_defs.h | 2 + libxfs/libxfs_io.h | 1 + libxfs/rdwr.c | 8 +++++ repair/phase2.c | 8 +++++ repair/protos.h | 1 + repair/xfs_repair.c | 75 ++++++++++++++++++++++++++++++++++++++++------ 6 files changed, 86 insertions(+), 9 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 2716a731bf9..f8efcce777b 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -53,9 +53,11 @@ #define xfs_buf_delwri_submit libxfs_buf_delwri_submit #define xfs_buf_get libxfs_buf_get #define xfs_buf_get_uncached libxfs_buf_get_uncached +#define xfs_buf_lock libxfs_buf_lock #define xfs_buf_read libxfs_buf_read #define xfs_buf_read_uncached libxfs_buf_read_uncached #define xfs_buf_relse libxfs_buf_relse +#define xfs_buf_unlock libxfs_buf_unlock #define xfs_bunmapi libxfs_bunmapi #define xfs_bwrite libxfs_bwrite #define xfs_calc_dquots_per_chunk libxfs_calc_dquots_per_chunk diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h index 9c0e2704d11..fae86427201 100644 --- a/libxfs/libxfs_io.h +++ b/libxfs/libxfs_io.h @@ -226,6 +226,7 @@ xfs_buf_hold(struct xfs_buf *bp) } void xfs_buf_lock(struct xfs_buf *bp); +void xfs_buf_unlock(struct xfs_buf *bp); int libxfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen, int flags, struct xfs_buf **bpp); diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 20e0793c2f6..d5aad3ea210 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -384,6 +384,14 @@ xfs_buf_lock( pthread_mutex_lock(&bp->b_lock); } +void +xfs_buf_unlock( + struct xfs_buf *bp) +{ + if (use_xfs_buf_lock) + pthread_mutex_unlock(&bp->b_lock); +} + static int __cache_lookup( struct xfs_bufkey *key, diff --git a/repair/phase2.c b/repair/phase2.c index 56a39bb4562..2ada95aefd1 100644 --- a/repair/phase2.c +++ b/repair/phase2.c @@ -370,6 +370,14 @@ phase2( } else do_log(_("Phase 2 - using internal log\n")); + /* + * Now that we've set up the buffer cache the way we want it, try to + * grab our own reference to the primary sb so that the hooks will not + * have to call out to the buffer cache. + */ + if (mp->m_buf_writeback_fn) + retain_primary_sb(mp); + /* Zero log if applicable */ do_log(_(" - zero log...\n")); diff --git a/repair/protos.h b/repair/protos.h index 03ebae14138..83e471ff2ad 100644 --- a/repair/protos.h +++ b/repair/protos.h @@ -16,6 +16,7 @@ int get_sb(xfs_sb_t *sbp, xfs_off_t off, int size, xfs_agnumber_t agno); +int retain_primary_sb(struct xfs_mount *mp); void write_primary_sb(xfs_sb_t *sbp, int size); diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 871b428d7de..ff29bea9743 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -749,6 +749,63 @@ check_fs_vs_host_sectsize( } } +/* + * If we set up a writeback function to set NEEDSREPAIR while the filesystem is + * dirty, there's a chance that calling libxfs_getsb could deadlock the buffer + * cache while trying to get the primary sb buffer if the first non-sb write to + * the filesystem is the result of a cache shake. Retain a reference to the + * primary sb buffer to avoid all that. + */ +static struct xfs_buf *primary_sb_bp; /* buffer for superblock */ + +int +retain_primary_sb( + struct xfs_mount *mp) +{ + int error; + + error = -libxfs_buf_read(mp->m_ddev_targp, XFS_SB_DADDR, + XFS_FSS_TO_BB(mp, 1), 0, &primary_sb_bp, + &xfs_sb_buf_ops); + if (error) + return error; + + libxfs_buf_unlock(primary_sb_bp); + return 0; +} + +static void +drop_primary_sb(void) +{ + if (!primary_sb_bp) + return; + + libxfs_buf_lock(primary_sb_bp); + libxfs_buf_relse(primary_sb_bp); + primary_sb_bp = NULL; +} + +static int +get_primary_sb( + struct xfs_mount *mp, + struct xfs_buf **bpp) +{ + int error; + + *bpp = NULL; + + if (!primary_sb_bp) { + error = retain_primary_sb(mp); + if (error) + return error; + } + + libxfs_buf_lock(primary_sb_bp); + xfs_buf_hold(primary_sb_bp); + *bpp = primary_sb_bp; + return 0; +} + /* Clear needsrepair after a successful repair run. */ static void clear_needsrepair( @@ -769,15 +826,14 @@ clear_needsrepair( do_warn( _("Cannot clear needsrepair due to flush failure, err=%d.\n"), error); - return; + goto drop; } /* Clear needsrepair from the superblock. */ - bp = libxfs_getsb(mp); - if (!bp || bp->b_error) { + error = get_primary_sb(mp, &bp); + if (error) { do_warn( - _("Cannot clear needsrepair from primary super, err=%d.\n"), - bp ? bp->b_error : ENOMEM); + _("Cannot clear needsrepair from primary super, err=%d.\n"), error); } else { mp->m_sb.sb_features_incompat &= ~XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR; @@ -786,6 +842,8 @@ clear_needsrepair( } if (bp) libxfs_buf_relse(bp); +drop: + drop_primary_sb(); } static void @@ -808,11 +866,10 @@ force_needsrepair( xfs_sb_version_needsrepair(&mp->m_sb)) return; - bp = libxfs_getsb(mp); - if (!bp || bp->b_error) { + error = get_primary_sb(mp, &bp); + if (error) { do_log( - _("couldn't get superblock to set needsrepair, err=%d\n"), - bp ? bp->b_error : ENOMEM); + _("couldn't get superblock to set needsrepair, err=%d\n"), error); } else { /* * It's possible that we need to set NEEDSREPAIR before we've From patchwork Wed Nov 23 17:09:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13053990 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 EF69EC47088 for ; Wed, 23 Nov 2022 17:09:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239254AbiKWRJ5 (ORCPT ); Wed, 23 Nov 2022 12:09:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239151AbiKWRJn (ORCPT ); Wed, 23 Nov 2022 12:09:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C1931148 for ; Wed, 23 Nov 2022 09:09:42 -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 1444CB821C3 for ; Wed, 23 Nov 2022 17:09:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABD5BC433C1; Wed, 23 Nov 2022 17:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669223379; bh=UnYzZ0ec4Vjv7i5xCeQMX6VqdQ0wjQ+8KkO8tCwc8Yc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=AtPEwJEn7BO3UZegO/X52tq0FY0gTIQ3cHBxwRRdMQUocT70Tv7c7YGIDxMB0BOzd II3U5jF8YaLN3ZO+nCJkwGVVaxjxzv9ghJZeLq5Kqa7yuIo5aPR+1Hmfm3YaCH0GCw 5rTDvwlQbtyp20eLgOfj5hIxh5dxQHvBM58yh0qJe6084qQyfOp+ybpTmf3Qu683nr UvgrjnA5FwJQ+k4WU0/5lmRkWLxaWDY9764HRJ5g/6f883LK5GO6AYa2z4aU3RkRNi LPh/OxJRlOxiH9Vykb4sKZbHy+2WmrpsZV9j0kscnpSBqEpULz2TnISXsLgVOFsone qPx0XNgW336vw== Subject: [PATCH 8/9] xfs_{db,repair}: fix XFS_REFC_COW_START usage From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 23 Nov 2022 09:09:39 -0800 Message-ID: <166922337929.1572664.8324902697406402249.stgit@magnolia> In-Reply-To: <166922333463.1572664.2330601679911464739.stgit@magnolia> References: <166922333463.1572664.2330601679911464739.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 This is really a bit field stashed in the upper bit of the rc_startblock field, so change its usage patterns to use masking instead of integer addition and subtraction. Signed-off-by: Darrick J. Wong --- db/check.c | 4 ++-- repair/scan.c | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/db/check.c b/db/check.c index 680edf1f9ed..bb27ce58053 100644 --- a/db/check.c +++ b/db/check.c @@ -4848,8 +4848,8 @@ scanfunc_refcnt( char *msg; agbno = be32_to_cpu(rp[i].rc_startblock); - if (agbno >= XFS_REFC_COWFLAG) { - agbno -= XFS_REFC_COWFLAG; + if (agbno & XFS_REFC_COWFLAG) { + agbno &= ~XFS_REFC_COWFLAG; msg = _( "leftover CoW extent (%u/%u) len %u\n"); } else { diff --git a/repair/scan.c b/repair/scan.c index 859a6e69374..7b72013153d 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -1367,6 +1367,7 @@ _("%s btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), pag = libxfs_perag_get(mp, agno); for (i = 0; i < numrecs; i++) { + enum xfs_refc_domain domain; xfs_agblock_t b, agb, end; xfs_extlen_t len; xfs_nlink_t nr; @@ -1374,16 +1375,23 @@ _("%s btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), b = agb = be32_to_cpu(rp[i].rc_startblock); len = be32_to_cpu(rp[i].rc_blockcount); nr = be32_to_cpu(rp[i].rc_refcount); - if (b >= XFS_REFC_COWFLAG && nr != 1) + + if (b & XFS_REFC_COWFLAG) { + domain = XFS_REFC_DOMAIN_COW; + agb &= ~XFS_REFC_COWFLAG; + } else { + domain = XFS_REFC_DOMAIN_SHARED; + } + + if (domain == XFS_REFC_DOMAIN_COW && nr != 1) do_warn( _("leftover CoW extent has incorrect refcount in record %u of %s btree block %u/%u\n"), i, name, agno, bno); if (nr == 1) { - if (agb < XFS_REFC_COWFLAG) + if (domain != XFS_REFC_DOMAIN_COW) do_warn( _("leftover CoW extent has invalid startblock in record %u of %s btree block %u/%u\n"), i, name, agno, bno); - agb -= XFS_REFC_COWFLAG; } end = agb + len; @@ -1438,15 +1446,17 @@ _("extent (%u/%u) len %u claimed, state is %d\n"), } /* Is this record mergeable with the last one? */ - if (refc_priv->last_rec.rc_startblock + - refc_priv->last_rec.rc_blockcount == b && + if (refc_priv->last_rec.rc_domain == domain && + refc_priv->last_rec.rc_startblock + + refc_priv->last_rec.rc_blockcount == agb && refc_priv->last_rec.rc_refcount == nr) { do_warn( _("record %d in block (%u/%u) of %s tree should be merged with previous record\n"), i, agno, bno, name); refc_priv->last_rec.rc_blockcount += len; } else { - refc_priv->last_rec.rc_startblock = b; + refc_priv->last_rec.rc_domain = domain; + refc_priv->last_rec.rc_startblock = agb; refc_priv->last_rec.rc_blockcount = len; refc_priv->last_rec.rc_refcount = nr; } From patchwork Wed Nov 23 17:09:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13053991 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 ADB55C4332F for ; Wed, 23 Nov 2022 17:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239204AbiKWRKN (ORCPT ); Wed, 23 Nov 2022 12:10:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239203AbiKWRJt (ORCPT ); Wed, 23 Nov 2022 12:09:49 -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 26BD7E096 for ; Wed, 23 Nov 2022 09:09: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 ams.source.kernel.org (Postfix) with ESMTPS id 8F27BB821BD for ; Wed, 23 Nov 2022 17:09:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C2B3C433C1; Wed, 23 Nov 2022 17:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669223385; bh=FAu8G0kfzCjH7k1IfZGiULMVlK06TpbvBGV6svNGnes=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ZImhUPYpmKZPgn7SrWqj5anF7YFu+2PeXC700aDkZVn2EWA649eSRopibkEjiv/3g I0mPkD3mneEV8+lwZwQwX8im97QPY5f+2/93Q8FmIvfRkM09U7fzm17wes+dzEg4C8 5x4LvWfdOUwZngVds2oiiTz3zXQmpAo9HvV0gD7hvM994IlXhWhdTBkkZlTT+Fi+fg Cjx+q6HlK5zs3W7Nh+igQH3ryWTrs0BrntMydMtATiARZNJbwSZEc0fwaccuz0C7zS QGlUkpH1B8cyFoAFOQaPxGGKU71ul96lmgqxjQ7tm8tRHExfZPdVmz0xlfd7MXMsph hkYa1hX2HGmiQ== Subject: [PATCH 9/9] mkfs.xfs: add mkfs config file for the 6.1 LTS kernel From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 23 Nov 2022 09:09:44 -0800 Message-ID: <166922338486.1572664.12822037256588012126.stgit@magnolia> In-Reply-To: <166922333463.1572664.2330601679911464739.stgit@magnolia> References: <166922333463.1572664.2330601679911464739.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 Add a new mkfs config file to reflect the default featureset for the 6.1 LTS release. Signed-off-by: Darrick J. Wong --- mkfs/Makefile | 3 ++- mkfs/lts_6.1.conf | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 mkfs/lts_6.1.conf diff --git a/mkfs/Makefile b/mkfs/Makefile index 55d9362f6b6..6c7ee186fa2 100644 --- a/mkfs/Makefile +++ b/mkfs/Makefile @@ -14,7 +14,8 @@ CFGFILES = \ lts_4.19.conf \ lts_5.4.conf \ lts_5.10.conf \ - lts_5.15.conf + lts_5.15.conf \ + lts_6.1.conf LLDLIBS += $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBRT) $(LIBBLKID) \ $(LIBUUID) $(LIBINIH) $(LIBURCU) $(LIBPTHREAD) diff --git a/mkfs/lts_6.1.conf b/mkfs/lts_6.1.conf new file mode 100644 index 00000000000..08bbe9f3c7e --- /dev/null +++ b/mkfs/lts_6.1.conf @@ -0,0 +1,14 @@ +# V5 features that were the mkfs defaults when the upstream Linux 6.1 LTS +# kernel was released at the end of 2022. + +[metadata] +nrext64=0 +bigtime=1 +crc=1 +finobt=1 +inobtcount=1 +reflink=1 +rmapbt=0 + +[inode] +sparse=1