aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Adamson <andros@netapp.com>2011-03-03 10:13:41 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-03-11 15:38:43 -0500
commitd138d5d17be6a60d883e8bd4e22bc218d3adfab3 (patch)
tree157dcb197e44823b0dc7500b9ba5f691b536402c
parent80fe2b192dbc53261e385dc26d90f5195f1c62e7 (diff)
NFSv4.1: rearrange nfs_write_rpcsetup
Reorder nfs_write_rpcsetup, preparing for a pnfs entry point. Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Fred Isaman <iisaman@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/write.c82
1 files changed, 46 insertions, 36 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index f033fa0d7d33..ae035990941a 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -782,25 +782,21 @@ static int flush_task_priority(int how)
782 return RPC_PRIORITY_NORMAL; 782 return RPC_PRIORITY_NORMAL;
783} 783}
784 784
785/* 785static int nfs_initiate_write(struct nfs_write_data *data,
786 * Set up the argument/result storage required for the RPC call. 786 struct rpc_clnt *clnt,
787 */ 787 const struct rpc_call_ops *call_ops,
788static int nfs_write_rpcsetup(struct nfs_page *req, 788 int how)
789 struct nfs_write_data *data,
790 const struct rpc_call_ops *call_ops,
791 unsigned int count, unsigned int offset,
792 int how)
793{ 789{
794 struct inode *inode = req->wb_context->path.dentry->d_inode; 790 struct inode *inode = data->inode;
795 int priority = flush_task_priority(how); 791 int priority = flush_task_priority(how);
796 struct rpc_task *task; 792 struct rpc_task *task;
797 struct rpc_message msg = { 793 struct rpc_message msg = {
798 .rpc_argp = &data->args, 794 .rpc_argp = &data->args,
799 .rpc_resp = &data->res, 795 .rpc_resp = &data->res,
800 .rpc_cred = req->wb_context->cred, 796 .rpc_cred = data->cred,
801 }; 797 };
802 struct rpc_task_setup task_setup_data = { 798 struct rpc_task_setup task_setup_data = {
803 .rpc_client = NFS_CLIENT(inode), 799 .rpc_client = clnt,
804 .task = &data->task, 800 .task = &data->task,
805 .rpc_message = &msg, 801 .rpc_message = &msg,
806 .callback_ops = call_ops, 802 .callback_ops = call_ops,
@@ -811,12 +807,49 @@ static int nfs_write_rpcsetup(struct nfs_page *req,
811 }; 807 };
812 int ret = 0; 808 int ret = 0;
813 809
810 /* Set up the initial task struct. */
811 NFS_PROTO(inode)->write_setup(data, &msg);
812
813 dprintk("NFS: %5u initiated write call "
814 "(req %s/%lld, %u bytes @ offset %llu)\n",
815 data->task.tk_pid,
816 inode->i_sb->s_id,
817 (long long)NFS_FILEID(inode),
818 data->args.count,
819 (unsigned long long)data->args.offset);
820
821 task = rpc_run_task(&task_setup_data);
822 if (IS_ERR(task)) {
823 ret = PTR_ERR(task);
824 goto out;
825 }
826 if (how & FLUSH_SYNC) {
827 ret = rpc_wait_for_completion_task(task);
828 if (ret == 0)
829 ret = task->tk_status;
830 }
831 rpc_put_task(task);
832out:
833 return ret;
834}
835
836/*
837 * Set up the argument/result storage required for the RPC call.
838 */
839static int nfs_write_rpcsetup(struct nfs_page *req,
840 struct nfs_write_data *data,
841 const struct rpc_call_ops *call_ops,
842 unsigned int count, unsigned int offset,
843 int how)
844{
845 struct inode *inode = req->wb_context->path.dentry->d_inode;
846
814 /* Set up the RPC argument and reply structs 847 /* Set up the RPC argument and reply structs
815 * NB: take care not to mess about with data->commit et al. */ 848 * NB: take care not to mess about with data->commit et al. */
816 849
817 data->req = req; 850 data->req = req;
818 data->inode = inode = req->wb_context->path.dentry->d_inode; 851 data->inode = inode = req->wb_context->path.dentry->d_inode;
819 data->cred = msg.rpc_cred; 852 data->cred = req->wb_context->cred;
820 853
821 data->args.fh = NFS_FH(inode); 854 data->args.fh = NFS_FH(inode);
822 data->args.offset = req_offset(req) + offset; 855 data->args.offset = req_offset(req) + offset;
@@ -837,30 +870,7 @@ static int nfs_write_rpcsetup(struct nfs_page *req,
837 data->res.verf = &data->verf; 870 data->res.verf = &data->verf;
838 nfs_fattr_init(&data->fattr); 871 nfs_fattr_init(&data->fattr);
839 872
840 /* Set up the initial task struct. */ 873 return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how);
841 NFS_PROTO(inode)->write_setup(data, &msg);
842
843 dprintk("NFS: %5u initiated write call "
844 "(req %s/%lld, %u bytes @ offset %llu)\n",
845 data->task.tk_pid,
846 inode->i_sb->s_id,
847 (long long)NFS_FILEID(inode),
848 count,
849 (unsigned long long)data->args.offset);
850
851 task = rpc_run_task(&task_setup_data);
852 if (IS_ERR(task)) {
853 ret = PTR_ERR(task);
854 goto out;
855 }
856 if (how & FLUSH_SYNC) {
857 ret = rpc_wait_for_completion_task(task);
858 if (ret == 0)
859 ret = task->tk_status;
860 }
861 rpc_put_task(task);
862out:
863 return ret;
864} 874}
865 875
866/* If a nfs_flush_* function fails, it should remove reqs from @head and 876/* If a nfs_flush_* function fails, it should remove reqs from @head and