From: Darrick J. Wong <djwong@xxxxxxxxxx> Tidy these two functions a bit by adjusting the names so that they communicate that they belong to blockgc and nothing else; and establish that the igrab in the blockgc grab function has to have a matching irele in the blockgc scan function. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- fs/xfs/xfs_icache.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 5c17bed8edb2..5922010b956d 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -1518,6 +1518,10 @@ xfs_blockgc_start( xfs_blockgc_queue(pag); } +/* Don't try to run block gc on an inode that's in any of these states. */ +#define XFS_BLOCKGC_NOGRAB_IFLAGS (XFS_INEW | \ + XFS_IRECLAIMABLE | \ + XFS_IRECLAIM) /* * Decide if the given @ip is eligible for garbage collection of speculative * preallocations, and grab it if so. Returns true if it's ready to go or @@ -1536,8 +1540,7 @@ xfs_blockgc_igrab( if (!ip->i_ino) goto out_unlock_noent; - /* avoid new or reclaimable inodes. Leave for reclaim code to flush */ - if (__xfs_iflags_test(ip, XFS_INEW | XFS_IRECLAIMABLE | XFS_IRECLAIM)) + if (ip->i_flags & XFS_BLOCKGC_NOGRAB_IFLAGS) goto out_unlock_noent; spin_unlock(&ip->i_flags_lock); @@ -1574,6 +1577,7 @@ xfs_blockgc_scan_inode( unlock: if (lockflags) xfs_iunlock(ip, lockflags); + xfs_irele(ip); return error; } @@ -1775,12 +1779,12 @@ xfs_inode_walk_ag( switch (goal) { case XFS_ICWALK_DQRELE: error = xfs_dqrele_inode(batch[i], args); + xfs_irele(batch[i]); break; case XFS_ICWALK_BLOCKGC: error = xfs_blockgc_scan_inode(batch[i], args); break; } - xfs_irele(batch[i]); if (error == -EAGAIN) { skipped++; continue;