aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/read.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r--fs/nfs/read.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index fd58e909842b..8b48ec63f722 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -35,16 +35,13 @@ static const struct rpc_call_ops nfs_read_partial_ops;
35static const struct rpc_call_ops nfs_read_full_ops; 35static const struct rpc_call_ops nfs_read_full_ops;
36 36
37static struct kmem_cache *nfs_rdata_cachep; 37static struct kmem_cache *nfs_rdata_cachep;
38static mempool_t *nfs_rdata_mempool;
39
40#define MIN_POOL_READ (32)
41 38
42struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount) 39struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
43{ 40{
44 struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, GFP_KERNEL); 41 struct nfs_read_data *p;
45 42
43 p = kmem_cache_zalloc(nfs_rdata_cachep, GFP_KERNEL);
46 if (p) { 44 if (p) {
47 memset(p, 0, sizeof(*p));
48 INIT_LIST_HEAD(&p->pages); 45 INIT_LIST_HEAD(&p->pages);
49 p->npages = pagecount; 46 p->npages = pagecount;
50 if (pagecount <= ARRAY_SIZE(p->page_array)) 47 if (pagecount <= ARRAY_SIZE(p->page_array))
@@ -52,7 +49,7 @@ struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
52 else { 49 else {
53 p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_KERNEL); 50 p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_KERNEL);
54 if (!p->pagevec) { 51 if (!p->pagevec) {
55 mempool_free(p, nfs_rdata_mempool); 52 kmem_cache_free(nfs_rdata_cachep, p);
56 p = NULL; 53 p = NULL;
57 } 54 }
58 } 55 }
@@ -64,7 +61,7 @@ void nfs_readdata_free(struct nfs_read_data *p)
64{ 61{
65 if (p && (p->pagevec != &p->page_array[0])) 62 if (p && (p->pagevec != &p->page_array[0]))
66 kfree(p->pagevec); 63 kfree(p->pagevec);
67 mempool_free(p, nfs_rdata_mempool); 64 kmem_cache_free(nfs_rdata_cachep, p);
68} 65}
69 66
70void nfs_readdata_release(struct nfs_read_data *rdata) 67void nfs_readdata_release(struct nfs_read_data *rdata)
@@ -716,16 +713,10 @@ int __init nfs_init_readpagecache(void)
716 if (nfs_rdata_cachep == NULL) 713 if (nfs_rdata_cachep == NULL)
717 return -ENOMEM; 714 return -ENOMEM;
718 715
719 nfs_rdata_mempool = mempool_create_slab_pool(MIN_POOL_READ,
720 nfs_rdata_cachep);
721 if (nfs_rdata_mempool == NULL)
722 return -ENOMEM;
723
724 return 0; 716 return 0;
725} 717}
726 718
727void nfs_destroy_readpagecache(void) 719void nfs_destroy_readpagecache(void)
728{ 720{
729 mempool_destroy(nfs_rdata_mempool);
730 kmem_cache_destroy(nfs_rdata_cachep); 721 kmem_cache_destroy(nfs_rdata_cachep);
731} 722}