Skip to content

Commit

Permalink
NFS: kswapd must not block in nfs_release_page
Browse files Browse the repository at this point in the history
See https://bugzilla.kernel.org/show_bug.cgi?id=16056

If other processes are blocked waiting for kswapd to free up some memory so
that they can make progress, then we cannot allow kswapd to block on those
processes.

Signed-off-by: Trond Myklebust <[email protected]>
Cc: [email protected]
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Jul 30, 2010
1 parent 674b222 commit b608b28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions fs/nfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/pagemap.h>
#include <linux/aio.h>
#include <linux/gfp.h>
#include <linux/swap.h>

#include <asm/uaccess.h>
#include <asm/system.h>
Expand Down Expand Up @@ -493,11 +494,19 @@ static void nfs_invalidate_page(struct page *page, unsigned long offset)
*/
static int nfs_release_page(struct page *page, gfp_t gfp)
{
struct address_space *mapping = page->mapping;

dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page);

/* Only do I/O if gfp is a superset of GFP_KERNEL */
if ((gfp & GFP_KERNEL) == GFP_KERNEL)
nfs_wb_page(page->mapping->host, page);
if (mapping && (gfp & GFP_KERNEL) == GFP_KERNEL) {
int how = FLUSH_SYNC;

/* Don't let kswapd deadlock waiting for OOM RPC calls */
if (current_is_kswapd())
how = 0;
nfs_commit_inode(mapping->host, how);
}
/* If PagePrivate() is set, then the page is not freeable */
if (PagePrivate(page))
return 0;
Expand Down
4 changes: 2 additions & 2 deletions fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ static const struct rpc_call_ops nfs_commit_ops = {
.rpc_release = nfs_commit_release,
};

static int nfs_commit_inode(struct inode *inode, int how)
int nfs_commit_inode(struct inode *inode, int how)
{
LIST_HEAD(head);
int may_wait = how & FLUSH_SYNC;
Expand Down Expand Up @@ -1443,7 +1443,7 @@ static int nfs_commit_unstable_pages(struct inode *inode, struct writeback_contr
return ret;
}
#else
static int nfs_commit_inode(struct inode *inode, int how)
int nfs_commit_inode(struct inode *inode, int how)
{
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions include/linux/nfs_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ extern int nfs_wb_all(struct inode *inode);
extern int nfs_wb_page(struct inode *inode, struct page* page);
extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
extern int nfs_commit_inode(struct inode *, int);
extern struct nfs_write_data *nfs_commitdata_alloc(void);
extern void nfs_commit_free(struct nfs_write_data *wdata);
#endif
Expand Down

0 comments on commit b608b28

Please sign in to comment.