summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-09-01 10:40:17 -0700
committerDarrick J. Wong <djwong@kernel.org>2021-10-22 16:40:33 -0700
commit85a611aa2456f5fbec5a0c0f5ebb073233df81ae (patch)
tree690b745b2e4ce9a6cdb14c07ecfb8b30cac815af
parent5a14297eca8eda4a222610bb32279704d0ec30ef (diff)
xfs: only allow reaping of per-AG blocks in xrep_reap_extents
Now that we've refactored btree cursors to require the caller to pass in a perag structure, there are numerous problems in xrep_reap_extents if it's being called to reap extents for an inode metadata repair. We don't have any repair functions that can do that, so drop the support for now. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r--fs/xfs/scrub/repair.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index 2f16b6900f5e..95f48bbcf1a7 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -524,7 +524,6 @@ xrep_reap_block(
enum xfs_ag_resv_type resv)
{
struct xfs_btree_cur *cur;
- struct xfs_buf *agf_bp = NULL;
xfs_agnumber_t agno;
xfs_agblock_t agbno;
bool has_other_rmap;
@@ -533,25 +532,19 @@ xrep_reap_block(
agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
agbno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
- /*
- * If we are repairing per-inode metadata, we need to read in the AGF
- * buffer. Otherwise, we're repairing a per-AG structure, so reuse
- * the AGF buffer that the setup functions already grabbed.
- */
- if (sc->ip) {
- error = xfs_alloc_read_agf(sc->mp, sc->tp, agno, 0, &agf_bp);
- if (error)
- return error;
- } else {
- agf_bp = sc->sa.agf_bp;
+ /* We don't support reaping file extents yet. */
+ if (sc->ip != NULL || sc->sa.pag->pag_agno != agno) {
+ ASSERT(0);
+ return -EFSCORRUPTED;
}
- cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf_bp, sc->sa.pag);
+
+ cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, sc->sa.agf_bp, sc->sa.pag);
/* Can we find any other rmappings? */
error = xfs_rmap_has_other_keys(cur, agbno, 1, oinfo, &has_other_rmap);
xfs_btree_del_cursor(cur, error);
if (error)
- goto out_free;
+ return error;
/*
* If there are other rmappings, this block is cross linked and must
@@ -567,8 +560,8 @@ xrep_reap_block(
* to run xfs_repair.
*/
if (has_other_rmap) {
- error = xfs_rmap_free(sc->tp, agf_bp, sc->sa.pag, agbno, 1,
- oinfo);
+ error = xfs_rmap_free(sc->tp, sc->sa.agf_bp, sc->sa.pag, agbno,
+ 1, oinfo);
} else if (resv == XFS_AG_RESV_AGFL) {
xrep_reap_invalidate_block(sc, fsbno);
error = xrep_put_freelist(sc, agbno);
@@ -576,19 +569,10 @@ xrep_reap_block(
xrep_reap_invalidate_block(sc, fsbno);
error = xfs_free_extent(sc->tp, fsbno, 1, oinfo, resv);
}
- if (agf_bp != sc->sa.agf_bp)
- xfs_trans_brelse(sc->tp, agf_bp);
if (error)
return error;
- if (sc->ip)
- return xfs_trans_roll_inode(&sc->tp, sc->ip);
return xrep_roll_ag_trans(sc);
-
-out_free:
- if (agf_bp != sc->sa.agf_bp)
- xfs_trans_brelse(sc->tp, agf_bp);
- return error;
}
/* Dispose of every block of every extent in the bitmap. */