xfs: flush inode inactivation work when compiling usage statistics
authorDarrick J. Wong <djwong@kernel.org>
Fri, 6 Aug 2021 18:05:42 +0000 (11:05 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 9 Aug 2021 17:52:18 +0000 (10:52 -0700)
Users have come to expect that the space accounting information in
statfs and getquota reports are fairly accurate.  Now that we inactivate
inodes from a background queue, these numbers can be thrown off by
whatever resources are singly-owned by the inodes in the queue.  Flush
the pending inactivations when userspace asks for a space usage report.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/xfs_qm_syscalls.c
fs/xfs/xfs_super.c

index 982cd66..c6902f9 100644 (file)
@@ -481,6 +481,10 @@ xfs_qm_scall_getquota(
        struct xfs_dquot        *dqp;
        int                     error;
 
+       /* Flush inodegc work at the start of a quota reporting scan. */
+       if (id == 0)
+               xfs_inodegc_flush(mp);
+
        /*
         * Try to get the dquot. We don't want it allocated on disk, so don't
         * set doalloc. If it doesn't exist, we'll get ENOENT back.
@@ -519,6 +523,10 @@ xfs_qm_scall_getquota_next(
        struct xfs_dquot        *dqp;
        int                     error;
 
+       /* Flush inodegc work at the start of a quota reporting scan. */
+       if (*id == 0)
+               xfs_inodegc_flush(mp);
+
        error = xfs_qm_dqget_next(mp, *id, type, &dqp);
        if (error)
                return error;
index fd39b97..d142aaa 100644 (file)
@@ -785,6 +785,9 @@ xfs_fs_statfs(
        xfs_extlen_t            lsize;
        int64_t                 ffree;
 
+       /* Wait for whatever inactivations are in progress. */
+       xfs_inodegc_flush(mp);
+
        statp->f_type = XFS_SUPER_MAGIC;
        statp->f_namelen = MAXNAMELEN - 1;