diff options
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r-- | fs/nfs/read.c | 32 |
1 files changed, 31 insertions, 1 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; | |||
40 | static const struct rpc_call_ops nfs_read_full_ops; | 40 | static const struct rpc_call_ops nfs_read_full_ops; |
41 | 41 | ||
42 | static kmem_cache_t *nfs_rdata_cachep; | 42 | static kmem_cache_t *nfs_rdata_cachep; |
43 | mempool_t *nfs_rdata_mempool; | 43 | static mempool_t *nfs_rdata_mempool; |
44 | 44 | ||
45 | #define MIN_POOL_READ (32) | 45 | #define MIN_POOL_READ (32) |
46 | 46 | ||
47 | struct 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 | |||
70 | void 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 | |||
47 | void nfs_readdata_release(void *data) | 77 | void nfs_readdata_release(void *data) |
48 | { | 78 | { |
49 | nfs_readdata_free(data); | 79 | nfs_readdata_free(data); |