Commit 8389f3ff authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: skip scrub xref if corruption already noted

Don't bother looking for cross-referencing problems if the metadata is
already corrupt or we've already found a cross-referencing problem.
Since we added a helper function for flags testing, convert existing
users to use it.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent c9fbd7bb
...@@ -70,7 +70,7 @@ xfs_scrub_allocbt_xref_other( ...@@ -70,7 +70,7 @@ xfs_scrub_allocbt_xref_other(
pcur = &sc->sa.cnt_cur; pcur = &sc->sa.cnt_cur;
else else
pcur = &sc->sa.bno_cur; pcur = &sc->sa.bno_cur;
if (!*pcur) if (!*pcur || xfs_scrub_skip_xref(sc->sm))
return; return;
error = xfs_alloc_lookup_le(*pcur, agbno, len, &has_otherrec); error = xfs_alloc_lookup_le(*pcur, agbno, len, &has_otherrec);
...@@ -172,7 +172,7 @@ xfs_scrub_xref_is_used_space( ...@@ -172,7 +172,7 @@ xfs_scrub_xref_is_used_space(
bool is_freesp; bool is_freesp;
int error; int error;
if (!sc->sa.bno_cur) if (!sc->sa.bno_cur || xfs_scrub_skip_xref(sc->sm))
return; return;
error = xfs_alloc_has_record(sc->sa.bno_cur, agbno, len, &is_freesp); error = xfs_alloc_has_record(sc->sa.bno_cur, agbno, len, &is_freesp);
......
...@@ -174,7 +174,7 @@ xfs_scrub_bmap_xref_rmap( ...@@ -174,7 +174,7 @@ xfs_scrub_bmap_xref_rmap(
unsigned long long rmap_end; unsigned long long rmap_end;
uint64_t owner; uint64_t owner;
if (!info->sc->sa.rmap_cur) if (!info->sc->sa.rmap_cur || xfs_scrub_skip_xref(info->sc->sm))
return; return;
if (info->whichfork == XFS_COW_FORK) if (info->whichfork == XFS_COW_FORK)
......
...@@ -737,6 +737,10 @@ xfs_scrub_should_check_xref( ...@@ -737,6 +737,10 @@ xfs_scrub_should_check_xref(
int *error, int *error,
struct xfs_btree_cur **curpp) struct xfs_btree_cur **curpp)
{ {
/* No point in xref if we already know we're corrupt. */
if (xfs_scrub_skip_xref(sc->sm))
return false;
if (*error == 0) if (*error == 0)
return true; return true;
......
...@@ -145,4 +145,14 @@ int xfs_scrub_setup_inode_contents(struct xfs_scrub_context *sc, ...@@ -145,4 +145,14 @@ int xfs_scrub_setup_inode_contents(struct xfs_scrub_context *sc,
struct xfs_inode *ip, unsigned int resblks); struct xfs_inode *ip, unsigned int resblks);
void xfs_scrub_buffer_recheck(struct xfs_scrub_context *sc, struct xfs_buf *bp); void xfs_scrub_buffer_recheck(struct xfs_scrub_context *sc, struct xfs_buf *bp);
/*
* Don't bother cross-referencing if we already found corruption or cross
* referencing discrepancies.
*/
static inline bool xfs_scrub_skip_xref(struct xfs_scrub_metadata *sm)
{
return sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT |
XFS_SCRUB_OFLAG_XCORRUPT);
}
#endif /* __XFS_SCRUB_COMMON_H__ */ #endif /* __XFS_SCRUB_COMMON_H__ */
...@@ -387,7 +387,8 @@ xfs_scrub_iallocbt_xref_rmap_btreeblks( ...@@ -387,7 +387,8 @@ xfs_scrub_iallocbt_xref_rmap_btreeblks(
int error; int error;
if (!sc->sa.ino_cur || !sc->sa.rmap_cur || if (!sc->sa.ino_cur || !sc->sa.rmap_cur ||
(xfs_sb_version_hasfinobt(&sc->mp->m_sb) && !sc->sa.fino_cur)) (xfs_sb_version_hasfinobt(&sc->mp->m_sb) && !sc->sa.fino_cur) ||
xfs_scrub_skip_xref(sc->sm))
return; return;
/* Check that we saw as many inobt blocks as the rmap says. */ /* Check that we saw as many inobt blocks as the rmap says. */
...@@ -424,7 +425,7 @@ xfs_scrub_iallocbt_xref_rmap_inodes( ...@@ -424,7 +425,7 @@ xfs_scrub_iallocbt_xref_rmap_inodes(
xfs_filblks_t blocks; xfs_filblks_t blocks;
int error; int error;
if (!sc->sa.rmap_cur) if (!sc->sa.rmap_cur || xfs_scrub_skip_xref(sc->sm))
return; return;
/* Check that we saw as many inode blocks as the rmap knows about. */ /* Check that we saw as many inode blocks as the rmap knows about. */
...@@ -496,7 +497,7 @@ xfs_scrub_xref_inode_check( ...@@ -496,7 +497,7 @@ xfs_scrub_xref_inode_check(
bool has_inodes; bool has_inodes;
int error; int error;
if (!(*icur)) if (!(*icur) || xfs_scrub_skip_xref(sc->sm))
return; return;
error = xfs_ialloc_has_inodes_at_extent(*icur, agbno, len, &has_inodes); error = xfs_ialloc_has_inodes_at_extent(*icur, agbno, len, &has_inodes);
......
...@@ -448,7 +448,7 @@ xfs_scrub_inode_xref_finobt( ...@@ -448,7 +448,7 @@ xfs_scrub_inode_xref_finobt(
int has_record; int has_record;
int error; int error;
if (!sc->sa.fino_cur) if (!sc->sa.fino_cur || xfs_scrub_skip_xref(sc->sm))
return; return;
agino = XFS_INO_TO_AGINO(sc->mp, ino); agino = XFS_INO_TO_AGINO(sc->mp, ino);
...@@ -491,6 +491,9 @@ xfs_scrub_inode_xref_bmap( ...@@ -491,6 +491,9 @@ xfs_scrub_inode_xref_bmap(
xfs_filblks_t acount; xfs_filblks_t acount;
int error; int error;
if (xfs_scrub_skip_xref(sc->sm))
return;
/* Walk all the extents to check nextents/naextents/nblocks. */ /* Walk all the extents to check nextents/naextents/nblocks. */
error = xfs_bmap_count_blocks(sc->tp, sc->ip, XFS_DATA_FORK, error = xfs_bmap_count_blocks(sc->tp, sc->ip, XFS_DATA_FORK,
&nextents, &count); &nextents, &count);
......
...@@ -310,7 +310,7 @@ xfs_scrub_refcountbt_xref_rmap( ...@@ -310,7 +310,7 @@ xfs_scrub_refcountbt_xref_rmap(
struct xfs_scrub_refcnt_frag *n; struct xfs_scrub_refcnt_frag *n;
int error; int error;
if (!sc->sa.rmap_cur) if (!sc->sa.rmap_cur || xfs_scrub_skip_xref(sc->sm))
return; return;
/* Cross-reference with the rmapbt to confirm the refcount. */ /* Cross-reference with the rmapbt to confirm the refcount. */
...@@ -404,7 +404,7 @@ xfs_scrub_refcount_xref_rmap( ...@@ -404,7 +404,7 @@ xfs_scrub_refcount_xref_rmap(
xfs_filblks_t blocks; xfs_filblks_t blocks;
int error; int error;
if (!sc->sa.rmap_cur) if (!sc->sa.rmap_cur || xfs_scrub_skip_xref(sc->sm))
return; return;
/* Check that we saw as many refcbt blocks as the rmap knows about. */ /* Check that we saw as many refcbt blocks as the rmap knows about. */
...@@ -460,7 +460,7 @@ xfs_scrub_xref_is_cow_staging( ...@@ -460,7 +460,7 @@ xfs_scrub_xref_is_cow_staging(
int has_refcount; int has_refcount;
int error; int error;
if (!sc->sa.refc_cur) if (!sc->sa.refc_cur || xfs_scrub_skip_xref(sc->sm))
return; return;
/* Find the CoW staging extent. */ /* Find the CoW staging extent. */
...@@ -504,7 +504,7 @@ xfs_scrub_xref_is_not_shared( ...@@ -504,7 +504,7 @@ xfs_scrub_xref_is_not_shared(
bool shared; bool shared;
int error; int error;
if (!sc->sa.refc_cur) if (!sc->sa.refc_cur || xfs_scrub_skip_xref(sc->sm))
return; return;
error = xfs_refcount_has_record(sc->sa.refc_cur, agbno, len, &shared); error = xfs_refcount_has_record(sc->sa.refc_cur, agbno, len, &shared);
......
...@@ -66,7 +66,7 @@ xfs_scrub_rmapbt_xref_refc( ...@@ -66,7 +66,7 @@ xfs_scrub_rmapbt_xref_refc(
bool is_unwritten; bool is_unwritten;
int error; int error;
if (!sc->sa.refc_cur) if (!sc->sa.refc_cur || xfs_scrub_skip_xref(sc->sm))
return; return;
non_inode = XFS_RMAP_NON_INODE_OWNER(irec->rm_owner); non_inode = XFS_RMAP_NON_INODE_OWNER(irec->rm_owner);
...@@ -207,7 +207,7 @@ xfs_scrub_xref_check_owner( ...@@ -207,7 +207,7 @@ xfs_scrub_xref_check_owner(
bool has_rmap; bool has_rmap;
int error; int error;
if (!sc->sa.rmap_cur) if (!sc->sa.rmap_cur || xfs_scrub_skip_xref(sc->sm))
return; return;
error = xfs_rmap_record_exists(sc->sa.rmap_cur, bno, len, oinfo, error = xfs_rmap_record_exists(sc->sa.rmap_cur, bno, len, oinfo,
...@@ -250,7 +250,7 @@ xfs_scrub_xref_has_no_owner( ...@@ -250,7 +250,7 @@ xfs_scrub_xref_has_no_owner(
bool has_rmap; bool has_rmap;
int error; int error;
if (!sc->sa.rmap_cur) if (!sc->sa.rmap_cur || xfs_scrub_skip_xref(sc->sm))
return; return;
error = xfs_rmap_has_record(sc->sa.rmap_cur, bno, len, &has_rmap); error = xfs_rmap_has_record(sc->sa.rmap_cur, bno, len, &has_rmap);
......
...@@ -110,6 +110,9 @@ xfs_scrub_xref_is_used_rt_space( ...@@ -110,6 +110,9 @@ xfs_scrub_xref_is_used_rt_space(
bool is_free; bool is_free;
int error; int error;
if (xfs_scrub_skip_xref(sc->sm))
return;
xfs_ilock(sc->mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP); xfs_ilock(sc->mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP);
error = xfs_rtalloc_extent_is_free(sc->mp, sc->tp, fsbno, len, error = xfs_rtalloc_extent_is_free(sc->mp, sc->tp, fsbno, len,
&is_free); &is_free);
......
...@@ -450,8 +450,8 @@ xfs_scrub_metadata( ...@@ -450,8 +450,8 @@ xfs_scrub_metadata(
} else if (error) } else if (error)
goto out_teardown; goto out_teardown;
if (sc.sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT | if (sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT |
XFS_SCRUB_OFLAG_XCORRUPT)) XFS_SCRUB_OFLAG_XCORRUPT))
xfs_alert_ratelimited(mp, "Corruption detected during scrub."); xfs_alert_ratelimited(mp, "Corruption detected during scrub.");
out_teardown: out_teardown:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment