From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 1/3] xfs: clean up broken eearly-exit code in the inode btree scrubber
Date: Sun, 02 Oct 2022 11:20:19 -0700 [thread overview]
Message-ID: <166473481968.1084372.18253504968225202018.stgit@magnolia> (raw)
In-Reply-To: <166473481949.1084372.14443532201653453226.stgit@magnolia>
From: Darrick J. Wong <djwong@kernel.org>
Corrupt inode chunks should cause us to exit early after setting the
CORRUPT flag on the scrub state. While we're at it, collapse trivial
helpers.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/scrub/ialloc.c | 52 +++++++++++++++++++++----------------------------
1 file changed, 22 insertions(+), 30 deletions(-)
diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c
index efe346ddd1b7..89eaaa12b6ae 100644
--- a/fs/xfs/scrub/ialloc.c
+++ b/fs/xfs/scrub/ialloc.c
@@ -79,44 +79,33 @@ xchk_iallocbt_chunk_xref_other(
xchk_btree_xref_set_corrupt(sc, *pcur, 0);
}
-/* Cross-reference with the other btrees. */
-STATIC void
-xchk_iallocbt_chunk_xref(
- struct xfs_scrub *sc,
+/* Is this chunk worth checking and cross-referencing? */
+STATIC bool
+xchk_iallocbt_chunk(
+ struct xchk_btree *bs,
struct xfs_inobt_rec_incore *irec,
xfs_agino_t agino,
- xfs_agblock_t agbno,
xfs_extlen_t len)
{
- if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
- return;
+ struct xfs_scrub *sc = bs->sc;
+ struct xfs_mount *mp = bs->cur->bc_mp;
+ struct xfs_perag *pag = bs->cur->bc_ag.pag;
+ xfs_agblock_t agbno;
+
+ agbno = XFS_AGINO_TO_AGBNO(mp, agino);
+ if (agbno + len <= agbno ||
+ !xfs_verify_agbno(pag, agbno) ||
+ !xfs_verify_agbno(pag, agbno + len - 1))
+ xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
+
+ if (bs->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
+ return false;
xchk_xref_is_used_space(sc, agbno, len);
xchk_iallocbt_chunk_xref_other(sc, irec, agino);
xchk_xref_is_owned_by(sc, agbno, len, &XFS_RMAP_OINFO_INODES);
xchk_xref_is_not_shared(sc, agbno, len);
-}
-
-/* Is this chunk worth checking? */
-STATIC bool
-xchk_iallocbt_chunk(
- struct xchk_btree *bs,
- struct xfs_inobt_rec_incore *irec,
- xfs_agino_t agino,
- xfs_extlen_t len)
-{
- struct xfs_mount *mp = bs->cur->bc_mp;
- struct xfs_perag *pag = bs->cur->bc_ag.pag;
- xfs_agblock_t bno;
-
- bno = XFS_AGINO_TO_AGBNO(mp, agino);
- if (bno + len <= bno ||
- !xfs_verify_agbno(pag, bno) ||
- !xfs_verify_agbno(pag, bno + len - 1))
- xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
-
- xchk_iallocbt_chunk_xref(bs->sc, irec, agino, bno, len);
- xchk_xref_is_not_cow_staging(bs->sc, bno, len);
+ xchk_xref_is_not_cow_staging(sc, agbno, len);
return true;
}
@@ -486,7 +475,7 @@ xchk_iallocbt_rec(
if (holemask & 1)
holecount += XFS_INODES_PER_HOLEMASK_BIT;
else if (!xchk_iallocbt_chunk(bs, &irec, agino, len))
- break;
+ goto out;
holemask >>= 1;
agino += XFS_INODES_PER_HOLEMASK_BIT;
}
@@ -496,6 +485,9 @@ xchk_iallocbt_rec(
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
check_clusters:
+ if (bs->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
+ goto out;
+
error = xchk_iallocbt_check_clusters(bs, &irec);
if (error)
goto out;
next prev parent reply other threads:[~2022-10-02 18:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-02 18:20 [PATCHSET v23.1 0/3] xfs: detect incorrect gaps in inode btree Darrick J. Wong
2022-10-02 18:20 ` Darrick J. Wong [this message]
2022-10-02 18:20 ` [PATCH 2/3] xfs: directly cross-reference the inode btrees with each other Darrick J. Wong
2022-10-02 18:20 ` [PATCH 3/3] xfs: convert xfs_ialloc_has_inodes_at_extent to return keyfill scan results Darrick J. Wong
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=166473481968.1084372.18253504968225202018.stgit@magnolia \
--to=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).