aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/read.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2011-07-12 13:42:02 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-07-12 13:42:02 -0400
commit6e4efd568574221840ee8dd86f176dc977c1330c (patch)
treeb43afc1ae5400bbadbc122d2bfb5a69b3a26e7f8 /fs/nfs/read.c
parent87ed5eb44ad9338b1617a0e78dea81d681325298 (diff)
NFS: Clean up nfs_read_rpcsetup and nfs_write_rpcsetup
Split them up into two parts: one which sets up the struct nfs_read/write_data, the other which sets up the actual RPC call or pNFS call. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r--fs/nfs/read.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index c394662c790e..248a55425853 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -213,17 +213,14 @@ EXPORT_SYMBOL_GPL(nfs_initiate_read);
213/* 213/*
214 * Set up the NFS read request struct 214 * Set up the NFS read request struct
215 */ 215 */
216static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data, 216static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
217 const struct rpc_call_ops *call_ops, 217 unsigned int count, unsigned int offset)
218 unsigned int count, unsigned int offset,
219 struct pnfs_layout_segment *lseg)
220{ 218{
221 struct inode *inode = req->wb_context->path.dentry->d_inode; 219 struct inode *inode = req->wb_context->path.dentry->d_inode;
222 220
223 data->req = req; 221 data->req = req;
224 data->inode = inode; 222 data->inode = inode;
225 data->cred = req->wb_context->cred; 223 data->cred = req->wb_context->cred;
226 data->lseg = get_lseg(lseg);
227 224
228 data->args.fh = NFS_FH(inode); 225 data->args.fh = NFS_FH(inode);
229 data->args.offset = req_offset(req) + offset; 226 data->args.offset = req_offset(req) + offset;
@@ -237,10 +234,21 @@ static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
237 data->res.count = count; 234 data->res.count = count;
238 data->res.eof = 0; 235 data->res.eof = 0;
239 nfs_fattr_init(&data->fattr); 236 nfs_fattr_init(&data->fattr);
237}
240 238
241 if (data->lseg && 239static int nfs_do_read(struct nfs_read_data *data,
242 (pnfs_try_to_read_data(data, call_ops) == PNFS_ATTEMPTED)) 240 const struct rpc_call_ops *call_ops,
243 return 0; 241 struct pnfs_layout_segment *lseg)
242{
243 struct inode *inode = data->args.context->path.dentry->d_inode;
244
245 if (lseg) {
246 data->lseg = get_lseg(lseg);
247 if (pnfs_try_to_read_data(data, call_ops) == PNFS_ATTEMPTED)
248 return 0;
249 put_lseg(data->lseg);
250 data->lseg = NULL;
251 }
244 252
245 return nfs_initiate_read(data, NFS_CLIENT(inode), call_ops); 253 return nfs_initiate_read(data, NFS_CLIENT(inode), call_ops);
246} 254}
@@ -292,7 +300,7 @@ static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc)
292 data = nfs_readdata_alloc(1); 300 data = nfs_readdata_alloc(1);
293 if (!data) 301 if (!data)
294 goto out_bad; 302 goto out_bad;
295 list_add(&data->pages, &list); 303 list_add(&data->list, &list);
296 requests++; 304 requests++;
297 nbytes -= len; 305 nbytes -= len;
298 } while(nbytes != 0); 306 } while(nbytes != 0);
@@ -304,15 +312,15 @@ static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc)
304 do { 312 do {
305 int ret2; 313 int ret2;
306 314
307 data = list_entry(list.next, struct nfs_read_data, pages); 315 data = list_entry(list.next, struct nfs_read_data, list);
308 list_del_init(&data->pages); 316 list_del_init(&data->list);
309 317
310 data->pagevec[0] = page; 318 data->pagevec[0] = page;
311 319
312 if (nbytes < rsize) 320 if (nbytes < rsize)
313 rsize = nbytes; 321 rsize = nbytes;
314 ret2 = nfs_read_rpcsetup(req, data, &nfs_read_partial_ops, 322 nfs_read_rpcsetup(req, data, rsize, offset);
315 rsize, offset, lseg); 323 ret2 = nfs_do_read(data, &nfs_read_partial_ops, lseg);
316 if (ret == 0) 324 if (ret == 0)
317 ret = ret2; 325 ret = ret2;
318 offset += rsize; 326 offset += rsize;
@@ -325,8 +333,8 @@ static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc)
325 333
326out_bad: 334out_bad:
327 while (!list_empty(&list)) { 335 while (!list_empty(&list)) {
328 data = list_entry(list.next, struct nfs_read_data, pages); 336 data = list_entry(list.next, struct nfs_read_data, list);
329 list_del(&data->pages); 337 list_del(&data->list);
330 nfs_readdata_free(data); 338 nfs_readdata_free(data);
331 } 339 }
332 SetPageError(page); 340 SetPageError(page);
@@ -362,8 +370,8 @@ static int nfs_pagein_one(struct nfs_pageio_descriptor *desc)
362 } 370 }
363 req = nfs_list_entry(data->pages.next); 371 req = nfs_list_entry(data->pages.next);
364 372
365 ret = nfs_read_rpcsetup(req, data, &nfs_read_full_ops, desc->pg_count, 373 nfs_read_rpcsetup(req, data, desc->pg_count, 0);
366 0, lseg); 374 ret = nfs_do_read(data, &nfs_read_full_ops, lseg);
367out: 375out:
368 put_lseg(lseg); 376 put_lseg(lseg);
369 desc->pg_lseg = NULL; 377 desc->pg_lseg = NULL;