Skip to content

Commit c01868b

Browse files
author
Darrick J. Wong
committed
xfs: clean up broken eearly-exit code in the inode btree scrubber
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> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent cc12076 commit c01868b

1 file changed

Lines changed: 17 additions & 25 deletions

File tree

fs/xfs/scrub/ialloc.c

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -79,43 +79,32 @@ xchk_iallocbt_chunk_xref_other(
7979
xchk_btree_xref_set_corrupt(sc, *pcur, 0);
8080
}
8181

82-
/* Cross-reference with the other btrees. */
83-
STATIC void
84-
xchk_iallocbt_chunk_xref(
85-
struct xfs_scrub *sc,
86-
struct xfs_inobt_rec_incore *irec,
87-
xfs_agino_t agino,
88-
xfs_agblock_t agbno,
89-
xfs_extlen_t len)
90-
{
91-
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
92-
return;
93-
94-
xchk_xref_is_used_space(sc, agbno, len);
95-
xchk_iallocbt_chunk_xref_other(sc, irec, agino);
96-
xchk_xref_is_owned_by(sc, agbno, len, &XFS_RMAP_OINFO_INODES);
97-
xchk_xref_is_not_shared(sc, agbno, len);
98-
}
99-
100-
/* Is this chunk worth checking? */
82+
/* Is this chunk worth checking and cross-referencing? */
10183
STATIC bool
10284
xchk_iallocbt_chunk(
10385
struct xchk_btree *bs,
10486
struct xfs_inobt_rec_incore *irec,
10587
xfs_agino_t agino,
10688
xfs_extlen_t len)
10789
{
90+
struct xfs_scrub *sc = bs->sc;
10891
struct xfs_mount *mp = bs->cur->bc_mp;
10992
struct xfs_perag *pag = bs->cur->bc_ag.pag;
110-
xfs_agblock_t bno;
93+
xfs_agblock_t agbno;
11194

112-
bno = XFS_AGINO_TO_AGBNO(mp, agino);
95+
agbno = XFS_AGINO_TO_AGBNO(mp, agino);
11396

114-
if (!xfs_verify_agbext(pag, bno, len))
97+
if (!xfs_verify_agbext(pag, agbno, len))
11598
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
11699

117-
xchk_iallocbt_chunk_xref(bs->sc, irec, agino, bno, len);
118-
xchk_xref_is_not_cow_staging(bs->sc, bno, len);
100+
if (bs->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
101+
return false;
102+
103+
xchk_xref_is_used_space(sc, agbno, len);
104+
xchk_iallocbt_chunk_xref_other(sc, irec, agino);
105+
xchk_xref_is_owned_by(sc, agbno, len, &XFS_RMAP_OINFO_INODES);
106+
xchk_xref_is_not_shared(sc, agbno, len);
107+
xchk_xref_is_not_cow_staging(sc, agbno, len);
119108
return true;
120109
}
121110

@@ -463,7 +452,7 @@ xchk_iallocbt_rec(
463452
if (holemask & 1)
464453
holecount += XFS_INODES_PER_HOLEMASK_BIT;
465454
else if (!xchk_iallocbt_chunk(bs, &irec, agino, len))
466-
break;
455+
goto out;
467456
holemask >>= 1;
468457
agino += XFS_INODES_PER_HOLEMASK_BIT;
469458
}
@@ -473,6 +462,9 @@ xchk_iallocbt_rec(
473462
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
474463

475464
check_clusters:
465+
if (bs->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
466+
goto out;
467+
476468
error = xchk_iallocbt_check_clusters(bs, &irec);
477469
if (error)
478470
goto out;

0 commit comments

Comments
 (0)