Skip to content

Commit a55e073

Browse files
author
Darrick J. Wong
committed
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> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 8e54e06 commit a55e073

1 file changed

Lines changed: 13 additions & 32 deletions

File tree

fs/xfs/scrub/reap.c

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -162,40 +162,30 @@ xrep_reap_block(
162162
struct xrep_reap_state *rs = priv;
163163
struct xfs_scrub *sc = rs->sc;
164164
struct xfs_btree_cur *cur;
165-
struct xfs_buf *agf_bp = NULL;
165+
xfs_agnumber_t agno;
166166
xfs_agblock_t agbno;
167167
bool has_other_rmap;
168168
int error;
169169

170-
ASSERT(sc->ip != NULL ||
171-
XFS_FSB_TO_AGNO(sc->mp, fsbno) == sc->sa.pag->pag_agno);
172-
trace_xrep_dispose_btree_extent(sc->mp,
173-
XFS_FSB_TO_AGNO(sc->mp, fsbno),
174-
XFS_FSB_TO_AGBNO(sc->mp, fsbno), 1);
175-
170+
agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
176171
agbno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
177-
ASSERT(XFS_FSB_TO_AGNO(sc->mp, fsbno) == sc->sa.pag->pag_agno);
178172

179-
/*
180-
* If we are repairing per-inode metadata, we need to read in the AGF
181-
* buffer. Otherwise, we're repairing a per-AG structure, so reuse
182-
* the AGF buffer that the setup functions already grabbed.
183-
*/
184-
if (sc->ip) {
185-
error = xfs_alloc_read_agf(sc->sa.pag, sc->tp, 0, &agf_bp);
186-
if (error)
187-
return error;
188-
} else {
189-
agf_bp = sc->sa.agf_bp;
173+
trace_xrep_dispose_btree_extent(sc->mp, agno, agbno, 1);
174+
175+
/* We don't support reaping file extents yet. */
176+
if (sc->ip != NULL || sc->sa.pag->pag_agno != agno) {
177+
ASSERT(0);
178+
return -EFSCORRUPTED;
190179
}
191-
cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf_bp, sc->sa.pag);
180+
181+
cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, sc->sa.agf_bp, sc->sa.pag);
192182

193183
/* Can we find any other rmappings? */
194184
error = xfs_rmap_has_other_keys(cur, agbno, 1, rs->oinfo,
195185
&has_other_rmap);
196186
xfs_btree_del_cursor(cur, error);
197187
if (error)
198-
goto out_free;
188+
return error;
199189

200190
/*
201191
* If there are other rmappings, this block is cross linked and must
@@ -211,8 +201,8 @@ xrep_reap_block(
211201
* to run xfs_repair.
212202
*/
213203
if (has_other_rmap) {
214-
error = xfs_rmap_free(sc->tp, agf_bp, sc->sa.pag, agbno, 1,
215-
rs->oinfo);
204+
error = xfs_rmap_free(sc->tp, sc->sa.agf_bp, sc->sa.pag, agbno,
205+
1, rs->oinfo);
216206
} else if (rs->resv == XFS_AG_RESV_AGFL) {
217207
xrep_block_reap_binval(sc, fsbno);
218208
error = xrep_put_freelist(sc, agbno);
@@ -221,19 +211,10 @@ xrep_reap_block(
221211
error = xfs_free_extent(sc->tp, sc->sa.pag, agbno, 1, rs->oinfo,
222212
rs->resv);
223213
}
224-
if (agf_bp != sc->sa.agf_bp)
225-
xfs_trans_brelse(sc->tp, agf_bp);
226214
if (error)
227215
return error;
228216

229-
if (sc->ip)
230-
return xfs_trans_roll_inode(&sc->tp, sc->ip);
231217
return xrep_roll_ag_trans(sc);
232-
233-
out_free:
234-
if (agf_bp != sc->sa.agf_bp)
235-
xfs_trans_brelse(sc->tp, agf_bp);
236-
return error;
237218
}
238219

239220
/* Dispose of every block of every extent in the bitmap. */

0 commit comments

Comments
 (0)