summaryrefslogtreecommitdiffstats
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)
downloadlinux-30dd374f6fc1b202db3a1b57b61afff1326bad92.tar.bz2
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)
INIT_LIST_HEAD(&hdr->pages);
INIT_LIST_HEAD(&data->list);
- data->npages = pagecount;
data->header = hdr;
- if (pagecount <= ARRAY_SIZE(data->page_array))
- data->pagevec = data->page_array;
- else {
- data->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_KERNEL);
- if (!data->pagevec) {
- kmem_cache_free(nfs_rdata_cachep, p);
- p = NULL;
- }
+ if (!nfs_pgarray_set(&data->pages, pagecount)) {
+ kmem_cache_free(nfs_rdata_cachep, p);
+ p = NULL;
}
}
return p;
@@ -71,8 +65,8 @@ void nfs_readhdr_free(struct nfs_pgio_header *hdr)
void nfs_readdata_release(struct nfs_read_data *rdata)
{
put_nfs_open_context(rdata->args.context);
- if (rdata->pagevec != rdata->page_array)
- kfree(rdata->pagevec);
+ if (rdata->pages.pagevec != rdata->pages.page_array)
+ kfree(rdata->pages.pagevec);
nfs_readhdr_free(rdata->header);
}
@@ -232,7 +226,7 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
data->args.fh = NFS_FH(inode);
data->args.offset = req_offset(req) + offset;
data->args.pgbase = req->wb_pgbase + offset;
- data->args.pages = data->pagevec;
+ data->args.pages = data->pages.pagevec;
data->args.count = count;
data->args.context = get_nfs_open_context(req->wb_context);
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
if (!rhdr)
goto out_bad;
data = &rhdr->rpc_data;
- data->pagevec[0] = page;
+ data->pages.pagevec[0] = page;
nfs_read_rpcsetup(req, data, len, offset);
list_add(&data->list, res);
requests++;
@@ -356,7 +350,7 @@ static int nfs_pagein_one(struct nfs_pageio_descriptor *desc, struct list_head *
}
data = &rhdr->rpc_data;
- pages = data->pagevec;
+ pages = data->pages.pagevec;
while (!list_empty(head)) {
req = nfs_list_entry(head->next);
nfs_list_remove_request(req);