From d7bdba1c81f7e7bad12c7c7ce55afa3c7b0821ef Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 22 Dec 2021 17:21:04 +0000 Subject: 9p, afs, ceph, nfs: Use current_is_kswapd() rather than gfpflags_allow_blocking() In 9p, afs ceph, and nfs, gfpflags_allow_blocking() (which wraps a test for __GFP_DIRECT_RECLAIM being set) is used to determine if ->releasepage() should wait for the completion of a DIO write to fscache with something like: if (folio_test_fscache(folio)) { if (!gfpflags_allow_blocking(gfp) || !(gfp & __GFP_FS)) return false; folio_wait_fscache(folio); } Instead, current_is_kswapd() should be used instead. Note that this is based on a patch originally by Zhaoyang Huang[1]. In addition to extending it to the other network filesystems and putting it on top of my fscache rewrite, it also needs to include linux/swap.h in a bunch of places. Can current_is_kswapd() be moved to linux/mm.h? Changes ======= ver #5: - Dropping the changes for cifs. Originally-signed-off-by: Zhaoyang Huang Co-developed-by: David Howells Signed-off-by: David Howells Reviewed-by: Jeff Layton cc: Zhaoyang Huang cc: Dominique Martinet cc: Marc Dionne cc: Steve French cc: Trond Myklebust cc: linux-cachefs@redhat.com cc: v9fs-developer@lists.sourceforge.net cc: linux-afs@lists.infradead.org cc: ceph-devel@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: linux-nfs@vger.kernel.org cc: linux-mm@kvack.org Link: https://lore.kernel.org/r/1638952658-20285-1-git-send-email-huangzhaoyang@gmail.com/ [1] Link: https://lore.kernel.org/r/164021590773.640689.16777975200823659231.stgit@warthog.procyon.org.uk/ # v4 --- fs/ceph/addr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'fs/ceph') diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index e836f8f1d4f8..b3d9459c9bbd 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -174,7 +175,7 @@ static int ceph_releasepage(struct page *page, gfp_t gfp) return 0; if (PageFsCache(page)) { - if (!gfpflags_allow_blocking(gfp) || !(gfp & __GFP_FS)) + if (current_is_kswapd() || !(gfp & __GFP_FS)) return 0; wait_on_page_fscache(page); } -- cgit v1.2.3