diff mbox series

[09/14] xfs: inactivate inodes any time we try to free speculative preallocations

Message ID 162812923242.2589546.4318604170788681871.stgit@magnolia (mailing list archive)
State Accepted, archived
Headers show
Series xfs: deferred inode inactivation | expand

Commit Message

Darrick J. Wong Aug. 5, 2021, 2:07 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Other parts of XFS have learned to call xfs_blockgc_free_{space,quota}
to try to free speculative preallocations when space is tight.  This
means that file writes, transaction reservation failures, quota limit
enforcement, and the EOFBLOCKS ioctl all call this function to free
space when things are tight.

Since inode inactivation is now a background task, this means that the
filesystem can be hanging on to unlinked but not yet freed space.  Add
this to the list of things that xfs_blockgc_free_* makes writer threads
scan for when they cannot reserve space.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_icache.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Dave Chinner Aug. 5, 2021, 5:36 a.m. UTC | #1
On Wed, Aug 04, 2021 at 07:07:12PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Other parts of XFS have learned to call xfs_blockgc_free_{space,quota}
> to try to free speculative preallocations when space is tight.  This
> means that file writes, transaction reservation failures, quota limit
> enforcement, and the EOFBLOCKS ioctl all call this function to free
> space when things are tight.
> 
> Since inode inactivation is now a background task, this means that the
> filesystem can be hanging on to unlinked but not yet freed space.  Add
> this to the list of things that xfs_blockgc_free_* makes writer threads
> scan for when they cannot reserve space.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  fs/xfs/xfs_icache.c |   12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)

Yup.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 4a062cf689c3..f2d12405dd87 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1468,16 +1468,24 @@  xfs_blockgc_worker(
 }
 
 /*
- * Try to free space in the filesystem by purging eofblocks and cowblocks.
+ * Try to free space in the filesystem by purging inactive inodes, eofblocks
+ * and cowblocks.
  */
 int
 xfs_blockgc_free_space(
 	struct xfs_mount	*mp,
 	struct xfs_icwalk	*icw)
 {
+	int			error;
+
 	trace_xfs_blockgc_free_space(mp, icw, _RET_IP_);
 
-	return xfs_icwalk(mp, XFS_ICWALK_BLOCKGC, icw);
+	error = xfs_icwalk(mp, XFS_ICWALK_BLOCKGC, icw);
+	if (error)
+		return error;
+
+	xfs_inodegc_flush(mp);
+	return 0;
 }
 
 /*