diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-20 13:44:37 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-20 13:44:37 -0500 |
commit | 3feb2d49394b7874348a6e43c076b780c1d222c5 (patch) | |
tree | 6d27d4170fd9435574bd804033793f9d0d69a355 /fs/nfs | |
parent | 5db3a7b2cabe8f0957683f798c4f8fa8605f9ebb (diff) |
NFS: Uninline nfs_writedata_(alloc|free) and nfs_readdata_(alloc|free)
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/read.c | 32 | ||||
-rw-r--r-- | fs/nfs/write.c | 32 |
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; | |||
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); |
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; | |||
86 | static const struct rpc_call_ops nfs_commit_ops; | 86 | static const struct rpc_call_ops nfs_commit_ops; |
87 | 87 | ||
88 | static kmem_cache_t *nfs_wdata_cachep; | 88 | static kmem_cache_t *nfs_wdata_cachep; |
89 | mempool_t *nfs_wdata_mempool; | 89 | static mempool_t *nfs_wdata_mempool; |
90 | static mempool_t *nfs_commit_mempool; | 90 | static mempool_t *nfs_commit_mempool; |
91 | 91 | ||
92 | static DECLARE_WAIT_QUEUE_HEAD(nfs_write_congestion); | 92 | static 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 | ||
122 | struct 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 | |||
145 | void 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 | |||
122 | void nfs_writedata_release(void *wdata) | 152 | void nfs_writedata_release(void *wdata) |
123 | { | 153 | { |
124 | nfs_writedata_free(wdata); | 154 | nfs_writedata_free(wdata); |