aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/read.c
diff options
context:
space:
mode:
authorFred Isaman <iisaman@netapp.com>2012-04-20 14:47:45 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-04-27 14:10:37 -0400
commit30dd374f6fc1b202db3a1b57b61afff1326bad92 (patch)
tree7d3b631be897dd79a916ee8d410fd2bb92da4890 /fs/nfs/read.c
parentcd841605f7a721878d8a2d1362484723d8abf569 (diff)
NFS: create struct nfs_page_array
Both nfs_read_data and nfs_write_data devote several fields which can be combined into a single shared struct. Signed-off-by: Fred Isaman <iisaman@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r--fs/nfs/read.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index d6d46823d9e4..f6ab30b5a462 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -46,16 +46,10 @@ struct nfs_read_header *nfs_readhdr_alloc(unsigned int pagecount)
46 46
47 INIT_LIST_HEAD(&hdr->pages); 47 INIT_LIST_HEAD(&hdr->pages);
48 INIT_LIST_HEAD(&data->list); 48 INIT_LIST_HEAD(&data->list);
49 data->npages = pagecount;
50 data->header = hdr; 49 data->header = hdr;
51 if (pagecount <= ARRAY_SIZE(data->page_array)) 50 if (!nfs_pgarray_set(&data->pages, pagecount)) {
52 data->pagevec = data->page_array; 51 kmem_cache_free(nfs_rdata_cachep, p);
53 else { 52 p = NULL;
54 data->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_KERNEL);
55 if (!data->pagevec) {
56 kmem_cache_free(nfs_rdata_cachep, p);
57 p = NULL;
58 }
59 } 53 }
60 } 54 }
61 return p; 55 return p;
@@ -71,8 +65,8 @@ void nfs_readhdr_free(struct nfs_pgio_header *hdr)
71void nfs_readdata_release(struct nfs_read_data *rdata) 65void nfs_readdata_release(struct nfs_read_data *rdata)
72{ 66{
73 put_nfs_open_context(rdata->args.context); 67 put_nfs_open_context(rdata->args.context);
74 if (rdata->pagevec != rdata->page_array) 68 if (rdata->pages.pagevec != rdata->pages.page_array)
75 kfree(rdata->pagevec); 69 kfree(rdata->pages.pagevec);
76 nfs_readhdr_free(rdata->header); 70 nfs_readhdr_free(rdata->header);
77} 71}
78 72
@@ -232,7 +226,7 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
232 data->args.fh = NFS_FH(inode); 226 data->args.fh = NFS_FH(inode);
233 data->args.offset = req_offset(req) + offset; 227 data->args.offset = req_offset(req) + offset;
234 data->args.pgbase = req->wb_pgbase + offset; 228 data->args.pgbase = req->wb_pgbase + offset;
235 data->args.pages = data->pagevec; 229 data->args.pages = data->pages.pagevec;
236 data->args.count = count; 230 data->args.count = count;
237 data->args.context = get_nfs_open_context(req->wb_context); 231 data->args.context = get_nfs_open_context(req->wb_context);
238 data->args.lock_context = req->wb_lock_context; 232 data->args.lock_context = req->wb_lock_context;
@@ -318,7 +312,7 @@ static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc, struct list_head
318 if (!rhdr) 312 if (!rhdr)
319 goto out_bad; 313 goto out_bad;
320 data = &rhdr->rpc_data; 314 data = &rhdr->rpc_data;
321 data->pagevec[0] = page; 315 data->pages.pagevec[0] = page;
322 nfs_read_rpcsetup(req, data, len, offset); 316 nfs_read_rpcsetup(req, data, len, offset);
323 list_add(&data->list, res); 317 list_add(&data->list, res);
324 requests++; 318 requests++;
@@ -356,7 +350,7 @@ static int nfs_pagein_one(struct nfs_pageio_descriptor *desc, struct list_head *
356 } 350 }
357 351
358 data = &rhdr->rpc_data; 352 data = &rhdr->rpc_data;
359 pages = data->pagevec; 353 pages = data->pages.pagevec;
360 while (!list_empty(head)) { 354 while (!list_empty(head)) {
361 req = nfs_list_entry(head->next); 355 req = nfs_list_entry(head->next);
362 nfs_list_remove_request(req); 356 nfs_list_remove_request(req);