xfs: disable reaping in fscounters scrub
authorDarrick J. Wong <djwong@kernel.org>
Sat, 15 Jul 2023 06:31:13 +0000 (09:31 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jul 2023 14:22:15 +0000 (16:22 +0200)
commit 2d5f38a31980d7090f5bf91021488dc61a0ba8ee upstream.

The fscounters scrub code doesn't work properly because it cannot
quiesce updates to the percpu counters in the filesystem, hence it
returns false corruption reports.  This has been fixed properly in
one of the online repair patchsets that are under review by replacing
the xchk_disable_reaping calls with an exclusive filesystem freeze.
Disabling background gc isn't sufficient to fix the problem.

In other words, scrub doesn't need to call xfs_inodegc_stop, which is
just as well since it wasn't correct to allow scrub to call
xfs_inodegc_start when something else could be calling xfs_inodegc_stop
(e.g. trying to freeze the filesystem).

Neuter the scrubber for now, and remove the xchk_*_reaping functions.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/scrub/common.c
fs/xfs/scrub/common.h
fs/xfs/scrub/fscounters.c
fs/xfs/scrub/scrub.c
fs/xfs/scrub/scrub.h

index 9bbbf20f401b3af92eec89db60909d96ca0b2ada..e71449658ecc322867378e6f4caa382f3bffa6a0 100644 (file)
@@ -865,29 +865,3 @@ xchk_ilock_inverted(
        }
        return -EDEADLOCK;
 }
-
-/* Pause background reaping of resources. */
-void
-xchk_stop_reaping(
-       struct xfs_scrub        *sc)
-{
-       sc->flags |= XCHK_REAPING_DISABLED;
-       xfs_blockgc_stop(sc->mp);
-       xfs_inodegc_stop(sc->mp);
-}
-
-/* Restart background reaping of resources. */
-void
-xchk_start_reaping(
-       struct xfs_scrub        *sc)
-{
-       /*
-        * Readonly filesystems do not perform inactivation or speculative
-        * preallocation, so there's no need to restart the workers.
-        */
-       if (!xfs_is_readonly(sc->mp)) {
-               xfs_inodegc_start(sc->mp);
-               xfs_blockgc_start(sc->mp);
-       }
-       sc->flags &= ~XCHK_REAPING_DISABLED;
-}
index 454145db10e717f67f8e9d19530d0616abfe0ddd..2ca80102e704a608e2f84e5343ce58d2938eccb7 100644 (file)
@@ -148,7 +148,5 @@ static inline bool xchk_skip_xref(struct xfs_scrub_metadata *sm)
 
 int xchk_metadata_inode_forks(struct xfs_scrub *sc);
 int xchk_ilock_inverted(struct xfs_inode *ip, uint lock_mode);
-void xchk_stop_reaping(struct xfs_scrub *sc);
-void xchk_start_reaping(struct xfs_scrub *sc);
 
 #endif /* __XFS_SCRUB_COMMON_H__ */
index 6a6f8fe7f87c07a691176d1b96a4eb4cad922019..88d6961e38866077a4b6bf13e0eab9ce62e9a855 100644 (file)
@@ -128,13 +128,6 @@ xchk_setup_fscounters(
        if (error)
                return error;
 
-       /*
-        * Pause background reclaim while we're scrubbing to reduce the
-        * likelihood of background perturbations to the counters throwing off
-        * our calculations.
-        */
-       xchk_stop_reaping(sc);
-
        return xchk_trans_alloc(sc, 0);
 }
 
@@ -353,6 +346,12 @@ xchk_fscounters(
        if (fdblocks > mp->m_sb.sb_dblocks)
                xchk_set_corrupt(sc);
 
+       /*
+        * XXX: We can't quiesce percpu counter updates, so exit early.
+        * This can be re-enabled when we gain exclusive freeze functionality.
+        */
+       return 0;
+
        /*
         * If ifree exceeds icount by more than the minimum variance then
         * something's probably wrong with the counters.
index 2e8e400f10a9a8b3a1e10eedc4df71c136454f81..95132490fda5ee86f79d5adf873f38dcd48c2be1 100644 (file)
@@ -171,8 +171,6 @@ xchk_teardown(
        }
        if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)
                mnt_drop_write_file(sc->file);
-       if (sc->flags & XCHK_REAPING_DISABLED)
-               xchk_start_reaping(sc);
        if (sc->buf) {
                kmem_free(sc->buf);
                sc->buf = NULL;
index 3de5287e98d84cc1743b1ecef978289de418e4ce..4cb32c27df1025da357a13856183d04665ff78e4 100644 (file)
@@ -88,7 +88,6 @@ struct xfs_scrub {
 
 /* XCHK state flags grow up from zero, XREP state flags grown down from 2^31 */
 #define XCHK_TRY_HARDER                (1 << 0)  /* can't get resources, try again */
-#define XCHK_REAPING_DISABLED  (1 << 2)  /* background block reaping paused */
 #define XREP_ALREADY_FIXED     (1 << 31) /* checking our repair work */
 
 /* Metadata scrubbers */