From: "Darrick J. Wong" <djwong@kernel.org>
To: sandeen@sandeen.net, david@fromorbit.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 4/3] xfs_repair: always rewrite secondary supers when needsrepair is set
Date: Mon, 16 May 2022 11:11:32 -0700 [thread overview]
Message-ID: <YoKT1DRtLpY62WLR@magnolia> (raw)
In-Reply-To: <165176674590.248791.17672675617466150793.stgit@magnolia>
From: Darrick J. Wong <djwong@kernel.org>
Dave Chinner complained about xfs_scrub failures coming from xfs/158.
That test induces xfs_repair to fail while upgrading a filesystem to
have the inobtcount feature, and then restarts xfs_repair to finish the
upgrade. When the second xfs_repair run starts, it will find that the
primary super has NEEDSREPAIR set, along with whatever new feature that
we were trying to add to the filesystem.
From there, repair completes the upgrade in much the same manner as the
first repair run would have, with one big exception -- it forgets to set
features_changed to trigger rewriting of the secondary supers at the end
of repair. This results in discrepancies between the supers:
# XFS_REPAIR_FAIL_AFTER_PHASE=2 xfs_repair -c inobtcount=1 /dev/sdf
Phase 1 - find and verify superblock...
Phase 2 - using internal log
- zero log...
- scan filesystem freespace and inode maps...
- found root inode chunk
Adding inode btree counts to filesystem.
Killed
# xfs_repair /dev/sdf
Phase 1 - find and verify superblock...
Phase 2 - using internal log
- zero log...
- scan filesystem freespace and inode maps...
clearing needsrepair flag and regenerating metadata
bad inobt block count 0, saw 1
bad finobt block count 0, saw 1
bad inobt block count 0, saw 1
bad finobt block count 0, saw 1
bad inobt block count 0, saw 1
bad finobt block count 0, saw 1
bad inobt block count 0, saw 1
bad finobt block count 0, saw 1
- found root inode chunk
Phase 3 - for each AG...
- scan and clear agi unlinked lists...
- process known inodes and perform inode discovery...
- agno = 0
- agno = 1
- agno = 2
- agno = 3
- process newly discovered inodes...
Phase 4 - check for duplicate blocks...
- setting up duplicate extent list...
- check for inodes claiming duplicate blocks...
- agno = 1
- agno = 2
- agno = 0
- agno = 3
Phase 5 - rebuild AG headers and trees...
- reset superblock...
Phase 6 - check inode connectivity...
- resetting contents of realtime bitmap and summary inodes
- traversing filesystem ...
- traversal finished ...
- moving disconnected inodes to lost+found ...
Phase 7 - verify and correct link counts...
done
# xfs_db -c 'sb 0' -c 'print' -c 'sb 1' -c 'print' /dev/sdf | \
egrep '(features_ro_compat|features_incompat)'
features_ro_compat = 0xd
features_incompat = 0xb
features_ro_compat = 0x5
features_incompat = 0xb
Curiously, re-running xfs_repair will not trigger any warnings about the
featureset mismatch between the primary and secondary supers. xfs_scrub
immediately notices, which is what causes xfs/158 to fail.
This discrepancy doesn't happen when the upgrade completes successfully
in a single repair run, so we need to teach repair to rewrite the
secondaries at the end of repair any time needsrepair was set.
Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
| 8 ++++++++
1 file changed, 8 insertions(+)
--git a/repair/agheader.c b/repair/agheader.c
index d8f912f2..7da5641b 100644
--- a/repair/agheader.c
+++ b/repair/agheader.c
@@ -460,6 +460,14 @@ secondary_sb_whack(
else
do_warn(
_("would clear needsrepair flag and regenerate metadata\n"));
+ /*
+ * If needsrepair is set on the primary super, there's
+ * a possibility that repair crashed during an upgrade.
+ * Set features_changed to ensure that the secondary
+ * supers are rewritten with the new feature bits once
+ * we've finished the upgrade.
+ */
+ features_changed = true;
} else {
/*
* Quietly clear needsrepair on the secondary supers as
prev parent reply other threads:[~2022-05-16 18:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 16:05 [PATCHSET 0/3] xfs_repair: various small fixes Darrick J. Wong
2022-05-05 16:05 ` [PATCH 1/3] xfs_repair: detect v5 featureset mismatches in secondary supers Darrick J. Wong
2022-05-12 19:02 ` Eric Sandeen
2022-05-12 19:13 ` Darrick J. Wong
2022-05-16 8:11 ` Dave Chinner
2022-05-16 17:59 ` Darrick J. Wong
2022-05-05 16:05 ` [PATCH 2/3] xfs_repair: improve checking of existing rmap and refcount btrees Darrick J. Wong
2022-05-12 19:39 ` Eric Sandeen
2022-05-12 20:54 ` Darrick J. Wong
2022-05-05 16:06 ` [PATCH 3/3] xfs_repair: check the ftype of dot and dotdot directory entries Darrick J. Wong
2022-05-12 20:36 ` Eric Sandeen
2022-05-16 18:11 ` Darrick J. Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YoKT1DRtLpY62WLR@magnolia \
--to=djwong@kernel.org \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox