From patchwork Tue Jul 30 00:59:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13746064 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB8AF17D2 for ; Tue, 30 Jul 2024 00:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301155; cv=none; b=RedLVbtwei9PWR6sO258KNF/Sg2lUZVfmGWx5IdPkovQbgzK8s47BgJiM9dkIP/MxtLitfn5XT9LRv2gQ6TXc1JYrEsE8m5dRGejgTQgtfhEV9N7JR9YaQmhXU8DbiBu6gnt+1RFmKb1YF+U+uXwqof0cf6h7lRfh/brZlrF3uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301155; c=relaxed/simple; bh=EjvTX0S3RP+YLnWQDTXnCPlQNTwO6TTE23xp+/AL9no=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HswsbPrcKb7NMBnZ7PEXLBbuN8XULLkum183dOQoMvpBW7Va774Ye8bHJEoYv4ikk0s+of/Abfk/X8JKDZXH5GiMZ8sAjmYqQsFPnQvUyerjQvXwR4OLEbFxyr+PSBEsR9g1vReQncVe7HskcNPyie2LVuSWkEbC4mQouck+/3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H2vdCwQl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H2vdCwQl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 843DCC32786; Tue, 30 Jul 2024 00:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722301155; bh=EjvTX0S3RP+YLnWQDTXnCPlQNTwO6TTE23xp+/AL9no=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=H2vdCwQlDP0DgkMseCzfBfgQjPY3JCWO228VIKYCSYyDMmihwc0U+cMOnXnd2C/Xm tU9oIxcdpzO58wiKEEionHe/18Fgmg5ZXohudIeZ/0VzByCbXVuo4gurBkAALvkCvy 7DFxSBDXoPCbYI0yWvPtbTktLl6UZKFVeUBn7wnDeqMCo7Q+9ibzr1N3zREawSTRip TMaL6SHctEplvoWMBRd3mmkrXyVcyO4C9aF4zNiI3gFHz7Bjuw5+RqWOfKKEAVm666 Km2LOp7cg1xgOqHdaztNB00ZrDALUXupngQ346jubFkiTX7KgfWbUs++u4dh86osvJ lX3c1wMyDC7jA== Date: Mon, 29 Jul 2024 17:59:15 -0700 Subject: [PATCH 1/8] xfs_scrub: fix missing scrub coverage for broken inodes From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <172229845945.1345965.17007008964633102257.stgit@frogsfrogsfrogs> In-Reply-To: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> References: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong If INUMBERS says that an inode is allocated, but BULKSTAT skips over the inode and BULKSTAT_SINGLE errors out when loading the inumber, there are two possibilities: One, we're racing with ifree; or two, the inode is corrupt and iget failed. When this happens, the scrub_scan_all_inodes code will insert a dummy bulkstat record with all fields zeroed except bs_ino and bs_blksize. Hence the use of i_mode switches in phase3 to schedule file content scrubbing are not entirely correct -- bs_mode==0 means "type unknown", which ought to mean "schedule all scrubbers". Unfortunately, the current code doesn't do that, so instead we schedule no content scrubs. If the broken file was actually a directory, we fail to check the directory contents for further corruptions. Found by using fuzzing with xfs/385 and core.format = 0. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- scrub/phase3.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scrub/phase3.c b/scrub/phase3.c index 9a26b9203..b03b55250 100644 --- a/scrub/phase3.c +++ b/scrub/phase3.c @@ -166,16 +166,29 @@ scrub_inode( if (error) goto out; - if (S_ISLNK(bstat->bs_mode)) { + /* + * Check file data contents, e.g. symlink and directory entries. + * + * Note: bs_mode==0 occurs when inumbers says an inode is allocated, + * bulkstat skips the inode, and bulkstat_single errors out when + * loading the inode. This could be due to racing with ifree, but it + * could be a corrupt inode. Either way, schedule all the data fork + * content scrubbers. Better to have them return -ENOENT than miss + * some coverage. + */ + if (S_ISLNK(bstat->bs_mode) || !bstat->bs_mode) { /* Check symlink contents. */ error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_SYMLINK, &alist); - } else if (S_ISDIR(bstat->bs_mode)) { + if (error) + goto out; + } + if (S_ISDIR(bstat->bs_mode) || !bstat->bs_mode) { /* Check the directory entries. */ error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_DIR, &alist); + if (error) + goto out; } - if (error) - goto out; /* Check all the extended attributes. */ error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_XATTR, &alist); From patchwork Tue Jul 30 00:59:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13746065 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A08029AF for ; Tue, 30 Jul 2024 00:59:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301171; cv=none; b=U8OZ1ahGIe9MPhL3r3vTJJj02n8Dv84Ik4h07Qd/+dDWHzI6fjLLoE2EKaRwFeYGmSnSlIok1EoDElsOOKHMT22T6dmtBaGCl31etmKj+GFiJ9t8Y6qDRKV61XWS5NTEgN6XxLvYXyV/099El9/BYJ2OkhCFDzJ/G9+XWIiowrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301171; c=relaxed/simple; bh=FnakemZQVpFRKUbGUINGT6Z7U6waQBqY+J/guphC7dI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JZlKSmLFLESSL9ObAche4DxwoLNeMTXmSDg5dwTu6ZdICoi1pG+K1Y9VloIDsTSDxSddsjf6lrPAMnEM9PqKycGzc86fcmEvZtg72HglssT9igAZykZovhT0/xg62CL0WtfqOwlGhOOeewrZIPu2ebK0zl/LP/uEdKlbzyWJovA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZhNiJgGU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZhNiJgGU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AD6EC32786; Tue, 30 Jul 2024 00:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722301171; bh=FnakemZQVpFRKUbGUINGT6Z7U6waQBqY+J/guphC7dI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ZhNiJgGU6c3wozPxL8QbpRPALKGmCBChjwiZc5r84to8poNiE3MC6HqwgRkJ3cRiw TtL5NZngDwXtdNfdM3gba3cRN+Vo6NC9wTOBsH4w0nC0ja7YOZ5l7mnEU2P6ALbDOG B74zO5ydvdK5Pulem1OWm8lmeH/RkhLd3HMZkoIlYnzqSW39fITmnTTd/EHox+teKw y3Cg3YEJfVn6YjBc3zdyLAf7kKf2QEdl5YJVRDIkoQk2co/Dyrx/oiUTSyC2aD2J5O CSmwAAzXhh8LECM/tGbEzI9lbwSzz9p5XMv2xHXGqrFJORSDNHia6bFIsg8HMX7n8E rz1SajeSVa4LQ== Date: Mon, 29 Jul 2024 17:59:30 -0700 Subject: [PATCH 2/8] xfs_scrub: collapse trivial superblock scrub helpers From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <172229845960.1345965.14663701295588505014.stgit@frogsfrogsfrogs> In-Reply-To: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> References: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Remove the trivial primary super scrub helper function since it makes tracing code paths difficult and will become annoying in the patches that follow. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- scrub/phase2.c | 9 +++++---- scrub/scrub.c | 16 +--------------- scrub/scrub.h | 3 ++- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/scrub/phase2.c b/scrub/phase2.c index 2d49c604e..ec72bb5b7 100644 --- a/scrub/phase2.c +++ b/scrub/phase2.c @@ -166,12 +166,13 @@ phase2_func( } /* - * In case we ever use the primary super scrubber to perform fs - * upgrades (followed by a full scrub), do that before we launch - * anything else. + * Scrub primary superblock. This will be useful if we ever need to + * hook a filesystem-wide pre-scrub activity (e.g. enable filesystem + * upgrades) off of the sb 0 scrubber (which currently does nothing). + * If errors occur, this function will log them and return nonzero. */ action_list_init(&alist); - ret = scrub_primary_super(ctx, &alist); + ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_SB, 0, &alist); if (ret) goto out_wq; ret = action_list_process(ctx, -1, &alist, diff --git a/scrub/scrub.c b/scrub/scrub.c index 595839130..c2e56e5f1 100644 --- a/scrub/scrub.c +++ b/scrub/scrub.c @@ -259,7 +259,7 @@ scrub_save_repair( * Returns 0 for success. If errors occur, this function will log them and * return a positive error code. */ -static int +int scrub_meta_type( struct scrub_ctx *ctx, unsigned int type, @@ -325,20 +325,6 @@ scrub_group( return 0; } -/* - * Scrub primary superblock. This will be useful if we ever need to hook - * a filesystem-wide pre-scrub activity off of the sb 0 scrubber (which - * currently does nothing). If errors occur, this function will log them and - * return nonzero. - */ -int -scrub_primary_super( - struct scrub_ctx *ctx, - struct action_list *alist) -{ - return scrub_meta_type(ctx, XFS_SCRUB_TYPE_SB, 0, alist); -} - /* Scrub each AG's header blocks. */ int scrub_ag_headers( diff --git a/scrub/scrub.h b/scrub/scrub.h index 133445e8d..fef8a5960 100644 --- a/scrub/scrub.h +++ b/scrub/scrub.h @@ -17,7 +17,6 @@ enum check_outcome { struct action_item; void scrub_report_preen_triggers(struct scrub_ctx *ctx); -int scrub_primary_super(struct scrub_ctx *ctx, struct action_list *alist); int scrub_ag_headers(struct scrub_ctx *ctx, xfs_agnumber_t agno, struct action_list *alist); int scrub_ag_metadata(struct scrub_ctx *ctx, xfs_agnumber_t agno, @@ -30,6 +29,8 @@ int scrub_fs_counters(struct scrub_ctx *ctx, struct action_list *alist); int scrub_quotacheck(struct scrub_ctx *ctx, struct action_list *alist); int scrub_nlinks(struct scrub_ctx *ctx, struct action_list *alist); int scrub_clean_health(struct scrub_ctx *ctx, struct action_list *alist); +int scrub_meta_type(struct scrub_ctx *ctx, unsigned int type, + xfs_agnumber_t agno, struct action_list *alist); bool can_scrub_fs_metadata(struct scrub_ctx *ctx); bool can_scrub_inode(struct scrub_ctx *ctx); From patchwork Tue Jul 30 00:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13746066 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A3BF8F6A for ; Tue, 30 Jul 2024 00:59:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301187; cv=none; b=lXSFIiFbNt2+qx/OOqA7M/k1AFBaHMltIC+/yBT4AiD7flJFh/fY8Ohex6w3Z8oGiQIyei4dgUoxLKLXL8phoaw0HMk/XI0UVwxutSVEpAh1AHyLyvxM/3j5NYZ92RWx3TBmhM8DRcFbHm8KjCTy/WVcbOIfLclrTZld3ddBA50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301187; c=relaxed/simple; bh=OuH3bYTUZBvFYpIe4VVgTmhI+tRRfqLDKjx73M7N8h8=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=o3Fa3DK/Jh7qApOpPXVasgRhzcPEy1wbwXfLxZ0fq9XIT6AvnquLfade0eEU7axZy1TDB4ZMBCf54Ay8iiH2B5ZiFFEID1Lfr4gQs3khUETztg+aGkz8jo7rrpkKcaG3kAVgLXOWmsYuLI8oXEyZrVt2Pe8a43EyiwE4m2Avanw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RDFnPyke; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RDFnPyke" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7247C32786; Tue, 30 Jul 2024 00:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722301186; bh=OuH3bYTUZBvFYpIe4VVgTmhI+tRRfqLDKjx73M7N8h8=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=RDFnPykeF9+akQ8tVz0iQ/V0gVbl2CqdedjLTrEqirldfoSf0N+melb/CEWBL5PBD JHkFcbe082UzLhczYh5k1mbiECGRwQaTnY8Ba5EPWkguEzDBBhiaBVk7i+u/I+Dyki twHmgOFxs4EFXQFbZNGVvpc8BtvTcWwbZjGxrgS20e4JAGUItEVtRXphYcbtGgtp1b vSyB5CE4EoMlF9SDFOv2z2OPcGDgTcUelhOVRnDDYRHy+3Tn2pc3NKBmOj05mEwBoK 0uwpEeg/xAXFyLYHSLLVU+Moe+KmUb5BvtaGylsOo/4rJwv2DnIPcrjQ9ozYdfVVe3 RTkQOXx4l40+g== Date: Mon, 29 Jul 2024 17:59:46 -0700 Subject: [PATCH 3/8] xfs_scrub: get rid of trivial fs metadata scanner helpers From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <172229845975.1345965.9617020583885754986.stgit@frogsfrogsfrogs> In-Reply-To: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> References: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Get rid of these pointless wrappers. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- scrub/phase1.c | 2 +- scrub/phase4.c | 9 +++++---- scrub/phase5.c | 15 +++++++-------- scrub/scrub.c | 36 ------------------------------------ scrub/scrub.h | 4 ---- 5 files changed, 13 insertions(+), 53 deletions(-) diff --git a/scrub/phase1.c b/scrub/phase1.c index 81b0918a1..a61e154a8 100644 --- a/scrub/phase1.c +++ b/scrub/phase1.c @@ -61,7 +61,7 @@ report_to_kernel( return 0; action_list_init(&alist); - ret = scrub_clean_health(ctx, &alist); + ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_HEALTHY, 0, &alist); if (ret) return ret; diff --git a/scrub/phase4.c b/scrub/phase4.c index 0c67abf64..d01dc89f4 100644 --- a/scrub/phase4.c +++ b/scrub/phase4.c @@ -136,14 +136,14 @@ phase4_func( goto maybe_trim; /* - * Check the summary counters early. Normally we do this during phase - * seven, but some of the cross-referencing requires fairly accurate + * Check the resource usage counters early. Normally we do this during + * phase 7, but some of the cross-referencing requires fairly accurate * summary counters. Check and try to repair them now to minimize the * chance that repairs of primary metadata fail due to secondary * metadata. If repairs fails, we'll come back during phase 7. */ action_list_init(&alist); - ret = scrub_fs_counters(ctx, &alist); + ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_FSCOUNTERS, 0, &alist); if (ret) return ret; @@ -158,7 +158,8 @@ phase4_func( return ret; if (fsgeom.sick & XFS_FSOP_GEOM_SICK_QUOTACHECK) { - ret = scrub_quotacheck(ctx, &alist); + ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_QUOTACHECK, 0, + &alist); if (ret) return ret; } diff --git a/scrub/phase5.c b/scrub/phase5.c index 940e434c3..68d35cd58 100644 --- a/scrub/phase5.c +++ b/scrub/phase5.c @@ -384,12 +384,10 @@ check_fs_label( return error; } -typedef int (*fs_scan_item_fn)(struct scrub_ctx *, struct action_list *); - struct fs_scan_item { struct action_list alist; bool *abortedp; - fs_scan_item_fn scrub_fn; + unsigned int scrub_type; }; /* Run one full-fs scan scrubber in this thread. */ @@ -414,7 +412,7 @@ fs_scan_worker( nanosleep(&tv, NULL); } - ret = item->scrub_fn(ctx, &item->alist); + ret = scrub_meta_type(ctx, item->scrub_type, 0, &item->alist); if (ret) { str_liberror(ctx, ret, _("checking fs scan metadata")); *item->abortedp = true; @@ -440,7 +438,7 @@ queue_fs_scan( struct workqueue *wq, bool *abortedp, xfs_agnumber_t nr, - fs_scan_item_fn scrub_fn) + unsigned int scrub_type) { struct fs_scan_item *item; struct scrub_ctx *ctx = wq->wq_ctx; @@ -453,7 +451,7 @@ queue_fs_scan( return ret; } action_list_init(&item->alist); - item->scrub_fn = scrub_fn; + item->scrub_type = scrub_type; item->abortedp = abortedp; ret = -workqueue_add(wq, fs_scan_worker, nr, item); @@ -485,14 +483,15 @@ run_kernel_fs_scan_scrubbers( * The nlinks scanner is much faster than quotacheck because it only * walks directories, so we start it first. */ - ret = queue_fs_scan(&wq_fs_scan, &aborted, nr, scrub_nlinks); + ret = queue_fs_scan(&wq_fs_scan, &aborted, nr, XFS_SCRUB_TYPE_NLINKS); if (ret) goto wait; if (nr_threads > 1) nr++; - ret = queue_fs_scan(&wq_fs_scan, &aborted, nr, scrub_quotacheck); + ret = queue_fs_scan(&wq_fs_scan, &aborted, nr, + XFS_SCRUB_TYPE_QUOTACHECK); if (ret) goto wait; diff --git a/scrub/scrub.c b/scrub/scrub.c index c2e56e5f1..6e857c79d 100644 --- a/scrub/scrub.c +++ b/scrub/scrub.c @@ -366,42 +366,6 @@ scrub_summary_metadata( return scrub_group(ctx, XFROG_SCRUB_GROUP_SUMMARY, 0, alist); } -/* Scrub /only/ the superblock summary counters. */ -int -scrub_fs_counters( - struct scrub_ctx *ctx, - struct action_list *alist) -{ - return scrub_meta_type(ctx, XFS_SCRUB_TYPE_FSCOUNTERS, 0, alist); -} - -/* Scrub /only/ the quota counters. */ -int -scrub_quotacheck( - struct scrub_ctx *ctx, - struct action_list *alist) -{ - return scrub_meta_type(ctx, XFS_SCRUB_TYPE_QUOTACHECK, 0, alist); -} - -/* Scrub /only/ the file link counters. */ -int -scrub_nlinks( - struct scrub_ctx *ctx, - struct action_list *alist) -{ - return scrub_meta_type(ctx, XFS_SCRUB_TYPE_NLINKS, 0, alist); -} - -/* Update incore health records if we were clean. */ -int -scrub_clean_health( - struct scrub_ctx *ctx, - struct action_list *alist) -{ - return scrub_meta_type(ctx, XFS_SCRUB_TYPE_HEALTHY, 0, alist); -} - /* How many items do we have to check? */ unsigned int scrub_estimate_ag_work( diff --git a/scrub/scrub.h b/scrub/scrub.h index fef8a5960..98819a25b 100644 --- a/scrub/scrub.h +++ b/scrub/scrub.h @@ -25,10 +25,6 @@ int scrub_fs_metadata(struct scrub_ctx *ctx, unsigned int scrub_type, struct action_list *alist); int scrub_iscan_metadata(struct scrub_ctx *ctx, struct action_list *alist); int scrub_summary_metadata(struct scrub_ctx *ctx, struct action_list *alist); -int scrub_fs_counters(struct scrub_ctx *ctx, struct action_list *alist); -int scrub_quotacheck(struct scrub_ctx *ctx, struct action_list *alist); -int scrub_nlinks(struct scrub_ctx *ctx, struct action_list *alist); -int scrub_clean_health(struct scrub_ctx *ctx, struct action_list *alist); int scrub_meta_type(struct scrub_ctx *ctx, unsigned int type, xfs_agnumber_t agno, struct action_list *alist); From patchwork Tue Jul 30 01:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13746067 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E4433211 for ; Tue, 30 Jul 2024 01:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301202; cv=none; b=YK5MzspW97bMyRg/U5B+qtrYp2VCy3z/Uz/a5+q9Yf7Bua+42GIc6+RwFsWzGc2IutQ2EykrpYWzMqs4eQkcaDkmLPSAvZPUh0Ud0abK+LO+uMgPQlV2GekRRwfxzt2riBYzEAiWAxI2qIl4rQ536GK449mqAfCZr8sU2CkREaM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301202; c=relaxed/simple; bh=1ujHTh0zoeMl5FhAd0wscA44jd3xcn9Hf3pZrUOJ1h4=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kx9siOwiraKVKTMuHl8E1gCRRHESifktFI2Nybuc9/MsHZodP2oVKoH0IL9f/XrKljnbx5CULS4wz3qUBjPnmkDK4SpNyMDgRSaVHlwScjAPZ/+/88jtfdGWxfaUm+BqPm937Hbcg70GLAfkl718AFof4SSEf6JRT+BJLgFita0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HX3tx4Qk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HX3tx4Qk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 704DFC32786; Tue, 30 Jul 2024 01:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722301202; bh=1ujHTh0zoeMl5FhAd0wscA44jd3xcn9Hf3pZrUOJ1h4=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=HX3tx4Qk66Cqb1pwr0tu2d0E/2OlFPijAQPK4cSLvfTjHoHMthaF6DOwHruUxmsl4 omc1smX857EqFBEPbauOwDkh+mHCG540aI+4gToi98/MEB25KgAXNLk/1I1uWDDQKi 4T3bQlOpYY1C50UEbf9b5Sb2mE9/yIDqHBnvUk9f38o9PGGXlpBmDiKmtYVEiWku6X E6vKVNIopuH72R8SBBZwK5TrLep9rjxfuge6/Im/+83vPu8xRqkHwFVzwsIpaVHUBy hnuuXZrIUmeaHgA7X/1/5j8DLUENgyw38dv3FJlQaKDcwuy2dZhCGiJpw3g94CjDzs L8Lhm2eTX3p3w== Date: Mon, 29 Jul 2024 18:00:01 -0700 Subject: [PATCH 4/8] xfs_scrub: split up the mustfix repairs and difficulty assessment functions From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <172229845990.1345965.3538490020328377196.stgit@frogsfrogsfrogs> In-Reply-To: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> References: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Currently, action_list_find_mustfix does two things -- it figures out which repairs must be tried during phase 2 to enable the inode scan in phase 3; and it figures out if xfs_scrub should warn about secondary and primary metadata corruption that might make repair difficult. Split these into separate functions to make each more coherent. A long time from now we'll need this to enable warnings about difficult rt repairs, but for now this is merely a code cleanup. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- scrub/phase2.c | 15 +++++++-------- scrub/repair.c | 38 +++++++++++++++++++++++++++----------- scrub/repair.h | 10 +++++++--- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/scrub/phase2.c b/scrub/phase2.c index ec72bb5b7..4c0d20a8e 100644 --- a/scrub/phase2.c +++ b/scrub/phase2.c @@ -42,9 +42,8 @@ scan_ag_metadata( struct scan_ctl *sctl = arg; struct action_list alist; struct action_list immediate_alist; - unsigned long long broken_primaries; - unsigned long long broken_secondaries; char descr[DESCR_BUFSZ]; + unsigned int difficulty; int ret; if (sctl->aborted) @@ -79,12 +78,12 @@ scan_ag_metadata( * the inobt from rmapbt data, but if the rmapbt is broken even * at this early phase then we are sunk. */ - broken_secondaries = 0; - broken_primaries = 0; - action_list_find_mustfix(&alist, &immediate_alist, - &broken_primaries, &broken_secondaries); - if (broken_secondaries && !debug_tweak_on("XFS_SCRUB_FORCE_REPAIR")) { - if (broken_primaries) + difficulty = action_list_difficulty(&alist); + action_list_find_mustfix(&alist, &immediate_alist); + + if ((difficulty & REPAIR_DIFFICULTY_SECONDARY) && + !debug_tweak_on("XFS_SCRUB_FORCE_REPAIR")) { + if (difficulty & REPAIR_DIFFICULTY_PRIMARY) str_info(ctx, descr, _("Corrupt primary and secondary block mapping metadata.")); else diff --git a/scrub/repair.c b/scrub/repair.c index 50f168d24..8ee9102ab 100644 --- a/scrub/repair.c +++ b/scrub/repair.c @@ -290,9 +290,7 @@ xfs_action_item_compare( void action_list_find_mustfix( struct action_list *alist, - struct action_list *immediate_alist, - unsigned long long *broken_primaries, - unsigned long long *broken_secondaries) + struct action_list *immediate_alist) { struct action_item *n; struct action_item *aitem; @@ -301,25 +299,43 @@ action_list_find_mustfix( if (!(aitem->flags & XFS_SCRUB_OFLAG_CORRUPT)) continue; switch (aitem->type) { - case XFS_SCRUB_TYPE_RMAPBT: - (*broken_secondaries)++; - break; case XFS_SCRUB_TYPE_FINOBT: case XFS_SCRUB_TYPE_INOBT: alist->nr--; list_move_tail(&aitem->list, &immediate_alist->list); immediate_alist->nr++; - fallthrough; + break; + } + } +} + +/* Determine if primary or secondary metadata are inconsistent. */ +unsigned int +action_list_difficulty( + const struct action_list *alist) +{ + struct action_item *aitem, *n; + unsigned int ret = 0; + + list_for_each_entry_safe(aitem, n, &alist->list, list) { + if (!(aitem->flags & XFS_SCRUB_OFLAG_CORRUPT)) + continue; + + switch (aitem->type) { + case XFS_SCRUB_TYPE_RMAPBT: + ret |= REPAIR_DIFFICULTY_SECONDARY; + break; + case XFS_SCRUB_TYPE_FINOBT: + case XFS_SCRUB_TYPE_INOBT: case XFS_SCRUB_TYPE_BNOBT: case XFS_SCRUB_TYPE_CNTBT: case XFS_SCRUB_TYPE_REFCNTBT: - (*broken_primaries)++; - break; - default: - abort(); + ret |= REPAIR_DIFFICULTY_PRIMARY; break; } } + + return ret; } /* diff --git a/scrub/repair.h b/scrub/repair.h index 6b6f64691..b61bd29c8 100644 --- a/scrub/repair.h +++ b/scrub/repair.h @@ -28,9 +28,13 @@ void action_list_discard(struct action_list *alist); void action_list_splice(struct action_list *dest, struct action_list *src); void action_list_find_mustfix(struct action_list *actions, - struct action_list *immediate_alist, - unsigned long long *broken_primaries, - unsigned long long *broken_secondaries); + struct action_list *immediate_alist); + +/* Primary metadata is corrupt */ +#define REPAIR_DIFFICULTY_PRIMARY (1U << 0) +/* Secondary metadata is corrupt */ +#define REPAIR_DIFFICULTY_SECONDARY (1U << 1) +unsigned int action_list_difficulty(const struct action_list *actions); /* * Only ask the kernel to repair this object if the kernel directly told us it From patchwork Tue Jul 30 01:00:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13746068 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4289D39B for ; Tue, 30 Jul 2024 01:00:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301218; cv=none; b=DPBHmZlLrXJJVnvufWRDh3/AWQrjj3WJ1GZ6XyV7rvtl1eC27rnkhe9PfXy2vQkWgAv34LGvsakESrmfUXzPVF9bUHaxomPsAWMqdNzAwLOlMw1cmw7beCwoFE7QZ3raAd8d1MlqOC9qhHs+cDuD4J4xyUf9GGbwwuWTuwycLWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301218; c=relaxed/simple; bh=vNDQ8mpMziVkJVUYsFyPNNJTcYmOG9oSG+CJyvWvWjY=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WdZ2xqvxLQQl/hIFimXVxfnakdy9xdaWUjXpYrrsxrY5gpbChWBKEOumbyVnPL7jFbBUwNPTzHxyYIIUYzKHjhlW8iWj7lbaCVTg3C5PxJVavYD8NVbMj30QrS3xGqfWN91Q/vU5q+kBp99STJAeY5hV2aNLMWp7qfV+YJzxvNY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HHP4Oy3P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HHP4Oy3P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18A9DC32786; Tue, 30 Jul 2024 01:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722301218; bh=vNDQ8mpMziVkJVUYsFyPNNJTcYmOG9oSG+CJyvWvWjY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=HHP4Oy3POwwzmOpP3VyBvOjL4lzaVq6evszV8/HGKnM3mebC6u6qMF76fBrkI3Xpk c5rjFRKYsh2l3oTn0ruNHWSKk/K4SsdiKxvjkceIo35yskiuqAF4WqwaIEaIIunFbV GxjVGnxpJ4MtqqZIgM5jsuWwo6nDYDOVfg3EhpmKFfh44KXV/rnnvsQbxXmbeC1f+f CMGEHzS/0P/jhxZiu+V9Ats2v/mZPBTXjD1bVRVd6194VlrXSlo1jBXkyoUS9sF+zR +UkAVXN3m02YOhgS8HcHyOvUNf6vlEueLnyx2vAg5wPpnX/9RcKVVvqSUn9ZPKwMXw Tp78muscg79hA== Date: Mon, 29 Jul 2024 18:00:17 -0700 Subject: [PATCH 5/8] xfs_scrub: add missing repair types to the mustfix and difficulty assessment From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <172229846006.1345965.2213135088155876021.stgit@frogsfrogsfrogs> In-Reply-To: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> References: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Add a few scrub types that ought to trigger a mustfix (such as AGI corruption) and all the AG space metadata to the repair difficulty assessment. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- scrub/repair.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scrub/repair.c b/scrub/repair.c index 8ee9102ab..33a803110 100644 --- a/scrub/repair.c +++ b/scrub/repair.c @@ -299,6 +299,7 @@ action_list_find_mustfix( if (!(aitem->flags & XFS_SCRUB_OFLAG_CORRUPT)) continue; switch (aitem->type) { + case XFS_SCRUB_TYPE_AGI: case XFS_SCRUB_TYPE_FINOBT: case XFS_SCRUB_TYPE_INOBT: alist->nr--; @@ -325,11 +326,17 @@ action_list_difficulty( case XFS_SCRUB_TYPE_RMAPBT: ret |= REPAIR_DIFFICULTY_SECONDARY; break; + case XFS_SCRUB_TYPE_SB: + case XFS_SCRUB_TYPE_AGF: + case XFS_SCRUB_TYPE_AGFL: + case XFS_SCRUB_TYPE_AGI: case XFS_SCRUB_TYPE_FINOBT: case XFS_SCRUB_TYPE_INOBT: case XFS_SCRUB_TYPE_BNOBT: case XFS_SCRUB_TYPE_CNTBT: case XFS_SCRUB_TYPE_REFCNTBT: + case XFS_SCRUB_TYPE_RTBITMAP: + case XFS_SCRUB_TYPE_RTSUM: ret |= REPAIR_DIFFICULTY_PRIMARY; break; } From patchwork Tue Jul 30 01:00:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13746069 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36C797464 for ; Tue, 30 Jul 2024 01:00:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301234; cv=none; b=cKRlJqcmeYtOD+wum/j4BamK1oIaES6sjojCsJ9iRZiYMoPQ6WsPuHSu3wrZC1JHYLdHzMGOGZkfTvrgxujkrFob8REJBbNRTi2wTWK1LkKwd2EW4EjcTB8rmVLfi5timMA/a6WsnRcaASB/FEwIqx/6pPWdMBZFBCs03pZjxQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301234; c=relaxed/simple; bh=8Ao5pP1V5GELqylfpEcbsYeEhkn5J0IK+EvXZLZrfFI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GneK/1ZUhuzSVKbP+BWI/MKlhK3fq78WH+hKE1jSHaLGM7gSRcmGEMV5Fz1lWF/aZ7AkBTYS5AAvwmGvDS1U6THB/rpc+UeEnOG8PpKTmEv6fDYW2nwPW+QfsonzBL503H53EAk5OXbLVrK1Meidvglx77axneWcx0CznD4RY8k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ea02mIjf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ea02mIjf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C47ABC32786; Tue, 30 Jul 2024 01:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722301233; bh=8Ao5pP1V5GELqylfpEcbsYeEhkn5J0IK+EvXZLZrfFI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Ea02mIjfNSqsZ3CdR9aX6BDgS1V5iqDMqg9aG91FJBH1gHdJsUEU7RPPZPpd9bQlL rPaMuGpA1VDV/go8z3fCwJzuPtKGumBAOnE/RT7LGZNyt7IkxidZoSocQ6nbFGt03f iH6aOriVP+yW4GF+smmCSTabpew2cIZ0Ojh5evqSoInox1voDM0SjBhx+kjGb/UcVR 2BpP8lSq/KsJrPnBV/bwtAQGkTD8znL81epA0+7AWuyiw3PBxBai1zr4kdTUQQCo87 HR7Fh0wlGzVPTtpYVpNJvw4bnQl+R0PcQ/Rm4jt9I9FsDTOB8QNL2scbk+LTl0UKGT rk1zjgxJfflWw== Date: Mon, 29 Jul 2024 18:00:33 -0700 Subject: [PATCH 6/8] xfs_scrub: any inconsistency in metadata should trigger difficulty warnings From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <172229846019.1345965.4713357950081199892.stgit@frogsfrogsfrogs> In-Reply-To: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> References: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Any inconsistency in the space metadata can be a sign that repairs will be difficult, so set off the warning if there were cross referencing problems too. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- scrub/repair.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scrub/repair.c b/scrub/repair.c index 33a803110..30817d268 100644 --- a/scrub/repair.c +++ b/scrub/repair.c @@ -319,7 +319,9 @@ action_list_difficulty( unsigned int ret = 0; list_for_each_entry_safe(aitem, n, &alist->list, list) { - if (!(aitem->flags & XFS_SCRUB_OFLAG_CORRUPT)) + if (!(aitem->flags & (XFS_SCRUB_OFLAG_CORRUPT | + XFS_SCRUB_OFLAG_XCORRUPT | + XFS_SCRUB_OFLAG_XFAIL))) continue; switch (aitem->type) { From patchwork Tue Jul 30 01:00:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13746070 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 193718BF0 for ; Tue, 30 Jul 2024 01:00:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301250; cv=none; b=Vo1mTUQ3e+AxZTl2MuuwnbBXHMRGrGIELmmT44PlOsbQsatEunT7YUfhmVDiBrfmZcq5R5pxHsAm0qtoO1tfOuWy+fEyKmYqR8l8fZmtSOR/fvD5Y/bhELPuNz1QKroZN6KitG/L131lIp2ZbIQEnLy1tdJ72ZEVwx0UQe5imUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301250; c=relaxed/simple; bh=UoRIt5/jpVq/+5A0yezf+kh4w7v+F7c1Wg7aF+bCvvE=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PxSxlbk9AECtyNYqlwlvUQ+3+Rb0LcDVyCgQoY3OW4lXS1PwEXpDv33bqrAS7fW/SxTAlAV4X6nG3rFOeOJhVZsTNyZXgt9oHShliDXcOjnwfb+FmnL1A+BsvxfelVC3K3mgiGX/6vzS5kL5ZCZXnov2QoWsoI5zOigpafU9Smk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M6sicKzf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M6sicKzf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D73AC32786; Tue, 30 Jul 2024 01:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722301249; bh=UoRIt5/jpVq/+5A0yezf+kh4w7v+F7c1Wg7aF+bCvvE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=M6sicKzfyK58PUArAL5IWePeuL3Pcub3wpcE5xzKv+KhF7nlx8IxIdllhYYPYcxun /tcA7cE4lgzme/tHO3q209496G5oijPHQy+zgF66YDFUBbf8c/Jgb0xa0xhIP60eFy oNlX+cI2YfBFs0PThHN1EEG1V2L6VXFOISDwiWGRMAWcYnujW5uDMfPREcn/KFdQQn CTSb8nsdTRa/BxgoxN6hFdpMKfscCEJHvQfZhNgE0Rx0lpBIzUdhqOu1UM99wnw6H7 eFu7ATn2DcxlGpkiGIncYo6QmP/7AzKkzkbNLt4W8ReLVFBN5bP8A2bMHnpMaq0RH8 WixRoldf8mK8w== Date: Mon, 29 Jul 2024 18:00:48 -0700 Subject: [PATCH 7/8] xfs_scrub: warn about difficult repairs to rt and quota metadata From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <172229846031.1345965.7945861310392407506.stgit@frogsfrogsfrogs> In-Reply-To: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> References: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Warn the user if there are problems with the rt or quota metadata that might make repairs difficult. For now there aren't any corruption conditions that would trigger this, but we don't want to leave a gap. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- scrub/phase2.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/scrub/phase2.c b/scrub/phase2.c index 4c0d20a8e..3e88c969b 100644 --- a/scrub/phase2.c +++ b/scrub/phase2.c @@ -31,6 +31,25 @@ struct scan_ctl { bool aborted; }; +/* Warn about the types of mutual inconsistencies that may make repairs hard. */ +static inline void +warn_repair_difficulties( + struct scrub_ctx *ctx, + unsigned int difficulty, + const char *descr) +{ + if (!(difficulty & REPAIR_DIFFICULTY_SECONDARY)) + return; + if (debug_tweak_on("XFS_SCRUB_FORCE_REPAIR")) + return; + + if (difficulty & REPAIR_DIFFICULTY_PRIMARY) + str_info(ctx, descr, _("Corrupt primary and secondary metadata.")); + else + str_info(ctx, descr, _("Corrupt secondary metadata.")); + str_info(ctx, descr, _("Filesystem might not be repairable.")); +} + /* Scrub each AG's metadata btrees. */ static void scan_ag_metadata( @@ -80,18 +99,7 @@ scan_ag_metadata( */ difficulty = action_list_difficulty(&alist); action_list_find_mustfix(&alist, &immediate_alist); - - if ((difficulty & REPAIR_DIFFICULTY_SECONDARY) && - !debug_tweak_on("XFS_SCRUB_FORCE_REPAIR")) { - if (difficulty & REPAIR_DIFFICULTY_PRIMARY) - str_info(ctx, descr, -_("Corrupt primary and secondary block mapping metadata.")); - else - str_info(ctx, descr, -_("Corrupt secondary block mapping metadata.")); - str_info(ctx, descr, -_("Filesystem might not be repairable.")); - } + warn_repair_difficulties(ctx, difficulty, descr); /* Repair (inode) btree damage. */ ret = action_list_process_or_defer(ctx, agno, &immediate_alist); @@ -115,6 +123,7 @@ scan_fs_metadata( struct action_list alist; struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx; struct scan_ctl *sctl = arg; + unsigned int difficulty; int ret; if (sctl->aborted) @@ -127,6 +136,10 @@ scan_fs_metadata( goto out; } + /* Complain about metadata corruptions that might not be fixable. */ + difficulty = action_list_difficulty(&alist); + warn_repair_difficulties(ctx, difficulty, xfrog_scrubbers[type].descr); + action_list_defer(ctx, 0, &alist); out: From patchwork Tue Jul 30 01:01:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13746071 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57EE58BF0 for ; Tue, 30 Jul 2024 01:01:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301265; cv=none; b=bpOg7few2S6itnKD3d5O5Gm6mmD27p5pCd6bkLDi1tV0NZMGWP4pwfex6fsgV5yYNQKgOssHjffXiSRXfwHGalBJ1Xi13iB0ha3XXjSTUx0UhnzHCJZZA42dZ3OxSFA7iu7F7Ugqo8X3RTXuyKmy7b/Qib/ydx3d6QE5rIIkf/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722301265; c=relaxed/simple; bh=Sl6puLHuFeA4FbJn4mNdGXD4IdYbY+1oN/VYhrSyOeE=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DTYLYOB6Za2ahZ5k5C3bR7iLTFD/0a9XfuNKVj9HmIymHUqIj0yPaLLSO/bd5GZ9Oxzz3AqmwnXeLjyfwaXsBmwDM2vljiAoFXTUTv7aNO5poC0TNN6SfoMBq9wVBsk8l9HdJBaCJtMde/JHasHT05yb+V+OODQivPt3+8C5/vo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X/6zO417; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X/6zO417" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35EBEC32786; Tue, 30 Jul 2024 01:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722301265; bh=Sl6puLHuFeA4FbJn4mNdGXD4IdYbY+1oN/VYhrSyOeE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=X/6zO417iQuqiQgSFA2cSXsWKC0FwzFZCautXt0LRmUMxROZC/S9jB5KBV7JL5gMy CjvS52h0Uos3/NUpT+gHeLBoSHRmz/ZCwNTM2v/BhohGGaxGJ10WRvu4ICn4GsoQeY kziTH8h4tpoyVgazCkUR0zXkGkmcP62oH80nOji16IA10o/BMhWRiZS7sGEJizlw4A mzuG8sAcTiEAKQblMRXPM3VLWSsBn0YX6NijsIVQmFtVXAXIirVAtbmToADu97kE4Z MR9g8k3cP2CURbZw/tkZp8JfFLl/jICWhuxsisdG4bwnm5SXnJMm634p7T3VdeG1X7 +n2FDAJhXf6oQ== Date: Mon, 29 Jul 2024 18:01:04 -0700 Subject: [PATCH 8/8] xfs_scrub: enable users to bump information messages to warnings From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <172229846046.1345965.8996034309282286750.stgit@frogsfrogsfrogs> In-Reply-To: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> References: <172229845921.1345965.6707043699978988202.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Add a -o iwarn option that enables users to specify that informational messages (such as incomplete scans, or confusing names) should be treated as warnings. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- man/man8/xfs_scrub.8 | 19 +++++++++++++++++++ scrub/common.c | 2 ++ scrub/xfs_scrub.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- scrub/xfs_scrub.h | 1 + 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/man/man8/xfs_scrub.8 b/man/man8/xfs_scrub.8 index e881ae76a..404baba69 100644 --- a/man/man8/xfs_scrub.8 +++ b/man/man8/xfs_scrub.8 @@ -85,6 +85,25 @@ Search this file for mounted filesystems instead of /etc/mtab. .B \-n Only check filesystem metadata. Do not repair or optimize anything. +.HP +.B \-o +.I subopt\c +[\c +.B =\c +.IR value ] +.BR +Override what the program might conclude about the filesystem +if left to its own devices. +.IP +The +.IR subopt ions +supported are: +.RS 1.0i +.TP +.BI iwarn +Treat informational messages as warnings. +This will result in a nonzero return code, and a higher logging level. +.RE .TP .BI \-T Print timing and memory usage information for each phase. diff --git a/scrub/common.c b/scrub/common.c index 283ac84e2..aca596487 100644 --- a/scrub/common.c +++ b/scrub/common.c @@ -110,6 +110,8 @@ __str_out( /* print strerror or format of choice but not both */ assert(!(error && format)); + if (level == S_INFO && info_is_warning) + level = S_WARN; if (level >= S_INFO) stream = stdout; diff --git a/scrub/xfs_scrub.c b/scrub/xfs_scrub.c index 50565857d..e49538ca1 100644 --- a/scrub/xfs_scrub.c +++ b/scrub/xfs_scrub.c @@ -160,6 +160,9 @@ bool is_service; /* Set to true if the kernel supports XFS_SCRUB_IFLAG_FORCE_REBUILD */ bool use_force_rebuild; +/* Should we count informational messages as warnings? */ +bool info_is_warning; + #define SCRUB_RET_SUCCESS (0) /* no problems left behind */ #define SCRUB_RET_CORRUPT (1) /* corruption remains on fs */ #define SCRUB_RET_UNOPTIMIZED (2) /* fs could be optimized */ @@ -604,6 +607,43 @@ report_outcome( # define XFS_SCRUB_HAVE_UNICODE "-" #endif +/* + * -o: user-supplied override options + */ +enum o_opt_nums { + IWARN = 0, + O_MAX_OPTS, +}; + +static char *o_opts[] = { + [IWARN] = "iwarn", + [O_MAX_OPTS] = NULL, +}; + +static void +parse_o_opts( + struct scrub_ctx *ctx, + char *p) +{ + while (*p != '\0') { + char *val; + + switch (getsubopt(&p, o_opts, &val)) { + case IWARN: + if (val) { + fprintf(stderr, + _("iwarn does not take an argument\n")); + usage(); + } + info_is_warning = true; + break; + default: + usage(); + break; + } + } +} + int main( int argc, @@ -637,7 +677,7 @@ main( pthread_mutex_init(&ctx.lock, NULL); ctx.mode = SCRUB_MODE_REPAIR; ctx.error_action = ERRORS_CONTINUE; - while ((c = getopt(argc, argv, "a:bC:de:km:nTvxV")) != EOF) { + while ((c = getopt(argc, argv, "a:bC:de:km:no:TvxV")) != EOF) { switch (c) { case 'a': ctx.max_errors = cvt_u64(optarg, 10); @@ -687,6 +727,9 @@ main( case 'n': ctx.mode = SCRUB_MODE_DRY_RUN; break; + case 'o': + parse_o_opts(&ctx, optarg); + break; case 'T': display_rusage = true; break; diff --git a/scrub/xfs_scrub.h b/scrub/xfs_scrub.h index 34d850d8d..1151ee9ff 100644 --- a/scrub/xfs_scrub.h +++ b/scrub/xfs_scrub.h @@ -22,6 +22,7 @@ extern bool stderr_isatty; extern bool stdout_isatty; extern bool is_service; extern bool use_force_rebuild; +extern bool info_is_warning; enum scrub_mode { SCRUB_MODE_DRY_RUN,