diff options
author | Anna Schumaker <Anna.Schumaker@netapp.com> | 2014-05-06 09:12:37 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2014-05-29 11:11:40 -0400 |
commit | 1ed26f33008e954a8e91d26f97d4380dea8145db (patch) | |
tree | a187a1fb9658ee39d5c00e71fd6105b7cb6d3f56 /fs/nfs/pagelist.c | |
parent | ef2c488c073f4f0b3a200745dd8d608c01d69c39 (diff) |
NFS: Create a common initiate_pgio() function
Most of this code is the same for both the read and write paths, so
combine everything and use the rw_ops when necessary.
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/pagelist.c')
-rw-r--r-- | fs/nfs/pagelist.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index d8d25a4deb88..ab5b1850ca4f 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
@@ -447,6 +447,52 @@ static void nfs_pgio_prepare(struct rpc_task *task, void *calldata) | |||
447 | rpc_exit(task, err); | 447 | rpc_exit(task, err); |
448 | } | 448 | } |
449 | 449 | ||
450 | int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_data *data, | ||
451 | const struct rpc_call_ops *call_ops, int how, int flags) | ||
452 | { | ||
453 | struct rpc_task *task; | ||
454 | struct rpc_message msg = { | ||
455 | .rpc_argp = &data->args, | ||
456 | .rpc_resp = &data->res, | ||
457 | .rpc_cred = data->header->cred, | ||
458 | }; | ||
459 | struct rpc_task_setup task_setup_data = { | ||
460 | .rpc_client = clnt, | ||
461 | .task = &data->task, | ||
462 | .rpc_message = &msg, | ||
463 | .callback_ops = call_ops, | ||
464 | .callback_data = data, | ||
465 | .workqueue = nfsiod_workqueue, | ||
466 | .flags = RPC_TASK_ASYNC | flags, | ||
467 | }; | ||
468 | int ret = 0; | ||
469 | |||
470 | data->header->rw_ops->rw_initiate(data, &msg, &task_setup_data, how); | ||
471 | |||
472 | dprintk("NFS: %5u initiated pgio call " | ||
473 | "(req %s/%llu, %u bytes @ offset %llu)\n", | ||
474 | data->task.tk_pid, | ||
475 | data->header->inode->i_sb->s_id, | ||
476 | (unsigned long long)NFS_FILEID(data->header->inode), | ||
477 | data->args.count, | ||
478 | (unsigned long long)data->args.offset); | ||
479 | |||
480 | task = rpc_run_task(&task_setup_data); | ||
481 | if (IS_ERR(task)) { | ||
482 | ret = PTR_ERR(task); | ||
483 | goto out; | ||
484 | } | ||
485 | if (how & FLUSH_SYNC) { | ||
486 | ret = rpc_wait_for_completion_task(task); | ||
487 | if (ret == 0) | ||
488 | ret = task->tk_status; | ||
489 | } | ||
490 | rpc_put_task(task); | ||
491 | out: | ||
492 | return ret; | ||
493 | } | ||
494 | EXPORT_SYMBOL_GPL(nfs_initiate_pgio); | ||
495 | |||
450 | /** | 496 | /** |
451 | * nfs_pgio_error - Clean up from a pageio error | 497 | * nfs_pgio_error - Clean up from a pageio error |
452 | * @desc: IO descriptor | 498 | * @desc: IO descriptor |