aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/read.c32
-rw-r--r--fs/nfs/write.c32
2 files changed, 62 insertions, 2 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 2da255f0247f..3961524fd4ab 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -40,10 +40,40 @@ static const struct rpc_call_ops nfs_read_partial_ops;
40static const struct rpc_call_ops nfs_read_full_ops; 40static const struct rpc_call_ops nfs_read_full_ops;
41 41
42static kmem_cache_t *nfs_rdata_cachep; 42static kmem_cache_t *nfs_rdata_cachep;
43mempool_t *nfs_rdata_mempool; 43static mempool_t *nfs_rdata_mempool;
44 44
45#define MIN_POOL_READ (32) 45#define MIN_POOL_READ (32)
46 46
47struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
48{
49 struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, SLAB_NOFS);
50
51 if (p) {
52 memset(p, 0, sizeof(*p));
53 INIT_LIST_HEAD(&p->pages);
54 if (pagecount < NFS_PAGEVEC_SIZE)
55 p->pagevec = &p->page_array[0];
56 else {
57 size_t size = ++pagecount * sizeof(struct page *);
58 p->pagevec = kmalloc(size, GFP_NOFS);
59 if (p->pagevec) {
60 memset(p->pagevec, 0, size);
61 } else {
62 mempool_free(p, nfs_rdata_mempool);
63 p = NULL;
64 }
65 }
66 }
67 return p;
68}
69
70void nfs_readdata_free(struct nfs_read_data *p)
71{
72 if (p && (p->pagevec != &p->page_array[0]))
73 kfree(p->pagevec);
74 mempool_free(p, nfs_rdata_mempool);
75}
76
47void nfs_readdata_release(void *data) 77void nfs_readdata_release(void *data)
48{ 78{
49 nfs_readdata_free(data); 79 nfs_readdata_free(data);
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index f7c8be0beccf..647e3217c2e1 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -86,7 +86,7 @@ static const struct rpc_call_ops nfs_write_full_ops;
86static const struct rpc_call_ops nfs_commit_ops; 86static const struct rpc_call_ops nfs_commit_ops;
87 87
88static kmem_cache_t *nfs_wdata_cachep; 88static kmem_cache_t *nfs_wdata_cachep;
89mempool_t *nfs_wdata_mempool; 89static mempool_t *nfs_wdata_mempool;
90static mempool_t *nfs_commit_mempool; 90static mempool_t *nfs_commit_mempool;
91 91
92static DECLARE_WAIT_QUEUE_HEAD(nfs_write_congestion); 92static DECLARE_WAIT_QUEUE_HEAD(nfs_write_congestion);
@@ -119,6 +119,36 @@ void nfs_commit_free(struct nfs_write_data *p)
119 mempool_free(p, nfs_commit_mempool); 119 mempool_free(p, nfs_commit_mempool);
120} 120}
121 121
122struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount)
123{
124 struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, SLAB_NOFS);
125
126 if (p) {
127 memset(p, 0, sizeof(*p));
128 INIT_LIST_HEAD(&p->pages);
129 if (pagecount < NFS_PAGEVEC_SIZE)
130 p->pagevec = &p->page_array[0];
131 else {
132 size_t size = ++pagecount * sizeof(struct page *);
133 p->pagevec = kmalloc(size, GFP_NOFS);
134 if (p->pagevec) {
135 memset(p->pagevec, 0, size);
136 } else {
137 mempool_free(p, nfs_wdata_mempool);
138 p = NULL;
139 }
140 }
141 }
142 return p;
143}
144
145void nfs_writedata_free(struct nfs_write_data *p)
146{
147 if (p && (p->pagevec != &p->page_array[0]))
148 kfree(p->pagevec);
149 mempool_free(p, nfs_wdata_mempool);
150}
151
122void nfs_writedata_release(void *wdata) 152void nfs_writedata_release(void *wdata)
123{ 153{
124 nfs_writedata_free(wdata); 154 nfs_writedata_free(wdata);