Commit 77a1396f authored by Darrick J. Wong's avatar Darrick J. Wong

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: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 5fee784e
...@@ -646,13 +646,13 @@ xrep_agfl_fill( ...@@ -646,13 +646,13 @@ xrep_agfl_fill(
xfs_fsblock_t fsbno = start; xfs_fsblock_t fsbno = start;
int error; int error;
trace_xrep_agfl_insert(sc->sa.pag, XFS_FSB_TO_AGBNO(sc->mp, start),
len);
while (fsbno < start + len && af->fl_off < af->flcount) while (fsbno < start + len && af->fl_off < af->flcount)
af->agfl_bno[af->fl_off++] = af->agfl_bno[af->fl_off++] =
cpu_to_be32(XFS_FSB_TO_AGBNO(sc->mp, fsbno++)); cpu_to_be32(XFS_FSB_TO_AGBNO(sc->mp, fsbno++));
trace_xrep_agfl_insert(sc->mp, sc->sa.pag->pag_agno,
XFS_FSB_TO_AGBNO(sc->mp, start), len);
error = xbitmap_set(&af->used_extents, start, fsbno - 1); error = xbitmap_set(&af->used_extents, start, fsbno - 1);
if (error) if (error)
return error; return error;
......
...@@ -175,8 +175,6 @@ xrep_reap_block( ...@@ -175,8 +175,6 @@ xrep_reap_block(
agno = XFS_FSB_TO_AGNO(sc->mp, fsbno); agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
agbno = XFS_FSB_TO_AGBNO(sc->mp, fsbno); agbno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
trace_xrep_dispose_btree_extent(sc->mp, agno, agbno, 1);
/* We don't support reaping file extents yet. */ /* We don't support reaping file extents yet. */
if (sc->ip != NULL || sc->sa.pag->pag_agno != agno) { if (sc->ip != NULL || sc->sa.pag->pag_agno != agno) {
ASSERT(0); ASSERT(0);
...@@ -206,10 +204,21 @@ xrep_reap_block( ...@@ -206,10 +204,21 @@ xrep_reap_block(
* to run xfs_repair. * to run xfs_repair.
*/ */
if (has_other_rmap) { if (has_other_rmap) {
trace_xrep_dispose_unmap_extent(sc->sa.pag, agbno, 1);
error = xfs_rmap_free(sc->tp, sc->sa.agf_bp, sc->sa.pag, agbno, error = xfs_rmap_free(sc->tp, sc->sa.agf_bp, sc->sa.pag, agbno,
1, rs->oinfo); 1, rs->oinfo);
} else if (rs->resv == XFS_AG_RESV_AGFL) { if (error)
xrep_block_reap_binval(sc, fsbno); return error;
goto roll_out;
}
trace_xrep_dispose_free_extent(sc->sa.pag, agbno, 1);
xrep_block_reap_binval(sc, fsbno);
if (rs->resv == XFS_AG_RESV_AGFL) {
error = xrep_put_freelist(sc, agbno); error = xrep_put_freelist(sc, agbno);
} else { } else {
/* /*
...@@ -219,7 +228,6 @@ xrep_reap_block( ...@@ -219,7 +228,6 @@ xrep_reap_block(
* every 100 or so EFIs so that we don't exceed the log * every 100 or so EFIs so that we don't exceed the log
* reservation. * reservation.
*/ */
xrep_block_reap_binval(sc, fsbno);
error = __xfs_free_extent_later(sc->tp, fsbno, 1, rs->oinfo, error = __xfs_free_extent_later(sc->tp, fsbno, 1, rs->oinfo,
rs->resv, true); rs->resv, true);
if (error) if (error)
...@@ -230,6 +238,7 @@ xrep_reap_block( ...@@ -230,6 +238,7 @@ xrep_reap_block(
if (error || !need_roll) if (error || !need_roll)
return error; return error;
roll_out:
rs->deferred = 0; rs->deferred = 0;
return xrep_roll_ag_trans(sc); return xrep_roll_ag_trans(sc);
} }
......
...@@ -729,9 +729,8 @@ TRACE_EVENT(xchk_refcount_incorrect, ...@@ -729,9 +729,8 @@ TRACE_EVENT(xchk_refcount_incorrect,
#if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR) #if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)
DECLARE_EVENT_CLASS(xrep_extent_class, DECLARE_EVENT_CLASS(xrep_extent_class,
TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len),
xfs_agblock_t agbno, xfs_extlen_t len), TP_ARGS(pag, agbno, len),
TP_ARGS(mp, agno, agbno, len),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(dev_t, dev) __field(dev_t, dev)
__field(xfs_agnumber_t, agno) __field(xfs_agnumber_t, agno)
...@@ -739,8 +738,8 @@ DECLARE_EVENT_CLASS(xrep_extent_class, ...@@ -739,8 +738,8 @@ DECLARE_EVENT_CLASS(xrep_extent_class,
__field(xfs_extlen_t, len) __field(xfs_extlen_t, len)
), ),
TP_fast_assign( TP_fast_assign(
__entry->dev = mp->m_super->s_dev; __entry->dev = pag->pag_mount->m_super->s_dev;
__entry->agno = agno; __entry->agno = pag->pag_agno;
__entry->agbno = agbno; __entry->agbno = agbno;
__entry->len = len; __entry->len = len;
), ),
...@@ -752,10 +751,10 @@ DECLARE_EVENT_CLASS(xrep_extent_class, ...@@ -752,10 +751,10 @@ DECLARE_EVENT_CLASS(xrep_extent_class,
); );
#define DEFINE_REPAIR_EXTENT_EVENT(name) \ #define DEFINE_REPAIR_EXTENT_EVENT(name) \
DEFINE_EVENT(xrep_extent_class, name, \ DEFINE_EVENT(xrep_extent_class, name, \
TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len), \
xfs_agblock_t agbno, xfs_extlen_t len), \ TP_ARGS(pag, agbno, len))
TP_ARGS(mp, agno, agbno, len)) DEFINE_REPAIR_EXTENT_EVENT(xrep_dispose_unmap_extent);
DEFINE_REPAIR_EXTENT_EVENT(xrep_dispose_btree_extent); DEFINE_REPAIR_EXTENT_EVENT(xrep_dispose_free_extent);
DEFINE_REPAIR_EXTENT_EVENT(xrep_agfl_insert); DEFINE_REPAIR_EXTENT_EVENT(xrep_agfl_insert);
DECLARE_EVENT_CLASS(xrep_rmap_class, DECLARE_EVENT_CLASS(xrep_rmap_class,
......
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