aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/write.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/write.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/write.c')
-rw-r--r--fs/nfs/write.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index dbb5c0a613b8..2efae049b4f0 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -80,16 +80,10 @@ struct nfs_write_header *nfs_writehdr_alloc(unsigned int pagecount)
80 memset(p, 0, sizeof(*p)); 80 memset(p, 0, sizeof(*p));
81 INIT_LIST_HEAD(&hdr->pages); 81 INIT_LIST_HEAD(&hdr->pages);
82 INIT_LIST_HEAD(&data->list); 82 INIT_LIST_HEAD(&data->list);
83 data->npages = pagecount;
84 data->header = hdr; 83 data->header = hdr;
85 if (pagecount <= ARRAY_SIZE(data->page_array)) 84 if (!nfs_pgarray_set(&data->pages, pagecount)) {
86 data->pagevec = data->page_array; 85 mempool_free(p, nfs_wdata_mempool);
87 else { 86 p = NULL;
88 data->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_NOFS);
89 if (!data->pagevec) {
90 mempool_free(p, nfs_wdata_mempool);
91 p = NULL;
92 }
93 } 87 }
94 } 88 }
95 return p; 89 return p;
@@ -104,8 +98,8 @@ void nfs_writehdr_free(struct nfs_pgio_header *hdr)
104void nfs_writedata_release(struct nfs_write_data *wdata) 98void nfs_writedata_release(struct nfs_write_data *wdata)
105{ 99{
106 put_nfs_open_context(wdata->args.context); 100 put_nfs_open_context(wdata->args.context);
107 if (wdata->pagevec != wdata->page_array) 101 if (wdata->pages.pagevec != wdata->pages.page_array)
108 kfree(wdata->pagevec); 102 kfree(wdata->pages.pagevec);
109 nfs_writehdr_free(wdata->header); 103 nfs_writehdr_free(wdata->header);
110} 104}
111 105
@@ -916,7 +910,7 @@ static void nfs_write_rpcsetup(struct nfs_page *req,
916 /* pnfs_set_layoutcommit needs this */ 910 /* pnfs_set_layoutcommit needs this */
917 data->mds_offset = data->args.offset; 911 data->mds_offset = data->args.offset;
918 data->args.pgbase = req->wb_pgbase + offset; 912 data->args.pgbase = req->wb_pgbase + offset;
919 data->args.pages = data->pagevec; 913 data->args.pages = data->pages.pagevec;
920 data->args.count = count; 914 data->args.count = count;
921 data->args.context = get_nfs_open_context(req->wb_context); 915 data->args.context = get_nfs_open_context(req->wb_context);
922 data->args.lock_context = req->wb_lock_context; 916 data->args.lock_context = req->wb_lock_context;
@@ -1011,7 +1005,7 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc, struct list_head
1011 if (!whdr) 1005 if (!whdr)
1012 goto out_bad; 1006 goto out_bad;
1013 data = &whdr->rpc_data; 1007 data = &whdr->rpc_data;
1014 data->pagevec[0] = page; 1008 data->pages.pagevec[0] = page;
1015 nfs_write_rpcsetup(req, data, len, offset, desc->pg_ioflags); 1009 nfs_write_rpcsetup(req, data, len, offset, desc->pg_ioflags);
1016 list_add(&data->list, res); 1010 list_add(&data->list, res);
1017 requests++; 1011 requests++;
@@ -1061,7 +1055,7 @@ static int nfs_flush_one(struct nfs_pageio_descriptor *desc, struct list_head *r
1061 goto out; 1055 goto out;
1062 } 1056 }
1063 data = &whdr->rpc_data; 1057 data = &whdr->rpc_data;
1064 pages = data->pagevec; 1058 pages = data->pages.pagevec;
1065 while (!list_empty(head)) { 1059 while (!list_empty(head)) {
1066 req = nfs_list_entry(head->next); 1060 req = nfs_list_entry(head->next);
1067 nfs_list_remove_request(req); 1061 nfs_list_remove_request(req);