This patchset avoids transaction reservation recursion by reintroducing the discarded PF_FSTRANS in a new way, suggested by Dave. In this new implementation, some new helpers are introduced, which are xfs_trans_context_{set, clear, active}, suggested by Dave. And re-using the task->journal_info to indicates whehter the task is in fstrans or not, suggested by Willy Darrick helped fix the error occurred in xfs/141.[2] I rerun the xfstests again in my server, and no obvious error occurred. Patch #1 is picked from Willy's patchset "Overhaul memalloc_no*"[1] [1]. https://lore.kernel.org/linux-mm/20200625113122.7540-1-willy@xxxxxxxxxxxxx/ [2]. https://lore.kernel.org/linux-xfs/20201104001649.GN7123@magnolia/#t v9: - rebase it on xfs tree. - Darrick fixed an error occurred in xfs/141 - run xfstests, and no obvious error occurred. v8: - check xfs_trans_context_active() in xfs_vm_writepage(s), per Dave. v7: - check fstrans recursion for XFS only, by introducing a new member in struct writeback_control. v6: - add Michal's ack and comment in patch #1. v5: - pick one of Willy's patch - introduce four new helpers, per Dave v4: - retitle from "xfs: introduce task->in_fstrans for transaction reservation recursion protection" - reuse current->journal_info, per Willy Matthew Wilcox (Oracle) (1): mm: Add become_kswapd and restore_kswapd Yafang Shao (1): xfs: avoid transaction reservation recursion fs/iomap/buffered-io.c | 7 ------- fs/xfs/libxfs/xfs_btree.c | 14 ++++++++------ fs/xfs/xfs_aops.c | 23 +++++++++++++++++++++-- fs/xfs/xfs_linux.h | 4 ---- fs/xfs/xfs_trans.c | 25 +++++++++++++------------ fs/xfs/xfs_trans.h | 23 +++++++++++++++++++++++ include/linux/sched/mm.h | 23 +++++++++++++++++++++++ mm/vmscan.c | 16 +--------------- 8 files changed, 89 insertions(+), 46 deletions(-) -- 2.18.4