xfs: roll the scrub transaction after completing a repair
authorDarrick J. Wong <djwong@kernel.org>
Fri, 15 Dec 2023 18:03:31 +0000 (10:03 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 15 Dec 2023 18:03:31 +0000 (10:03 -0800)
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>
fs/xfs/scrub/agheader_repair.c

index 52956c0b8f79a5344cddbbd76fc28c923eb30e8f..26bd1ff68f1bed61a55a82f9583845acc2a657bf 100644 (file)
@@ -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 */
@@ -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. */
@@ -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;
@@ -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. */