xfs: exchange-range for repairs is no longer dynamic
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 16:48:29 +0000 (09:48 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 23 Apr 2024 23:55:19 +0000 (16:55 -0700)
The atomic file exchange-range functionality is now a permanent
filesystem feature instead of a dynamic log-incompat feature.  It cannot
be turned on at runtime, so we no longer need the XCHK_FSGATES flags and
whatnot that supported it.  Remove the flag and the enable function, and
move the xfs_has_exchange_range checks to the start of the repair
functions.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/scrub/attr_repair.c
fs/xfs/scrub/dir_repair.c
fs/xfs/scrub/parent_repair.c
fs/xfs/scrub/rtsummary_repair.c
fs/xfs/scrub/scrub.c
fs/xfs/scrub/scrub.h
fs/xfs/scrub/symlink_repair.c
fs/xfs/scrub/tempexch.h
fs/xfs/scrub/tempfile.c
fs/xfs/scrub/trace.h

index e059813b92b703404e63c7faa42074722045b0ce..c7eb94069cafcd001879ecc6533466f65388627b 100644 (file)
@@ -1630,6 +1630,9 @@ xrep_xattr(
        /* The rmapbt is required to reap the old attr fork. */
        if (!xfs_has_rmapbt(sc->mp))
                return -EOPNOTSUPP;
+       /* We require atomic file exchange range to rebuild anything. */
+       if (!xfs_has_exchange_range(sc->mp))
+               return -EOPNOTSUPP;
 
        error = xrep_xattr_setup_scan(sc, &rx);
        if (error)
index e968150fe0f063e2d0431c40c4201df2189a4b4e..6ad40f8aafb82690420c29b03cfc13d2322789d0 100644 (file)
@@ -1993,6 +1993,9 @@ xrep_directory(
        /* The rmapbt is required to reap the old data fork. */
        if (!xfs_has_rmapbt(sc->mp))
                return -EOPNOTSUPP;
+       /* We require atomic file exchange range to rebuild anything. */
+       if (!xfs_has_exchange_range(sc->mp))
+               return -EOPNOTSUPP;
 
        error = xrep_dir_setup_scan(rd);
        if (error)
index ee88ce5a12b8395ce0e6425672ead87a6ef5c144..7b42b7f65a0bd3e61ae5f6dd1b12442e8d79b7bd 100644 (file)
@@ -1571,10 +1571,14 @@ xrep_parent(
        /*
         * When the parent pointers feature is enabled, repairs are committed
         * by atomically committing a new xattr structure and reaping the old
-        * attr fork.  Reaping requires rmap to be enabled.
+        * attr fork.  Reaping requires rmap and exchange-range to be enabled.
         */
-       if (xfs_has_parent(sc->mp) && !xfs_has_rmapbt(sc->mp))
-               return -EOPNOTSUPP;
+       if (xfs_has_parent(sc->mp)) {
+               if (!xfs_has_rmapbt(sc->mp))
+                       return -EOPNOTSUPP;
+               if (!xfs_has_exchange_range(sc->mp))
+                       return -EOPNOTSUPP;
+       }
 
        error = xrep_parent_setup_scan(rp);
        if (error)
index c8bb6c4f15d05d861983b5269505410ae53950f5..d9e971c4c79fb267129002644de5310e94eb825a 100644 (file)
@@ -62,12 +62,7 @@ xrep_setup_rtsummary(
                return -EOPNOTSUPP;
 
        rts->resblks += blocks;
-
-       /*
-        * Grab support for atomic file content exchanges before we allocate
-        * any transactions or grab ILOCKs.
-        */
-       return xrep_tempexch_enable(sc);
+       return 0;
 }
 
 static int
@@ -111,6 +106,9 @@ xrep_rtsummary(
        /* We require the rmapbt to rebuild anything. */
        if (!xfs_has_rmapbt(mp))
                return -EOPNOTSUPP;
+       /* We require atomic file exchange range to rebuild anything. */
+       if (!xfs_has_exchange_range(mp))
+               return -EOPNOTSUPP;
 
        /* Walk away if we disagree on the size of the rt bitmap. */
        if (rts->rbmblocks != mp->m_sb.sb_rbmblocks)
index 43af5ce1f99f0955dad2032d9fa517248f278116..c013f0ba4f36b2cfc9a3fe7c8131b14954fcc10a 100644 (file)
@@ -154,15 +154,14 @@ xchk_probe(
 
 /* Scrub setup and teardown */
 
-#define FSGATES_MASK   (XCHK_FSGATES_ALL | XREP_FSGATES_ALL)
 static inline void
 xchk_fsgates_disable(
        struct xfs_scrub        *sc)
 {
-       if (!(sc->flags & FSGATES_MASK))
+       if (!(sc->flags & XCHK_FSGATES_ALL))
                return;
 
-       trace_xchk_fsgates_disable(sc, sc->flags & FSGATES_MASK);
+       trace_xchk_fsgates_disable(sc, sc->flags & XCHK_FSGATES_ALL);
 
        if (sc->flags & XCHK_FSGATES_DRAIN)
                xfs_drain_wait_disable();
@@ -176,9 +175,8 @@ xchk_fsgates_disable(
        if (sc->flags & XCHK_FSGATES_RMAP)
                xfs_rmap_hook_disable();
 
-       sc->flags &= ~FSGATES_MASK;
+       sc->flags &= ~XCHK_FSGATES_ALL;
 }
-#undef FSGATES_MASK
 
 /* Free the resources associated with a scrub subtype. */
 void
index 1da10182f7f42be05628a6188f9275fd41eb58f4..1bc33f010d0e788a7a3fdbd98f9e6bbcd6d6ca60 100644 (file)
@@ -188,7 +188,6 @@ struct xfs_scrub {
 #define XCHK_FSGATES_QUOTA     (1U << 4)  /* quota live update enabled */
 #define XCHK_FSGATES_DIRENTS   (1U << 5)  /* directory live update enabled */
 #define XCHK_FSGATES_RMAP      (1U << 6)  /* rmapbt live update enabled */
-#define XREP_FSGATES_EXCHANGE_RANGE (1U << 29) /* uses file content exchange */
 #define XREP_RESET_PERAG_RESV  (1U << 30) /* must reset AG space reservation */
 #define XREP_ALREADY_FIXED     (1U << 31) /* checking our repair work */
 
@@ -203,12 +202,6 @@ struct xfs_scrub {
                                 XCHK_FSGATES_DIRENTS | \
                                 XCHK_FSGATES_RMAP)
 
-/*
- * The sole XREP_FSGATES* flag reflects a log intent item that is protected
- * by a log-incompat feature flag.  No code patching in use here.
- */
-#define XREP_FSGATES_ALL       (XREP_FSGATES_EXCHANGE_RANGE)
-
 struct xfs_scrub_subord {
        struct xfs_scrub        sc;
        struct xfs_scrub        *parent_sc;
index c8b5a5b878ac9fb52539c7e8dd524a977ba7600a..d015a86ef460fb9145e335922fcd7a586452723b 100644 (file)
@@ -490,6 +490,9 @@ xrep_symlink(
        /* The rmapbt is required to reap the old data fork. */
        if (!xfs_has_rmapbt(sc->mp))
                return -EOPNOTSUPP;
+       /* We require atomic file exchange range to rebuild anything. */
+       if (!xfs_has_exchange_range(sc->mp))
+               return -EOPNOTSUPP;
 
        ASSERT(sc->ilock_flags & XFS_ILOCK_EXCL);
 
index c1dd4adec4f112f8c3548229c6f6663fd8166e87..995ba187c5aa62bb4ef4ac729bec23c144487acc 100644 (file)
@@ -11,7 +11,6 @@ struct xrep_tempexch {
        struct xfs_exchmaps_req req;
 };
 
-int xrep_tempexch_enable(struct xfs_scrub *sc);
 int xrep_tempexch_trans_reserve(struct xfs_scrub *sc, int whichfork,
                struct xrep_tempexch *ti);
 int xrep_tempexch_trans_alloc(struct xfs_scrub *sc, int whichfork,
index ddbcccb3dba13fec70d1b573761024244db5f4d6..b747b625c5ee4eb6408fedb96d854ef6a464dfc4 100644 (file)
@@ -486,23 +486,6 @@ xrep_tempfile_roll_trans(
        return 0;
 }
 
-/* Enable file content exchanges. */
-int
-xrep_tempexch_enable(
-       struct xfs_scrub        *sc)
-{
-       if (sc->flags & XREP_FSGATES_EXCHANGE_RANGE)
-               return 0;
-
-       if (!xfs_has_exchange_range(sc->mp))
-               return -EOPNOTSUPP;
-
-       trace_xchk_fsgates_enable(sc, XREP_FSGATES_EXCHANGE_RANGE);
-
-       sc->flags |= XREP_FSGATES_EXCHANGE_RANGE;
-       return 0;
-}
-
 /*
  * Fill out the mapping exchange request in preparation for atomically
  * committing the contents of a metadata file that we've rebuilt in the temp
@@ -745,6 +728,7 @@ xrep_tempexch_trans_alloc(
        int                     error;
 
        ASSERT(sc->tp == NULL);
+       ASSERT(xfs_has_exchange_range(sc->mp));
 
        error = xrep_tempexch_prep_request(sc, whichfork, tx);
        if (error)
@@ -757,10 +741,6 @@ xrep_tempexch_trans_alloc(
        if (xfs_has_lazysbcount(sc->mp))
                flags |= XFS_TRANS_RES_FDBLKS;
 
-       error = xrep_tempexch_enable(sc);
-       if (error)
-               return error;
-
        error = xfs_trans_alloc(sc->mp, &M_RES(sc->mp)->tr_itruncate,
                        tx->req.resblks, 0, flags, &sc->tp);
        if (error)
@@ -785,7 +765,7 @@ xrep_tempexch_contents(
 {
        int                     error;
 
-       ASSERT(sc->flags & XREP_FSGATES_EXCHANGE_RANGE);
+       ASSERT(xfs_has_exchange_range(sc->mp));
 
        xfs_exchange_mappings(sc->tp, &tx->req);
        error = xfs_defer_finish(&sc->tp);
index 8ce74bd8530a640c11bd776727f2f2e4676fdb04..4b945007ca6ca0584749eaebde96c6992fc831a6 100644 (file)
@@ -122,7 +122,6 @@ TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BARRIER);
        { XCHK_FSGATES_QUOTA,                   "fsgates_quota" }, \
        { XCHK_FSGATES_DIRENTS,                 "fsgates_dirents" }, \
        { XCHK_FSGATES_RMAP,                    "fsgates_rmap" }, \
-       { XREP_FSGATES_EXCHANGE_RANGE,          "fsgates_exchrange" }, \
        { XREP_RESET_PERAG_RESV,                "reset_perag_resv" }, \
        { XREP_ALREADY_FIXED,                   "already_fixed" }