On Sat, Dec 23, 2023 at 10:33:11PM +0900, Tetsuo Handa wrote: > But you can't replace GFP_NOFS with GFP_KERNEL anyway, for syzbot is also > reporting GFP_KERNEL allocation with filesystem lock held > at https://syzkaller.appspot.com/bug?extid=18f543fc90dd1194c616 . Well, you _can_. What _all_ filesystem authors should be doing is switching to memalloc_nofs_save/restore. Generally when taking a lock that's needed during reclaim. In this specific case, soemthing like this: diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 7b6423584eae..432905489a14 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -122,6 +122,7 @@ int mi_read(struct mft_inode *mi, bool is_mft) struct ntfs_inode *mft_ni = sbi->mft.ni; struct runs_tree *run = mft_ni ? &mft_ni->file.run : NULL; struct rw_semaphore *rw_lock = NULL; + unsigned int memalloc = memalloc_nofs_save(); if (is_mounted(sbi)) { if (!is_mft && mft_ni) { @@ -177,6 +178,7 @@ int mi_read(struct mft_inode *mi, bool is_mft) goto out; } + memalloc_nofs_restore(memalloc); return 0; out: @@ -186,6 +188,7 @@ int mi_read(struct mft_inode *mi, bool is_mft) err = -EINVAL; } + memalloc_nofs_restore(memalloc); return err; }