aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/proc.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:27 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:27 -0500
commit788e7a89a03e364855583c0ab4649b94925efbb9 (patch)
tree4434c93af133a92f550ba0ecc8d3254cb222e72d /fs/nfs/proc.c
parent7117bf3dfb10b534a017260d9fc643bc1d0afd2a (diff)
NFS: Cleanup of NFS write code in preparation for asynchronous o_direct
This patch inverts the callback hierarchy for NFS write calls. Instead of having the NFSv2/v3/v4-specific code set up the RPC callback ops, we allow the original caller to do so. This allows for more flexibility w.r.t. how to set up and tear down the nfs_write_data structure while still allowing the NFSv3/v4 code to perform error handling. The greater flexibility is needed by the asynchronous O_DIRECT code, which wants to be able to hold on to the original nfs_write_data structures after the WRITE RPC call has completed in order to be able to replay them if the COMMIT call determines that the server has rebooted. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/proc.c')
-rw-r--r--fs/nfs/proc.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 2b051ab8bea8..608aa5932a1d 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -654,26 +654,15 @@ nfs_proc_read_setup(struct nfs_read_data *data)
654 rpc_call_setup(task, &msg, 0); 654 rpc_call_setup(task, &msg, 0);
655} 655}
656 656
657static void nfs_write_done(struct rpc_task *task, void *calldata) 657static int nfs_write_done(struct rpc_task *task, struct nfs_write_data *data)
658{ 658{
659 struct nfs_write_data *data = calldata;
660
661 if (task->tk_status >= 0) 659 if (task->tk_status >= 0)
662 nfs_post_op_update_inode(data->inode, data->res.fattr); 660 nfs_post_op_update_inode(data->inode, data->res.fattr);
663 nfs_writeback_done(task, calldata); 661 return 0;
664} 662}
665 663
666static const struct rpc_call_ops nfs_write_ops = { 664static void nfs_proc_write_setup(struct nfs_write_data *data, int how)
667 .rpc_call_done = nfs_write_done,
668 .rpc_release = nfs_writedata_release,
669};
670
671static void
672nfs_proc_write_setup(struct nfs_write_data *data, int how)
673{ 665{
674 struct rpc_task *task = &data->task;
675 struct inode *inode = data->inode;
676 int flags;
677 struct rpc_message msg = { 666 struct rpc_message msg = {
678 .rpc_proc = &nfs_procedures[NFSPROC_WRITE], 667 .rpc_proc = &nfs_procedures[NFSPROC_WRITE],
679 .rpc_argp = &data->args, 668 .rpc_argp = &data->args,
@@ -684,12 +673,8 @@ nfs_proc_write_setup(struct nfs_write_data *data, int how)
684 /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */ 673 /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */
685 data->args.stable = NFS_FILE_SYNC; 674 data->args.stable = NFS_FILE_SYNC;
686 675
687 /* Set the initial flags for the task. */
688 flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
689
690 /* Finalize the task. */ 676 /* Finalize the task. */
691 rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs_write_ops, data); 677 rpc_call_setup(&data->task, &msg, 0);
692 rpc_call_setup(task, &msg, 0);
693} 678}
694 679
695static void 680static void
@@ -736,6 +721,7 @@ struct nfs_rpc_ops nfs_v2_clientops = {
736 .decode_dirent = nfs_decode_dirent, 721 .decode_dirent = nfs_decode_dirent,
737 .read_setup = nfs_proc_read_setup, 722 .read_setup = nfs_proc_read_setup,
738 .write_setup = nfs_proc_write_setup, 723 .write_setup = nfs_proc_write_setup,
724 .write_done = nfs_write_done,
739 .commit_setup = nfs_proc_commit_setup, 725 .commit_setup = nfs_proc_commit_setup,
740 .file_open = nfs_open, 726 .file_open = nfs_open,
741 .file_release = nfs_release, 727 .file_release = nfs_release,