From: Darrick J. Wong <djwong@xxxxxxxxxx> Now that we have the means to throttle queueing of inactive inodes and push the background workers when memory gets tight, stop forcing tasks that are evicting inodes from a memory reclaim context to wait for the inodes to inactivate. There's not much reason to make reclaimers wait, because it can take quite a long time to inactivate an inode (particularly deleted ones) and wait for the metadata updates to push through the logs until the incore inode can be reclaimed. In other words, memory allocations will no longer stall on XFS when inode eviction requires metadata updates. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- fs/xfs/xfs_icache.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 3e2302a44c69..82f0db311ef9 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -355,6 +355,15 @@ xfs_inodegc_want_throttle( { struct xfs_mount *mp = pag->pag_mount; + /* + * If we're in memory reclaim context, we don't want to wait for inode + * inactivation to finish because it can take a very long time to + * commit all the metadata updates and push the inodes through memory + * reclamation. Also, we might be the background inodegc thread. + */ + if (current->reclaim_state != NULL) + return false; + /* Throttle if memory reclaim anywhere has triggered us. */ if (atomic_read(&mp->m_inodegc_reclaim) > 0) { trace_xfs_inodegc_throttle_mempressure(mp);