Skip to content
Snippets Groups Projects
Commit fa10c640 authored by Trond Myklebust's avatar Trond Myklebust Committed by Yang Yingliang
Browse files

NFS: Ensure NFS writeback allocations don't recurse back into NFS.


mainline inclusion
from mainline-v5.0-rc1
commit 875bc3fb
category: bugfix
bugzilla: NA
CVE: NA

--------------------------------

All the allocations that we can hit in the NFS layer and sunrpc layers
themselves are already marked as GFP_NOFS, but we need to ensure that
any calls to generic kernel functionality do the right thing as well.

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Reviewed-by: default avatarZhang Yi <yi.zhang@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 3e917350
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@
#include <linux/iversion.h>
#include <linux/uaccess.h>
#include <linux/sched/mm.h>
#include "delegation.h"
#include "internal.h"
......@@ -727,11 +728,13 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
{
struct inode *inode = mapping->host;
struct nfs_pageio_descriptor pgio;
struct nfs_io_completion *ioc = nfs_io_completion_alloc(GFP_NOFS);
struct nfs_io_completion *ioc;
unsigned int pflags = memalloc_nofs_save();
int err;
nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES);
ioc = nfs_io_completion_alloc(GFP_NOFS);
if (ioc)
nfs_io_completion_init(ioc, nfs_io_completion_commit, inode);
......@@ -742,6 +745,8 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
nfs_pageio_complete(&pgio);
nfs_io_completion_put(ioc);
memalloc_nofs_restore(pflags);
if (err < 0)
goto out_err;
err = pgio.pg_error;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment