From: Wang Zhaolong <wangzhaolong@huaweicloud.com> hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/8332 -------------------------------- This reverts commit c28d40c8d3a47e3abaf6bc0e64328bf387b112ec. The mainline now has a fix cce0be6eb497 ("NFS: Fix a deadlock involving nfs_release_folio()"), so this commit reverts the temporary solution and then merges the mainline patch. Fixes: c28d40c8d3a4 ("[Huawei] Revert "NFS: fix up nfs_release_folio() to try to release the page"") Signed-off-by: Wang Zhaolong <wangzhaolong@huaweicloud.com> Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com> --- fs/nfs/file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 0c4abe38b785..4994b2873970 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -29,6 +29,7 @@ #include <linux/pagemap.h> #include <linux/gfp.h> #include <linux/swap.h> +#include <linux/compaction.h> #include <linux/uaccess.h> #include <linux/filelock.h> @@ -448,8 +449,13 @@ static bool nfs_release_folio(struct folio *folio, gfp_t gfp) dfprintk(PAGECACHE, "NFS: release_folio(%p)\n", folio); /* If the private flag is set, then the folio is not freeable */ - if (folio_test_private(folio)) - return false; + if (folio_test_private(folio)) { + if ((current_gfp_context(gfp) & GFP_KERNEL) != GFP_KERNEL || + current_is_kswapd() || current_is_kcompactd()) + return false; + if (nfs_wb_folio(folio_file_mapping(folio)->host, folio) < 0) + return false; + } return nfs_fscache_release_folio(folio, gfp); } -- 2.52.0