Skip to content

Commit

Permalink
xfs: roll the scrub transaction after completing a repair
Browse files Browse the repository at this point in the history
When we've finished repairing an AG header, roll the scrub transaction.
This ensure that any failures caused by defer ops failing are captured
by the xrep_done tracepoint and that any stacktraces that occur will
point to the repair code that caused it, instead of xchk_teardown.

Going forward, repair functions should commit the transaction if they're
going to return success.  Usually the space reaping functions that run
after a successful atomic commit of the new metadata will take care of
that for us.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Darrick J. Wong committed Dec 15, 2023
1 parent 0f08af0 commit efb43b3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fs/xfs/scrub/agheader_repair.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ xrep_superblock(
/* Write this to disk. */
xfs_trans_buf_set_type(sc->tp, bp, XFS_BLFT_SB_BUF);
xfs_trans_log_buf(sc->tp, bp, 0, BBTOB(bp->b_length) - 1);
return error;
return 0;
}

/* AGF */
Expand Down Expand Up @@ -342,7 +342,7 @@ xrep_agf_commit_new(
pag->pagf_refcount_level = be32_to_cpu(agf->agf_refcount_level);
set_bit(XFS_AGSTATE_AGF_INIT, &pag->pag_opstate);

return 0;
return xrep_roll_ag_trans(sc);
}

/* Repair the AGF. v5 filesystems only. */
Expand Down Expand Up @@ -789,6 +789,9 @@ xrep_agfl(
/* Dump any AGFL overflow. */
error = xrep_reap_agblocks(sc, &agfl_extents, &XFS_RMAP_OINFO_AG,
XFS_AG_RESV_AGFL);
if (error)
goto err;

err:
xagb_bitmap_destroy(&agfl_extents);
return error;
Expand Down Expand Up @@ -962,7 +965,7 @@ xrep_agi_commit_new(
pag->pagi_freecount = be32_to_cpu(agi->agi_freecount);
set_bit(XFS_AGSTATE_AGI_INIT, &pag->pag_opstate);

return 0;
return xrep_roll_ag_trans(sc);
}

/* Repair the AGI. */
Expand Down

0 comments on commit efb43b3

Please sign in to comment.