aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-14 15:39:59 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-01-30 02:05:30 -0500
commit84115e1cd4a3614c4e566d4cce31381dce3dbef9 (patch)
tree01b2de7163deb6b3a789811183d8b8c1329b900c /fs/nfs
parente8914c65f7f8d4e8701b8e78a12b714872ea0402 (diff)
SUNRPC: Cleanup of rpc_task initialisation
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/direct.c36
-rw-r--r--fs/nfs/read.c15
-rw-r--r--fs/nfs/write.c30
3 files changed, 57 insertions, 24 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 3c9d16b4f80c..f9f5fc13dc7d 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -272,6 +272,11 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
272 unsigned long user_addr = (unsigned long)iov->iov_base; 272 unsigned long user_addr = (unsigned long)iov->iov_base;
273 size_t count = iov->iov_len; 273 size_t count = iov->iov_len;
274 size_t rsize = NFS_SERVER(inode)->rsize; 274 size_t rsize = NFS_SERVER(inode)->rsize;
275 struct rpc_task_setup task_setup_data = {
276 .rpc_client = NFS_CLIENT(inode),
277 .callback_ops = &nfs_read_direct_ops,
278 .flags = RPC_TASK_ASYNC,
279 };
275 unsigned int pgbase; 280 unsigned int pgbase;
276 int result; 281 int result;
277 ssize_t started = 0; 282 ssize_t started = 0;
@@ -322,8 +327,8 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
322 data->res.eof = 0; 327 data->res.eof = 0;
323 data->res.count = bytes; 328 data->res.count = bytes;
324 329
325 rpc_init_task(&data->task, NFS_CLIENT(inode), RPC_TASK_ASYNC, 330 task_setup_data.callback_data = data;
326 &nfs_read_direct_ops, data); 331 rpc_init_task(&data->task, &task_setup_data);
327 NFS_PROTO(inode)->read_setup(data); 332 NFS_PROTO(inode)->read_setup(data);
328 333
329 data->task.tk_cookie = (unsigned long) inode; 334 data->task.tk_cookie = (unsigned long) inode;
@@ -431,6 +436,11 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
431 struct inode *inode = dreq->inode; 436 struct inode *inode = dreq->inode;
432 struct list_head *p; 437 struct list_head *p;
433 struct nfs_write_data *data; 438 struct nfs_write_data *data;
439 struct rpc_task_setup task_setup_data = {
440 .rpc_client = NFS_CLIENT(inode),
441 .callback_ops = &nfs_write_direct_ops,
442 .flags = RPC_TASK_ASYNC,
443 };
434 444
435 dreq->count = 0; 445 dreq->count = 0;
436 get_dreq(dreq); 446 get_dreq(dreq);
@@ -451,8 +461,8 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
451 * Reuse data->task; data->args should not have changed 461 * Reuse data->task; data->args should not have changed
452 * since the original request was sent. 462 * since the original request was sent.
453 */ 463 */
454 rpc_init_task(&data->task, NFS_CLIENT(inode), RPC_TASK_ASYNC, 464 task_setup_data.callback_data = data;
455 &nfs_write_direct_ops, data); 465 rpc_init_task(&data->task, &task_setup_data);
456 NFS_PROTO(inode)->write_setup(data, FLUSH_STABLE); 466 NFS_PROTO(inode)->write_setup(data, FLUSH_STABLE);
457 467
458 data->task.tk_priority = RPC_PRIORITY_NORMAL; 468 data->task.tk_priority = RPC_PRIORITY_NORMAL;
@@ -504,6 +514,12 @@ static const struct rpc_call_ops nfs_commit_direct_ops = {
504static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq) 514static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq)
505{ 515{
506 struct nfs_write_data *data = dreq->commit_data; 516 struct nfs_write_data *data = dreq->commit_data;
517 struct rpc_task_setup task_setup_data = {
518 .rpc_client = NFS_CLIENT(dreq->inode),
519 .callback_ops = &nfs_commit_direct_ops,
520 .callback_data = data,
521 .flags = RPC_TASK_ASYNC,
522 };
507 523
508 data->inode = dreq->inode; 524 data->inode = dreq->inode;
509 data->cred = dreq->ctx->cred; 525 data->cred = dreq->ctx->cred;
@@ -515,8 +531,7 @@ static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq)
515 data->res.fattr = &data->fattr; 531 data->res.fattr = &data->fattr;
516 data->res.verf = &data->verf; 532 data->res.verf = &data->verf;
517 533
518 rpc_init_task(&data->task, NFS_CLIENT(dreq->inode), RPC_TASK_ASYNC, 534 rpc_init_task(&data->task, &task_setup_data);
519 &nfs_commit_direct_ops, data);
520 NFS_PROTO(data->inode)->commit_setup(data, 0); 535 NFS_PROTO(data->inode)->commit_setup(data, 0);
521 536
522 data->task.tk_priority = RPC_PRIORITY_NORMAL; 537 data->task.tk_priority = RPC_PRIORITY_NORMAL;
@@ -641,6 +656,11 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
641 struct inode *inode = ctx->path.dentry->d_inode; 656 struct inode *inode = ctx->path.dentry->d_inode;
642 unsigned long user_addr = (unsigned long)iov->iov_base; 657 unsigned long user_addr = (unsigned long)iov->iov_base;
643 size_t count = iov->iov_len; 658 size_t count = iov->iov_len;
659 struct rpc_task_setup task_setup_data = {
660 .rpc_client = NFS_CLIENT(inode),
661 .callback_ops = &nfs_write_direct_ops,
662 .flags = RPC_TASK_ASYNC,
663 };
644 size_t wsize = NFS_SERVER(inode)->wsize; 664 size_t wsize = NFS_SERVER(inode)->wsize;
645 unsigned int pgbase; 665 unsigned int pgbase;
646 int result; 666 int result;
@@ -694,8 +714,8 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
694 data->res.count = bytes; 714 data->res.count = bytes;
695 data->res.verf = &data->verf; 715 data->res.verf = &data->verf;
696 716
697 rpc_init_task(&data->task, NFS_CLIENT(inode), RPC_TASK_ASYNC, 717 task_setup_data.callback_data = data;
698 &nfs_write_direct_ops, data); 718 rpc_init_task(&data->task, &task_setup_data);
699 NFS_PROTO(inode)->write_setup(data, sync); 719 NFS_PROTO(inode)->write_setup(data, sync);
700 720
701 data->task.tk_priority = RPC_PRIORITY_NORMAL; 721 data->task.tk_priority = RPC_PRIORITY_NORMAL;
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 4587a86adaac..c7f0d5ebd451 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -160,11 +160,17 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
160 const struct rpc_call_ops *call_ops, 160 const struct rpc_call_ops *call_ops,
161 unsigned int count, unsigned int offset) 161 unsigned int count, unsigned int offset)
162{ 162{
163 struct inode *inode; 163 struct inode *inode = req->wb_context->path.dentry->d_inode;
164 int flags; 164 int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0;
165 struct rpc_task_setup task_setup_data = {
166 .rpc_client = NFS_CLIENT(inode),
167 .callback_ops = call_ops,
168 .callback_data = data,
169 .flags = RPC_TASK_ASYNC | swap_flags,
170 };
165 171
166 data->req = req; 172 data->req = req;
167 data->inode = inode = req->wb_context->path.dentry->d_inode; 173 data->inode = inode;
168 data->cred = req->wb_context->cred; 174 data->cred = req->wb_context->cred;
169 175
170 data->args.fh = NFS_FH(inode); 176 data->args.fh = NFS_FH(inode);
@@ -180,8 +186,7 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
180 nfs_fattr_init(&data->fattr); 186 nfs_fattr_init(&data->fattr);
181 187
182 /* Set up the initial task struct. */ 188 /* Set up the initial task struct. */
183 flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0); 189 rpc_init_task(&data->task, &task_setup_data);
184 rpc_init_task(&data->task, NFS_CLIENT(inode), flags, call_ops, data);
185 NFS_PROTO(inode)->read_setup(data); 190 NFS_PROTO(inode)->read_setup(data);
186 191
187 data->task.tk_cookie = (unsigned long)inode; 192 data->task.tk_cookie = (unsigned long)inode;
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 092e79c6d962..c4376606f106 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -773,8 +773,14 @@ static void nfs_write_rpcsetup(struct nfs_page *req,
773 unsigned int count, unsigned int offset, 773 unsigned int count, unsigned int offset,
774 int how) 774 int how)
775{ 775{
776 struct inode *inode; 776 struct inode *inode = req->wb_context->path.dentry->d_inode;
777 int flags; 777 int flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
778 struct rpc_task_setup task_setup_data = {
779 .rpc_client = NFS_CLIENT(inode),
780 .callback_ops = call_ops,
781 .callback_data = data,
782 .flags = flags,
783 };
778 784
779 /* Set up the RPC argument and reply structs 785 /* Set up the RPC argument and reply structs
780 * NB: take care not to mess about with data->commit et al. */ 786 * NB: take care not to mess about with data->commit et al. */
@@ -796,8 +802,7 @@ static void nfs_write_rpcsetup(struct nfs_page *req,
796 nfs_fattr_init(&data->fattr); 802 nfs_fattr_init(&data->fattr);
797 803
798 /* Set up the initial task struct. */ 804 /* Set up the initial task struct. */
799 flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; 805 rpc_init_task(&data->task, &task_setup_data);
800 rpc_init_task(&data->task, NFS_CLIENT(inode), flags, call_ops, data);
801 NFS_PROTO(inode)->write_setup(data, how); 806 NFS_PROTO(inode)->write_setup(data, how);
802 807
803 data->task.tk_priority = flush_task_priority(how); 808 data->task.tk_priority = flush_task_priority(how);
@@ -1144,16 +1149,20 @@ static void nfs_commit_rpcsetup(struct list_head *head,
1144 struct nfs_write_data *data, 1149 struct nfs_write_data *data,
1145 int how) 1150 int how)
1146{ 1151{
1147 struct nfs_page *first; 1152 struct nfs_page *first = nfs_list_entry(head->next);
1148 struct inode *inode; 1153 struct inode *inode = first->wb_context->path.dentry->d_inode;
1149 int flags; 1154 int flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
1155 struct rpc_task_setup task_setup_data = {
1156 .rpc_client = NFS_CLIENT(inode),
1157 .callback_ops = &nfs_commit_ops,
1158 .callback_data = data,
1159 .flags = flags,
1160 };
1150 1161
1151 /* Set up the RPC argument and reply structs 1162 /* Set up the RPC argument and reply structs
1152 * NB: take care not to mess about with data->commit et al. */ 1163 * NB: take care not to mess about with data->commit et al. */
1153 1164
1154 list_splice_init(head, &data->pages); 1165 list_splice_init(head, &data->pages);
1155 first = nfs_list_entry(data->pages.next);
1156 inode = first->wb_context->path.dentry->d_inode;
1157 1166
1158 data->inode = inode; 1167 data->inode = inode;
1159 data->cred = first->wb_context->cred; 1168 data->cred = first->wb_context->cred;
@@ -1168,8 +1177,7 @@ static void nfs_commit_rpcsetup(struct list_head *head,
1168 nfs_fattr_init(&data->fattr); 1177 nfs_fattr_init(&data->fattr);
1169 1178
1170 /* Set up the initial task struct. */ 1179 /* Set up the initial task struct. */
1171 flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; 1180 rpc_init_task(&data->task, &task_setup_data);
1172 rpc_init_task(&data->task, NFS_CLIENT(inode), flags, &nfs_commit_ops, data);
1173 NFS_PROTO(inode)->commit_setup(data, how); 1181 NFS_PROTO(inode)->commit_setup(data, how);
1174 1182
1175 data->task.tk_priority = flush_task_priority(how); 1183 data->task.tk_priority = flush_task_priority(how);