@@ -1378,11 +1378,22 @@ xfs_reclaim_inodes_nr(
struct xfs_mount *mp,
int nr_to_scan)
{
- /* kick background reclaimer and push the AIL */
+ int sync_mode = SYNC_TRYLOCK;
+
+ /* kick background reclaimer */
xfs_reclaim_work_queue(mp);
- xfs_ail_push_all(mp->m_ail);
- return xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT, &nr_to_scan);
+ /*
+ * For kswapd, we kick background inode writeback. For direct
+ * reclaim, we issue and wait on inode writeback to throttle
+ * reclaim rates and avoid shouty OOM-death.
+ */
+ if (current_is_kswapd())
+ xfs_ail_push_all(mp->m_ail);
+ else
+ sync_mode |= SYNC_WAIT;
+
+ return xfs_reclaim_inodes_ag(mp, sync_mode, &nr_to_scan);
}
/*