aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/read.c32
-rw-r--r--fs/nfs/write.c32
-rw-r--r--include/linux/nfs_fs.h67
3 files changed, 66 insertions, 65 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);
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 9f84c8a5ea43..55de0770df4a 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -462,37 +462,8 @@ static inline int nfs_wb_page(struct inode *inode, struct page* page)
462/* 462/*
463 * Allocate and free nfs_write_data structures 463 * Allocate and free nfs_write_data structures
464 */ 464 */
465extern mempool_t *nfs_wdata_mempool; 465extern struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount);
466 466extern void nfs_writedata_free(struct nfs_write_data *p);
467static inline struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount)
468{
469 struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, SLAB_NOFS);
470
471 if (p) {
472 memset(p, 0, sizeof(*p));
473 INIT_LIST_HEAD(&p->pages);
474 if (pagecount < NFS_PAGEVEC_SIZE)
475 p->pagevec = &p->page_array[0];
476 else {
477 size_t size = ++pagecount * sizeof(struct page *);
478 p->pagevec = kmalloc(size, GFP_NOFS);
479 if (p->pagevec) {
480 memset(p->pagevec, 0, size);
481 } else {
482 mempool_free(p, nfs_wdata_mempool);
483 p = NULL;
484 }
485 }
486 }
487 return p;
488}
489
490static inline void nfs_writedata_free(struct nfs_write_data *p)
491{
492 if (p && (p->pagevec != &p->page_array[0]))
493 kfree(p->pagevec);
494 mempool_free(p, nfs_wdata_mempool);
495}
496 467
497/* 468/*
498 * linux/fs/nfs/read.c 469 * linux/fs/nfs/read.c
@@ -503,41 +474,11 @@ extern int nfs_readpages(struct file *, struct address_space *,
503extern int nfs_readpage_result(struct rpc_task *, struct nfs_read_data *); 474extern int nfs_readpage_result(struct rpc_task *, struct nfs_read_data *);
504extern void nfs_readdata_release(void *data); 475extern void nfs_readdata_release(void *data);
505 476
506
507/* 477/*
508 * Allocate and free nfs_read_data structures 478 * Allocate and free nfs_read_data structures
509 */ 479 */
510extern mempool_t *nfs_rdata_mempool; 480extern struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount);
511 481extern void nfs_readdata_free(struct nfs_read_data *p);
512static inline struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
513{
514 struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, SLAB_NOFS);
515
516 if (p) {
517 memset(p, 0, sizeof(*p));
518 INIT_LIST_HEAD(&p->pages);
519 if (pagecount < NFS_PAGEVEC_SIZE)
520 p->pagevec = &p->page_array[0];
521 else {
522 size_t size = ++pagecount * sizeof(struct page *);
523 p->pagevec = kmalloc(size, GFP_NOFS);
524 if (p->pagevec) {
525 memset(p->pagevec, 0, size);
526 } else {
527 mempool_free(p, nfs_rdata_mempool);
528 p = NULL;
529 }
530 }
531 }
532 return p;
533}
534
535static inline void nfs_readdata_free(struct nfs_read_data *p)
536{
537 if (p && (p->pagevec != &p->page_array[0]))
538 kfree(p->pagevec);
539 mempool_free(p, nfs_rdata_mempool);
540}
541 482
542/* 483/*
543 * linux/fs/nfs3proc.c 484 * linux/fs/nfs3proc.c