diff mbox series

[5/7] xfs: only walk the incore inode tree once per blockgc scan

Message ID 161040742666.1582286.3910636058356753098.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfs: consolidate posteof and cowblocks cleanup | expand

Commit Message

Darrick J. Wong Jan. 11, 2021, 11:23 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Perform background block preallocation gc scans more efficiently by
walking the incore inode tree once.

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

Comments

Christoph Hellwig Jan. 13, 2021, 3:06 p.m. UTC | #1
On Mon, Jan 11, 2021 at 03:23:46PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Perform background block preallocation gc scans more efficiently by
> walking the incore inode tree once.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Looks good.  If you could find a way to avoid the forward declarations
I'd be even more happy :)

Reviewed-by: Christoph Hellwig <hch@lst.de>
Darrick J. Wong Jan. 13, 2021, 8:41 p.m. UTC | #2
On Wed, Jan 13, 2021 at 04:06:32PM +0100, Christoph Hellwig wrote:
> On Mon, Jan 11, 2021 at 03:23:46PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Perform background block preallocation gc scans more efficiently by
> > walking the incore inode tree once.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> 
> Looks good.  If you could find a way to avoid the forward declarations
> I'd be even more happy :)

They went away as a part of the massive rework stemming from Dave's
"simple" review comment in the previous series about moving the ENOSPC
retry loops into the quota reservation functions.

Granted, the double series has ballooned from 13 to 28 patches as I had
to clean up even more quota code... :(

--D

> Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 92fcec349054..4f68375cf873 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -31,6 +31,9 @@ 
  */
 #define XFS_INODE_WALK_INEW_WAIT	0x1	/* wait on new inodes */
 
+STATIC int xfs_inode_free_eofblocks(struct xfs_inode *ip, void *args);
+STATIC int xfs_inode_free_cowblocks(struct xfs_inode *ip, void *args);
+
 /*
  * Allocate and initialise an xfs_inode.
  */
@@ -950,19 +953,29 @@  xfs_queue_blockgc(
 	rcu_read_unlock();
 }
 
+/* Scan one incore inode for block preallocations that we can remove. */
+static int
+xfs_blockgc_scan_inode(
+	struct xfs_inode	*ip,
+	void			*args)
+{
+	int			error;
+
+	error = xfs_inode_free_eofblocks(ip, args);
+	if (error && error != -EAGAIN)
+		return error;
+
+	return xfs_inode_free_cowblocks(ip, args);
+}
+
 /* Scan all incore inodes for block preallocations that we can remove. */
 static inline int
 xfs_blockgc_scan(
 	struct xfs_mount	*mp,
 	struct xfs_eofblocks	*eofb)
 {
-	int			error;
-
-	error = xfs_icache_free_eofblocks(mp, eofb);
-	if (error && error != -EAGAIN)
-		return error;
-
-	return xfs_icache_free_cowblocks(mp, eofb);
+	return __xfs_inode_walk(mp, 0, xfs_blockgc_scan_inode, eofb,
+			XFS_ICI_BLOCK_GC_TAG);
 }
 
 /* Background worker that trims preallocated space. */