diff options
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r-- | fs/nfs/write.c | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 8d90e90ccd47..9a69469274ae 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -764,6 +764,16 @@ static int flush_task_priority(int how) | |||
764 | return RPC_PRIORITY_NORMAL; | 764 | return RPC_PRIORITY_NORMAL; |
765 | } | 765 | } |
766 | 766 | ||
767 | static void nfs_execute_write(struct nfs_write_data *data) | ||
768 | { | ||
769 | struct rpc_clnt *clnt = NFS_CLIENT(data->inode); | ||
770 | sigset_t oldset; | ||
771 | |||
772 | rpc_clnt_sigmask(clnt, &oldset); | ||
773 | rpc_execute(&data->task); | ||
774 | rpc_clnt_sigunmask(clnt, &oldset); | ||
775 | } | ||
776 | |||
767 | /* | 777 | /* |
768 | * Set up the argument/result storage required for the RPC call. | 778 | * Set up the argument/result storage required for the RPC call. |
769 | */ | 779 | */ |
@@ -776,8 +786,14 @@ static void nfs_write_rpcsetup(struct nfs_page *req, | |||
776 | struct inode *inode = req->wb_context->path.dentry->d_inode; | 786 | struct inode *inode = req->wb_context->path.dentry->d_inode; |
777 | int flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; | 787 | int flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; |
778 | int priority = flush_task_priority(how); | 788 | int priority = flush_task_priority(how); |
789 | struct rpc_message msg = { | ||
790 | .rpc_argp = &data->args, | ||
791 | .rpc_resp = &data->res, | ||
792 | .rpc_cred = req->wb_context->cred, | ||
793 | }; | ||
779 | struct rpc_task_setup task_setup_data = { | 794 | struct rpc_task_setup task_setup_data = { |
780 | .rpc_client = NFS_CLIENT(inode), | 795 | .rpc_client = NFS_CLIENT(inode), |
796 | .rpc_message = &msg, | ||
781 | .callback_ops = call_ops, | 797 | .callback_ops = call_ops, |
782 | .callback_data = data, | 798 | .callback_data = data, |
783 | .flags = flags, | 799 | .flags = flags, |
@@ -789,7 +805,7 @@ static void nfs_write_rpcsetup(struct nfs_page *req, | |||
789 | 805 | ||
790 | data->req = req; | 806 | data->req = req; |
791 | data->inode = inode = req->wb_context->path.dentry->d_inode; | 807 | data->inode = inode = req->wb_context->path.dentry->d_inode; |
792 | data->cred = req->wb_context->cred; | 808 | data->cred = msg.rpc_cred; |
793 | 809 | ||
794 | data->args.fh = NFS_FH(inode); | 810 | data->args.fh = NFS_FH(inode); |
795 | data->args.offset = req_offset(req) + offset; | 811 | data->args.offset = req_offset(req) + offset; |
@@ -797,6 +813,12 @@ static void nfs_write_rpcsetup(struct nfs_page *req, | |||
797 | data->args.pages = data->pagevec; | 813 | data->args.pages = data->pagevec; |
798 | data->args.count = count; | 814 | data->args.count = count; |
799 | data->args.context = req->wb_context; | 815 | data->args.context = req->wb_context; |
816 | data->args.stable = NFS_UNSTABLE; | ||
817 | if (how & FLUSH_STABLE) { | ||
818 | data->args.stable = NFS_DATA_SYNC; | ||
819 | if (!NFS_I(inode)->ncommit) | ||
820 | data->args.stable = NFS_FILE_SYNC; | ||
821 | } | ||
800 | 822 | ||
801 | data->res.fattr = &data->fattr; | 823 | data->res.fattr = &data->fattr; |
802 | data->res.count = count; | 824 | data->res.count = count; |
@@ -804,8 +826,8 @@ static void nfs_write_rpcsetup(struct nfs_page *req, | |||
804 | nfs_fattr_init(&data->fattr); | 826 | nfs_fattr_init(&data->fattr); |
805 | 827 | ||
806 | /* Set up the initial task struct. */ | 828 | /* Set up the initial task struct. */ |
829 | NFS_PROTO(inode)->write_setup(data, &msg); | ||
807 | rpc_init_task(&data->task, &task_setup_data); | 830 | rpc_init_task(&data->task, &task_setup_data); |
808 | NFS_PROTO(inode)->write_setup(data, how); | ||
809 | 831 | ||
810 | dprintk("NFS: %5u initiated write call " | 832 | dprintk("NFS: %5u initiated write call " |
811 | "(req %s/%Ld, %u bytes @ offset %Lu)\n", | 833 | "(req %s/%Ld, %u bytes @ offset %Lu)\n", |
@@ -814,16 +836,8 @@ static void nfs_write_rpcsetup(struct nfs_page *req, | |||
814 | (long long)NFS_FILEID(inode), | 836 | (long long)NFS_FILEID(inode), |
815 | count, | 837 | count, |
816 | (unsigned long long)data->args.offset); | 838 | (unsigned long long)data->args.offset); |
817 | } | ||
818 | 839 | ||
819 | static void nfs_execute_write(struct nfs_write_data *data) | 840 | nfs_execute_write(data); |
820 | { | ||
821 | struct rpc_clnt *clnt = NFS_CLIENT(data->inode); | ||
822 | sigset_t oldset; | ||
823 | |||
824 | rpc_clnt_sigmask(clnt, &oldset); | ||
825 | rpc_execute(&data->task); | ||
826 | rpc_clnt_sigunmask(clnt, &oldset); | ||
827 | } | 841 | } |
828 | 842 | ||
829 | /* | 843 | /* |
@@ -870,7 +884,6 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned | |||
870 | wsize, offset, how); | 884 | wsize, offset, how); |
871 | offset += wsize; | 885 | offset += wsize; |
872 | nbytes -= wsize; | 886 | nbytes -= wsize; |
873 | nfs_execute_write(data); | ||
874 | } while (nbytes != 0); | 887 | } while (nbytes != 0); |
875 | 888 | ||
876 | return 0; | 889 | return 0; |
@@ -918,7 +931,6 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i | |||
918 | /* Set up the argument struct */ | 931 | /* Set up the argument struct */ |
919 | nfs_write_rpcsetup(req, data, &nfs_write_full_ops, count, 0, how); | 932 | nfs_write_rpcsetup(req, data, &nfs_write_full_ops, count, 0, how); |
920 | 933 | ||
921 | nfs_execute_write(data); | ||
922 | return 0; | 934 | return 0; |
923 | out_bad: | 935 | out_bad: |
924 | while (!list_empty(head)) { | 936 | while (!list_empty(head)) { |
@@ -1152,8 +1164,14 @@ static void nfs_commit_rpcsetup(struct list_head *head, | |||
1152 | struct inode *inode = first->wb_context->path.dentry->d_inode; | 1164 | struct inode *inode = first->wb_context->path.dentry->d_inode; |
1153 | int flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; | 1165 | int flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; |
1154 | int priority = flush_task_priority(how); | 1166 | int priority = flush_task_priority(how); |
1167 | struct rpc_message msg = { | ||
1168 | .rpc_argp = &data->args, | ||
1169 | .rpc_resp = &data->res, | ||
1170 | .rpc_cred = first->wb_context->cred, | ||
1171 | }; | ||
1155 | struct rpc_task_setup task_setup_data = { | 1172 | struct rpc_task_setup task_setup_data = { |
1156 | .rpc_client = NFS_CLIENT(inode), | 1173 | .rpc_client = NFS_CLIENT(inode), |
1174 | .rpc_message = &msg, | ||
1157 | .callback_ops = &nfs_commit_ops, | 1175 | .callback_ops = &nfs_commit_ops, |
1158 | .callback_data = data, | 1176 | .callback_data = data, |
1159 | .flags = flags, | 1177 | .flags = flags, |
@@ -1166,7 +1184,7 @@ static void nfs_commit_rpcsetup(struct list_head *head, | |||
1166 | list_splice_init(head, &data->pages); | 1184 | list_splice_init(head, &data->pages); |
1167 | 1185 | ||
1168 | data->inode = inode; | 1186 | data->inode = inode; |
1169 | data->cred = first->wb_context->cred; | 1187 | data->cred = msg.rpc_cred; |
1170 | 1188 | ||
1171 | data->args.fh = NFS_FH(data->inode); | 1189 | data->args.fh = NFS_FH(data->inode); |
1172 | /* Note: we always request a commit of the entire inode */ | 1190 | /* Note: we always request a commit of the entire inode */ |
@@ -1178,10 +1196,12 @@ static void nfs_commit_rpcsetup(struct list_head *head, | |||
1178 | nfs_fattr_init(&data->fattr); | 1196 | nfs_fattr_init(&data->fattr); |
1179 | 1197 | ||
1180 | /* Set up the initial task struct. */ | 1198 | /* Set up the initial task struct. */ |
1199 | NFS_PROTO(inode)->commit_setup(data, &msg); | ||
1181 | rpc_init_task(&data->task, &task_setup_data); | 1200 | rpc_init_task(&data->task, &task_setup_data); |
1182 | NFS_PROTO(inode)->commit_setup(data, how); | ||
1183 | 1201 | ||
1184 | dprintk("NFS: %5u initiated commit call\n", data->task.tk_pid); | 1202 | dprintk("NFS: %5u initiated commit call\n", data->task.tk_pid); |
1203 | |||
1204 | nfs_execute_write(data); | ||
1185 | } | 1205 | } |
1186 | 1206 | ||
1187 | /* | 1207 | /* |
@@ -1201,7 +1221,6 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how) | |||
1201 | /* Set up the argument struct */ | 1221 | /* Set up the argument struct */ |
1202 | nfs_commit_rpcsetup(head, data, how); | 1222 | nfs_commit_rpcsetup(head, data, how); |
1203 | 1223 | ||
1204 | nfs_execute_write(data); | ||
1205 | return 0; | 1224 | return 0; |
1206 | out_bad: | 1225 | out_bad: |
1207 | while (!list_empty(head)) { | 1226 | while (!list_empty(head)) { |