xfs: allow scrubbers to pause background reclaim
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 26 Apr 2019 01:26:23 +0000 (18:26 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Fri, 26 Apr 2019 19:28:56 +0000 (12:28 -0700)
The forthcoming summary counter patch races with regular filesystem
activity to compute rough expected values for the counters.  This design
was chosen to avoid having to freeze the entire filesystem to check the
counters, but while that's running we'd prefer to minimize background
reclamation activity to reduce the perturbations to the incore free
block count.  Therefore, provide a way for scrubbers to disable
background posteof and cowblock reclamation.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/scrub/common.c
fs/xfs/scrub/common.h
fs/xfs/scrub/scrub.c
fs/xfs/scrub/scrub.h

index 7076d5c98151447be032a86c02a5e3c6bc48ed1f..7d7e91a7bb86c0fb8c2f792276b3e7ebd875c62f 100644 (file)
@@ -894,3 +894,21 @@ xchk_ilock_inverted(
        }
        return -EDEADLOCK;
 }
+
+/* Pause background reaping of resources. */
+void
+xchk_stop_reaping(
+       struct xfs_scrub        *sc)
+{
+       sc->flags |= XCHK_REAPING_DISABLED;
+       xfs_stop_block_reaping(sc->mp);
+}
+
+/* Restart background reaping of resources. */
+void
+xchk_start_reaping(
+       struct xfs_scrub        *sc)
+{
+       xfs_start_block_reaping(sc->mp);
+       sc->flags &= ~XCHK_REAPING_DISABLED;
+}
index e26a430bd466eb8825154b82f9d1a97b7a8ddc10..84900bfad852539e33965646aea05fbdf88d462e 100644 (file)
@@ -137,5 +137,7 @@ 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 93b0f075a4d3afb458b70e0a13bfe01dc55fabbc..ce13c1c366dbe6da64bbe36bd1771cf4036be847 100644 (file)
@@ -187,6 +187,8 @@ xchk_teardown(
                        xfs_irele(sc->ip);
                sc->ip = NULL;
        }
+       if (sc->flags & XCHK_REAPING_DISABLED)
+               xchk_start_reaping(sc);
        if (sc->flags & XCHK_HAS_QUOTAOFFLOCK) {
                mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock);
                sc->flags &= ~XCHK_HAS_QUOTAOFFLOCK;
index 1b280f8f185aa08b68c78ceb83b0a0e00e2d495f..01986ed364dbc52a846be597b5c7c14f72de48ce 100644 (file)
@@ -80,6 +80,7 @@ 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_HAS_QUOTAOFFLOCK  (1 << 1)  /* we hold the quotaoff lock */
+#define XCHK_REAPING_DISABLED  (1 << 2)  /* background block reaping paused */
 #define XREP_ALREADY_FIXED     (1 << 31) /* checking our repair work */
 
 /* Metadata scrubbers */