aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorFred Isaman <iisaman@netapp.com>2011-03-03 10:13:48 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-03-11 15:38:44 -0500
commitc76069bda0f17cd3e153e54d9ac01242909c6b15 (patch)
treeb21a8844fdcfbda430cda191c84597393398e461 /fs
parenta69aef1496726ed88386dad65abfcc8cd3195304 (diff)
NFSv4.1: rearrange ->doio args
This will make it possible to clear the lseg pointer in the same function as it is put, instead of in the caller nfs_pageio_doio(). Signed-off-by: Fred Isaman <iisaman@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/pagelist.c10
-rw-r--r--fs/nfs/read.c42
-rw-r--r--fs/nfs/write.c28
3 files changed, 43 insertions, 37 deletions
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 45b0fb8add39..9f628746f5c8 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -214,7 +214,7 @@ nfs_wait_on_request(struct nfs_page *req)
214 */ 214 */
215void nfs_pageio_init(struct nfs_pageio_descriptor *desc, 215void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
216 struct inode *inode, 216 struct inode *inode,
217 int (*doio)(struct inode *, struct list_head *, unsigned int, size_t, int, struct pnfs_layout_segment *), 217 int (*doio)(struct nfs_pageio_descriptor *),
218 size_t bsize, 218 size_t bsize,
219 int io_flags) 219 int io_flags)
220{ 220{
@@ -311,13 +311,7 @@ static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc,
311static void nfs_pageio_doio(struct nfs_pageio_descriptor *desc) 311static void nfs_pageio_doio(struct nfs_pageio_descriptor *desc)
312{ 312{
313 if (!list_empty(&desc->pg_list)) { 313 if (!list_empty(&desc->pg_list)) {
314 int error = desc->pg_doio(desc->pg_inode, 314 int error = desc->pg_doio(desc);
315 &desc->pg_list,
316 nfs_page_array_len(desc->pg_base,
317 desc->pg_count),
318 desc->pg_count,
319 desc->pg_ioflags,
320 desc->pg_lseg);
321 desc->pg_lseg = NULL; 315 desc->pg_lseg = NULL;
322 if (error < 0) 316 if (error < 0)
323 desc->pg_error = error; 317 desc->pg_error = error;
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index f40c7f4dc16b..ab9c7768b7c6 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -31,8 +31,8 @@
31 31
32#define NFSDBG_FACILITY NFSDBG_PAGECACHE 32#define NFSDBG_FACILITY NFSDBG_PAGECACHE
33 33
34static int nfs_pagein_multi(struct inode *, struct list_head *, unsigned int, size_t, int, struct pnfs_layout_segment *); 34static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc);
35static int nfs_pagein_one(struct inode *, struct list_head *, unsigned int, size_t, int, struct pnfs_layout_segment *); 35static int nfs_pagein_one(struct nfs_pageio_descriptor *desc);
36static const struct rpc_call_ops nfs_read_partial_ops; 36static const struct rpc_call_ops nfs_read_partial_ops;
37static const struct rpc_call_ops nfs_read_full_ops; 37static const struct rpc_call_ops nfs_read_full_ops;
38 38
@@ -117,9 +117,9 @@ static void nfs_readpage_truncate_uninitialised_page(struct nfs_read_data *data)
117int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, 117int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
118 struct page *page) 118 struct page *page)
119{ 119{
120 LIST_HEAD(one_request);
121 struct nfs_page *new; 120 struct nfs_page *new;
122 unsigned int len; 121 unsigned int len;
122 struct nfs_pageio_descriptor pgio;
123 123
124 len = nfs_page_length(page); 124 len = nfs_page_length(page);
125 if (len == 0) 125 if (len == 0)
@@ -132,11 +132,14 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
132 if (len < PAGE_CACHE_SIZE) 132 if (len < PAGE_CACHE_SIZE)
133 zero_user_segment(page, len, PAGE_CACHE_SIZE); 133 zero_user_segment(page, len, PAGE_CACHE_SIZE);
134 134
135 nfs_list_add_request(new, &one_request); 135 nfs_pageio_init(&pgio, inode, NULL, 0, 0);
136 nfs_list_add_request(new, &pgio.pg_list);
137 pgio.pg_count = len;
138
136 if (NFS_SERVER(inode)->rsize < PAGE_CACHE_SIZE) 139 if (NFS_SERVER(inode)->rsize < PAGE_CACHE_SIZE)
137 nfs_pagein_multi(inode, &one_request, 1, len, 0, NULL); 140 nfs_pagein_multi(&pgio);
138 else 141 else
139 nfs_pagein_one(inode, &one_request, 1, len, 0, NULL); 142 nfs_pagein_one(&pgio);
140 return 0; 143 return 0;
141} 144}
142 145
@@ -258,20 +261,21 @@ nfs_async_read_error(struct list_head *head)
258 * won't see the new data until our attribute cache is updated. This is more 261 * won't see the new data until our attribute cache is updated. This is more
259 * or less conventional NFS client behavior. 262 * or less conventional NFS client behavior.
260 */ 263 */
261static int nfs_pagein_multi(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int flags, struct pnfs_layout_segment *lseg) 264static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc)
262{ 265{
263 struct nfs_page *req = nfs_list_entry(head->next); 266 struct nfs_page *req = nfs_list_entry(desc->pg_list.next);
264 struct page *page = req->wb_page; 267 struct page *page = req->wb_page;
265 struct nfs_read_data *data; 268 struct nfs_read_data *data;
266 size_t rsize = NFS_SERVER(inode)->rsize, nbytes; 269 size_t rsize = NFS_SERVER(desc->pg_inode)->rsize, nbytes;
267 unsigned int offset; 270 unsigned int offset;
268 int requests = 0; 271 int requests = 0;
269 int ret = 0; 272 int ret = 0;
273 struct pnfs_layout_segment *lseg;
270 LIST_HEAD(list); 274 LIST_HEAD(list);
271 275
272 nfs_list_remove_request(req); 276 nfs_list_remove_request(req);
273 277
274 nbytes = count; 278 nbytes = desc->pg_count;
275 do { 279 do {
276 size_t len = min(nbytes,rsize); 280 size_t len = min(nbytes,rsize);
277 281
@@ -284,11 +288,11 @@ static int nfs_pagein_multi(struct inode *inode, struct list_head *head, unsigne
284 } while(nbytes != 0); 288 } while(nbytes != 0);
285 atomic_set(&req->wb_complete, requests); 289 atomic_set(&req->wb_complete, requests);
286 290
287 /* We know lseg==NULL */ 291 BUG_ON(desc->pg_lseg != NULL);
288 lseg = pnfs_update_layout(inode, req->wb_context, IOMODE_READ); 292 lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_READ);
289 ClearPageError(page); 293 ClearPageError(page);
290 offset = 0; 294 offset = 0;
291 nbytes = count; 295 nbytes = desc->pg_count;
292 do { 296 do {
293 int ret2; 297 int ret2;
294 298
@@ -321,14 +325,17 @@ out_bad:
321 return -ENOMEM; 325 return -ENOMEM;
322} 326}
323 327
324static int nfs_pagein_one(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int flags, struct pnfs_layout_segment *lseg) 328static int nfs_pagein_one(struct nfs_pageio_descriptor *desc)
325{ 329{
326 struct nfs_page *req; 330 struct nfs_page *req;
327 struct page **pages; 331 struct page **pages;
328 struct nfs_read_data *data; 332 struct nfs_read_data *data;
333 struct list_head *head = &desc->pg_list;
334 struct pnfs_layout_segment *lseg = desc->pg_lseg;
329 int ret = -ENOMEM; 335 int ret = -ENOMEM;
330 336
331 data = nfs_readdata_alloc(npages); 337 data = nfs_readdata_alloc(nfs_page_array_len(desc->pg_base,
338 desc->pg_count));
332 if (!data) { 339 if (!data) {
333 nfs_async_read_error(head); 340 nfs_async_read_error(head);
334 goto out; 341 goto out;
@@ -344,9 +351,10 @@ static int nfs_pagein_one(struct inode *inode, struct list_head *head, unsigned
344 } 351 }
345 req = nfs_list_entry(data->pages.next); 352 req = nfs_list_entry(data->pages.next);
346 if ((!lseg) && list_is_singular(&data->pages)) 353 if ((!lseg) && list_is_singular(&data->pages))
347 lseg = pnfs_update_layout(inode, req->wb_context, IOMODE_READ); 354 lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_READ);
348 355
349 ret = nfs_read_rpcsetup(req, data, &nfs_read_full_ops, count, 0, lseg); 356 ret = nfs_read_rpcsetup(req, data, &nfs_read_full_ops, desc->pg_count,
357 0, lseg);
350out: 358out:
351 put_lseg(lseg); 359 put_lseg(lseg);
352 return ret; 360 return ret;
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index ee62ddf60e7a..b74200a2f753 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -898,20 +898,21 @@ static void nfs_redirty_request(struct nfs_page *req)
898 * Generate multiple small requests to write out a single 898 * Generate multiple small requests to write out a single
899 * contiguous dirty area on one page. 899 * contiguous dirty area on one page.
900 */ 900 */
901static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int how, struct pnfs_layout_segment *lseg) 901static int nfs_flush_multi(struct nfs_pageio_descriptor *desc)
902{ 902{
903 struct nfs_page *req = nfs_list_entry(head->next); 903 struct nfs_page *req = nfs_list_entry(desc->pg_list.next);
904 struct page *page = req->wb_page; 904 struct page *page = req->wb_page;
905 struct nfs_write_data *data; 905 struct nfs_write_data *data;
906 size_t wsize = NFS_SERVER(inode)->wsize, nbytes; 906 size_t wsize = NFS_SERVER(desc->pg_inode)->wsize, nbytes;
907 unsigned int offset; 907 unsigned int offset;
908 int requests = 0; 908 int requests = 0;
909 int ret = 0; 909 int ret = 0;
910 struct pnfs_layout_segment *lseg;
910 LIST_HEAD(list); 911 LIST_HEAD(list);
911 912
912 nfs_list_remove_request(req); 913 nfs_list_remove_request(req);
913 914
914 nbytes = count; 915 nbytes = desc->pg_count;
915 do { 916 do {
916 size_t len = min(nbytes, wsize); 917 size_t len = min(nbytes, wsize);
917 918
@@ -924,11 +925,11 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned
924 } while (nbytes != 0); 925 } while (nbytes != 0);
925 atomic_set(&req->wb_complete, requests); 926 atomic_set(&req->wb_complete, requests);
926 927
927 BUG_ON(lseg); 928 BUG_ON(desc->pg_lseg);
928 lseg = pnfs_update_layout(inode, req->wb_context, IOMODE_RW); 929 lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_RW);
929 ClearPageError(page); 930 ClearPageError(page);
930 offset = 0; 931 offset = 0;
931 nbytes = count; 932 nbytes = desc->pg_count;
932 do { 933 do {
933 int ret2; 934 int ret2;
934 935
@@ -940,7 +941,7 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned
940 if (nbytes < wsize) 941 if (nbytes < wsize)
941 wsize = nbytes; 942 wsize = nbytes;
942 ret2 = nfs_write_rpcsetup(req, data, &nfs_write_partial_ops, 943 ret2 = nfs_write_rpcsetup(req, data, &nfs_write_partial_ops,
943 wsize, offset, lseg, how); 944 wsize, offset, lseg, desc->pg_ioflags);
944 if (ret == 0) 945 if (ret == 0)
945 ret = ret2; 946 ret = ret2;
946 offset += wsize; 947 offset += wsize;
@@ -968,14 +969,17 @@ out_bad:
968 * This is the case if nfs_updatepage detects a conflicting request 969 * This is the case if nfs_updatepage detects a conflicting request
969 * that has been written but not committed. 970 * that has been written but not committed.
970 */ 971 */
971static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int how, struct pnfs_layout_segment *lseg) 972static int nfs_flush_one(struct nfs_pageio_descriptor *desc)
972{ 973{
973 struct nfs_page *req; 974 struct nfs_page *req;
974 struct page **pages; 975 struct page **pages;
975 struct nfs_write_data *data; 976 struct nfs_write_data *data;
977 struct list_head *head = &desc->pg_list;
978 struct pnfs_layout_segment *lseg = desc->pg_lseg;
976 int ret; 979 int ret;
977 980
978 data = nfs_writedata_alloc(npages); 981 data = nfs_writedata_alloc(nfs_page_array_len(desc->pg_base,
982 desc->pg_count));
979 if (!data) { 983 if (!data) {
980 while (!list_empty(head)) { 984 while (!list_empty(head)) {
981 req = nfs_list_entry(head->next); 985 req = nfs_list_entry(head->next);
@@ -995,10 +999,10 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i
995 } 999 }
996 req = nfs_list_entry(data->pages.next); 1000 req = nfs_list_entry(data->pages.next);
997 if ((!lseg) && list_is_singular(&data->pages)) 1001 if ((!lseg) && list_is_singular(&data->pages))
998 lseg = pnfs_update_layout(inode, req->wb_context, IOMODE_RW); 1002 lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_RW);
999 1003
1000 /* Set up the argument struct */ 1004 /* Set up the argument struct */
1001 ret = nfs_write_rpcsetup(req, data, &nfs_write_full_ops, count, 0, lseg, how); 1005 ret = nfs_write_rpcsetup(req, data, &nfs_write_full_ops, desc->pg_count, 0, lseg, desc->pg_ioflags);
1002out: 1006out:
1003 put_lseg(lseg); /* Cleans any gotten in ->pg_test */ 1007 put_lseg(lseg); /* Cleans any gotten in ->pg_test */
1004 return ret; 1008 return ret;