diff options
Diffstat (limited to 'net/sunrpc/xprt.c')
| -rw-r--r-- | net/sunrpc/xprt.c | 67 | 
1 files changed, 45 insertions, 22 deletions
| diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 43fef7626442..1ac2fbe05102 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
| @@ -275,6 +275,38 @@ void xprt_write_space(struct rpc_xprt *xprt) | |||
| 275 | spin_unlock_bh(&xprt->transport_lock); | 275 | spin_unlock_bh(&xprt->transport_lock); | 
| 276 | } | 276 | } | 
| 277 | 277 | ||
| 278 | /** | ||
| 279 | * xprt_set_retrans_timeout_def - set a request's retransmit timeout | ||
| 280 | * @task: task whose timeout is to be set | ||
| 281 | * | ||
| 282 | * Set a request's retransmit timeout based on the transport's | ||
| 283 | * default timeout parameters. Used by transports that don't adjust | ||
| 284 | * the retransmit timeout based on round-trip time estimation. | ||
| 285 | */ | ||
| 286 | void xprt_set_retrans_timeout_def(struct rpc_task *task) | ||
| 287 | { | ||
| 288 | task->tk_timeout = task->tk_rqstp->rq_timeout; | ||
| 289 | } | ||
| 290 | |||
| 291 | /* | ||
| 292 | * xprt_set_retrans_timeout_rtt - set a request's retransmit timeout | ||
| 293 | * @task: task whose timeout is to be set | ||
| 294 | * | ||
| 295 | * Set a request's retransmit timeout using the RTT estimator. | ||
| 296 | */ | ||
| 297 | void xprt_set_retrans_timeout_rtt(struct rpc_task *task) | ||
| 298 | { | ||
| 299 | int timer = task->tk_msg.rpc_proc->p_timer; | ||
| 300 | struct rpc_rtt *rtt = task->tk_client->cl_rtt; | ||
| 301 | struct rpc_rqst *req = task->tk_rqstp; | ||
| 302 | unsigned long max_timeout = req->rq_xprt->timeout.to_maxval; | ||
| 303 | |||
| 304 | task->tk_timeout = rpc_calc_rto(rtt, timer); | ||
| 305 | task->tk_timeout <<= rpc_ntimeo(rtt, timer) + req->rq_retries; | ||
| 306 | if (task->tk_timeout > max_timeout || task->tk_timeout == 0) | ||
| 307 | task->tk_timeout = max_timeout; | ||
| 308 | } | ||
| 309 | |||
| 278 | static void xprt_reset_majortimeo(struct rpc_rqst *req) | 310 | static void xprt_reset_majortimeo(struct rpc_rqst *req) | 
| 279 | { | 311 | { | 
| 280 | struct rpc_timeout *to = &req->rq_xprt->timeout; | 312 | struct rpc_timeout *to = &req->rq_xprt->timeout; | 
| @@ -588,7 +620,6 @@ out_unlock: | |||
| 588 | */ | 620 | */ | 
| 589 | void xprt_transmit(struct rpc_task *task) | 621 | void xprt_transmit(struct rpc_task *task) | 
| 590 | { | 622 | { | 
| 591 | struct rpc_clnt *clnt = task->tk_client; | ||
| 592 | struct rpc_rqst *req = task->tk_rqstp; | 623 | struct rpc_rqst *req = task->tk_rqstp; | 
| 593 | struct rpc_xprt *xprt = req->rq_xprt; | 624 | struct rpc_xprt *xprt = req->rq_xprt; | 
| 594 | int status; | 625 | int status; | 
| @@ -613,8 +644,19 @@ void xprt_transmit(struct rpc_task *task) | |||
| 613 | return; | 644 | return; | 
| 614 | 645 | ||
| 615 | status = xprt->ops->send_request(task); | 646 | status = xprt->ops->send_request(task); | 
| 616 | if (!status) | 647 | if (status == 0) { | 
| 617 | goto out_receive; | 648 | dprintk("RPC: %4d xmit complete\n", task->tk_pid); | 
| 649 | spin_lock_bh(&xprt->transport_lock); | ||
| 650 | xprt->ops->set_retrans_timeout(task); | ||
| 651 | /* Don't race with disconnect */ | ||
| 652 | if (!xprt_connected(xprt)) | ||
| 653 | task->tk_status = -ENOTCONN; | ||
| 654 | else if (!req->rq_received) | ||
| 655 | rpc_sleep_on(&xprt->pending, task, NULL, xprt_timer); | ||
| 656 | __xprt_release_write(xprt, task); | ||
| 657 | spin_unlock_bh(&xprt->transport_lock); | ||
| 658 | return; | ||
| 659 | } | ||
| 618 | 660 | ||
| 619 | /* Note: at this point, task->tk_sleeping has not yet been set, | 661 | /* Note: at this point, task->tk_sleeping has not yet been set, | 
| 620 | * hence there is no danger of the waking up task being put on | 662 | * hence there is no danger of the waking up task being put on | 
| @@ -634,25 +676,6 @@ void xprt_transmit(struct rpc_task *task) | |||
| 634 | } | 676 | } | 
| 635 | xprt_release_write(xprt, task); | 677 | xprt_release_write(xprt, task); | 
| 636 | return; | 678 | return; | 
| 637 | out_receive: | ||
| 638 | dprintk("RPC: %4d xmit complete\n", task->tk_pid); | ||
| 639 | /* Set the task's receive timeout value */ | ||
| 640 | spin_lock_bh(&xprt->transport_lock); | ||
| 641 | if (!xprt->nocong) { | ||
| 642 | int timer = task->tk_msg.rpc_proc->p_timer; | ||
| 643 | task->tk_timeout = rpc_calc_rto(clnt->cl_rtt, timer); | ||
| 644 | task->tk_timeout <<= rpc_ntimeo(clnt->cl_rtt, timer) + req->rq_retries; | ||
| 645 | if (task->tk_timeout > xprt->timeout.to_maxval || task->tk_timeout == 0) | ||
| 646 | task->tk_timeout = xprt->timeout.to_maxval; | ||
| 647 | } else | ||
| 648 | task->tk_timeout = req->rq_timeout; | ||
| 649 | /* Don't race with disconnect */ | ||
| 650 | if (!xprt_connected(xprt)) | ||
| 651 | task->tk_status = -ENOTCONN; | ||
| 652 | else if (!req->rq_received) | ||
| 653 | rpc_sleep_on(&xprt->pending, task, NULL, xprt_timer); | ||
| 654 | __xprt_release_write(xprt, task); | ||
| 655 | spin_unlock_bh(&xprt->transport_lock); | ||
| 656 | } | 679 | } | 
| 657 | 680 | ||
| 658 | static inline void do_xprt_reserve(struct rpc_task *task) | 681 | static inline void do_xprt_reserve(struct rpc_task *task) | 
