[PATCH -mmotm 27/30] nfs: fix various memory recursions possible with swap over NFS

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Xiaotian Feng
Date: Tuesday, July 13, 2010 - 3:21 am

From df0106f58d7ac2337f74efb1d8caaf27f635e050 Mon Sep 17 00:00:00 2001
From: Xiaotian Feng <dfeng@redhat.com>
Date: Tue, 13 Jul 2010 13:11:32 +0800
Subject: [PATCH 27/30] nfs: fix various memory recursions possible with swap over NFS.

GFP_NOFS is _more_ permissive than GFP_NOIO in that it will initiate IO,
just not of any filesystem data.

The problem is that previuosly NOFS was correct because that avoids
recursion into the NFS code, it now is not, because also IO (swap) can
lead to this recursion.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
---
 fs/nfs/pagelist.c |    2 +-
 fs/nfs/write.c    |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 2be94bb..c0247e9 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -27,7 +27,7 @@ static inline struct nfs_page *
 nfs_page_alloc(void)
 {
 	struct nfs_page	*p;
-	p = kmem_cache_alloc(nfs_page_cachep, GFP_KERNEL);
+	p = kmem_cache_alloc(nfs_page_cachep, GFP_NOIO);
 	if (p) {
 		memset(p, 0, sizeof(*p));
 		INIT_LIST_HEAD(&p->wb_list);
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 5852b20..dfa08cb 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -50,7 +50,7 @@ static mempool_t *nfs_commit_mempool;
 
 struct nfs_write_data *nfs_commitdata_alloc(void)
 {
-	struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, GFP_NOFS);
+	struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, GFP_NOIO);
 
 	if (p) {
 		memset(p, 0, sizeof(*p));
@@ -69,7 +69,7 @@ void nfs_commit_free(struct nfs_write_data *p)
 
 struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount)
 {
-	struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS);
+	struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOIO);
 
 	if (p) {
 		memset(p, 0, sizeof(*p));
@@ -79,7 +79,7 @@ struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount)
 		if (pagecount <= ARRAY_SIZE(p->page_array))
 			p->pagevec = p->page_array;
 		else {
-			p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_NOFS);
+			p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_NOIO);
 			if (!p->pagevec) {
 				mempool_free(p, nfs_wdata_mempool);
 				p = NULL;
-- 
1.7.1.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH -mmotm 00/30] [RFC] swap over nfs -v21, Xiaotian Feng, (Tue Jul 13, 3:16 am)
[PATCH -mmotm 02/30] Swap over network documentation, Xiaotian Feng, (Tue Jul 13, 3:17 am)
[PATCH -mmotm 03/30] mm: expose gfp_to_alloc_flags(), Xiaotian Feng, (Tue Jul 13, 3:17 am)
[PATCH -mmotm 04/30] mm: tag reseve pages, Xiaotian Feng, (Tue Jul 13, 3:17 am)
[PATCH -mmotm 06/30] mm: kmem_alloc_estimate(), Xiaotian Feng, (Tue Jul 13, 3:17 am)
[PATCH -mmotm 08/30] mm: emergency pool, Xiaotian Feng, (Tue Jul 13, 3:18 am)
[PATCH -mmotm 09/30] mm: system wide ALLOC_NO_WATERMARK, Xiaotian Feng, (Tue Jul 13, 3:18 am)
[PATCH -mmotm 10/30] mm: __GFP_MEMALLOC, Xiaotian Feng, (Tue Jul 13, 3:18 am)
[PATCH -mmotm 11/30] mm: memory reserve management, Xiaotian Feng, (Tue Jul 13, 3:18 am)
[PATCH -mmotm 13/30] net: packet split receive api, Xiaotian Feng, (Tue Jul 13, 3:19 am)
[PATCH -mmotm 16/30] netvm: INET reserves, Xiaotian Feng, (Tue Jul 13, 3:19 am)
[PATCH -mmotm 18/30] netvm: filter emergency skbs, Xiaotian Feng, (Tue Jul 13, 3:20 am)
[PATCH -mmotm 21/30] netvm: skb processing, Xiaotian Feng, (Tue Jul 13, 3:20 am)
[PATCH -mmotm 26/30] nfs: enable swap on NFS, Xiaotian Feng, (Tue Jul 13, 3:21 am)
[PATCH -mmotm 27/30] nfs: fix various memory recursions po ..., Xiaotian Feng, (Tue Jul 13, 3:21 am)
[PATCH -mmotm 28/30] build fix for skb_emergency_protocol, Xiaotian Feng, (Tue Jul 13, 3:22 am)
Re: [PATCH -mmotm 00/30] [RFC] swap over nfs -v21, Américo Wang, (Tue Jul 13, 5:53 am)