Skip to content

Commit 77a1396

Browse files
author
Darrick J. Wong
committed
xfs: rearrange xrep_reap_block to make future code flow easier
Rearrange the logic inside xrep_reap_block to make it more obvious that crosslinked metadata blocks are handled differently. Add a couple of tracepoints so that we can tell what's going on at the end of a btree rebuild operation. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 5fee784 commit 77a1396

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

fs/xfs/scrub/agheader_repair.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,13 +646,13 @@ xrep_agfl_fill(
646646
xfs_fsblock_t fsbno = start;
647647
int error;
648648

649+
trace_xrep_agfl_insert(sc->sa.pag, XFS_FSB_TO_AGBNO(sc->mp, start),
650+
len);
651+
649652
while (fsbno < start + len && af->fl_off < af->flcount)
650653
af->agfl_bno[af->fl_off++] =
651654
cpu_to_be32(XFS_FSB_TO_AGBNO(sc->mp, fsbno++));
652655

653-
trace_xrep_agfl_insert(sc->mp, sc->sa.pag->pag_agno,
654-
XFS_FSB_TO_AGBNO(sc->mp, start), len);
655-
656656
error = xbitmap_set(&af->used_extents, start, fsbno - 1);
657657
if (error)
658658
return error;

fs/xfs/scrub/reap.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ xrep_reap_block(
175175
agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
176176
agbno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
177177

178-
trace_xrep_dispose_btree_extent(sc->mp, agno, agbno, 1);
179-
180178
/* We don't support reaping file extents yet. */
181179
if (sc->ip != NULL || sc->sa.pag->pag_agno != agno) {
182180
ASSERT(0);
@@ -206,10 +204,21 @@ xrep_reap_block(
206204
* to run xfs_repair.
207205
*/
208206
if (has_other_rmap) {
207+
trace_xrep_dispose_unmap_extent(sc->sa.pag, agbno, 1);
208+
209209
error = xfs_rmap_free(sc->tp, sc->sa.agf_bp, sc->sa.pag, agbno,
210210
1, rs->oinfo);
211-
} else if (rs->resv == XFS_AG_RESV_AGFL) {
212-
xrep_block_reap_binval(sc, fsbno);
211+
if (error)
212+
return error;
213+
214+
goto roll_out;
215+
}
216+
217+
trace_xrep_dispose_free_extent(sc->sa.pag, agbno, 1);
218+
219+
xrep_block_reap_binval(sc, fsbno);
220+
221+
if (rs->resv == XFS_AG_RESV_AGFL) {
213222
error = xrep_put_freelist(sc, agbno);
214223
} else {
215224
/*
@@ -219,7 +228,6 @@ xrep_reap_block(
219228
* every 100 or so EFIs so that we don't exceed the log
220229
* reservation.
221230
*/
222-
xrep_block_reap_binval(sc, fsbno);
223231
error = __xfs_free_extent_later(sc->tp, fsbno, 1, rs->oinfo,
224232
rs->resv, true);
225233
if (error)
@@ -230,6 +238,7 @@ xrep_reap_block(
230238
if (error || !need_roll)
231239
return error;
232240

241+
roll_out:
233242
rs->deferred = 0;
234243
return xrep_roll_ag_trans(sc);
235244
}

fs/xfs/scrub/trace.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -729,18 +729,17 @@ TRACE_EVENT(xchk_refcount_incorrect,
729729
#if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)
730730

731731
DECLARE_EVENT_CLASS(xrep_extent_class,
732-
TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
733-
xfs_agblock_t agbno, xfs_extlen_t len),
734-
TP_ARGS(mp, agno, agbno, len),
732+
TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len),
733+
TP_ARGS(pag, agbno, len),
735734
TP_STRUCT__entry(
736735
__field(dev_t, dev)
737736
__field(xfs_agnumber_t, agno)
738737
__field(xfs_agblock_t, agbno)
739738
__field(xfs_extlen_t, len)
740739
),
741740
TP_fast_assign(
742-
__entry->dev = mp->m_super->s_dev;
743-
__entry->agno = agno;
741+
__entry->dev = pag->pag_mount->m_super->s_dev;
742+
__entry->agno = pag->pag_agno;
744743
__entry->agbno = agbno;
745744
__entry->len = len;
746745
),
@@ -752,10 +751,10 @@ DECLARE_EVENT_CLASS(xrep_extent_class,
752751
);
753752
#define DEFINE_REPAIR_EXTENT_EVENT(name) \
754753
DEFINE_EVENT(xrep_extent_class, name, \
755-
TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
756-
xfs_agblock_t agbno, xfs_extlen_t len), \
757-
TP_ARGS(mp, agno, agbno, len))
758-
DEFINE_REPAIR_EXTENT_EVENT(xrep_dispose_btree_extent);
754+
TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len), \
755+
TP_ARGS(pag, agbno, len))
756+
DEFINE_REPAIR_EXTENT_EVENT(xrep_dispose_unmap_extent);
757+
DEFINE_REPAIR_EXTENT_EVENT(xrep_dispose_free_extent);
759758
DEFINE_REPAIR_EXTENT_EVENT(xrep_agfl_insert);
760759

761760
DECLARE_EVENT_CLASS(xrep_rmap_class,

0 commit comments

Comments
 (0)