aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorChuck Lever <cel@netapp.com>2005-08-25 19:25:50 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2005-09-23 12:38:36 -0400
commitfe3aca290f17ae4978bd73d02aa4029f1c9c024c (patch)
tree4fbaa255e9e7a85f41eacb7cf1214dc44a90bcea /net/sunrpc
parent43118c29dea2b23798bd42a147015cceee7fa885 (diff)
[PATCH] RPC: add API to set transport-specific timeouts
Prepare the way to remove the "xprt->nocong" variable by adding a callout to the RPC client transport switch API to handle setting RPC retransmit timeouts. Add a pair of generic helper functions that provide the ability to set a simple fixed timeout, or to set a timeout based on the state of a round- trip estimator. Test-plan: Use WAN simulation to cause sporadic bursty packet loss. Look for significant regression in performance or client stability. Signed-off-by: Chuck Lever <cel@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/xprt.c67
-rw-r--r--net/sunrpc/xprtsock.c2
2 files changed, 47 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 */
286void 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 */
297void 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
278static void xprt_reset_majortimeo(struct rpc_rqst *req) 310static 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 */
589void xprt_transmit(struct rpc_task *task) 621void 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
658static inline void do_xprt_reserve(struct rpc_task *task) 681static inline void do_xprt_reserve(struct rpc_task *task)
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 5bb6fed3df34..79433ffd1df0 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1047,6 +1047,7 @@ static struct rpc_xprt_ops xs_udp_ops = {
1047 .set_buffer_size = xs_udp_set_buffer_size, 1047 .set_buffer_size = xs_udp_set_buffer_size,
1048 .connect = xs_connect, 1048 .connect = xs_connect,
1049 .send_request = xs_udp_send_request, 1049 .send_request = xs_udp_send_request,
1050 .set_retrans_timeout = xprt_set_retrans_timeout_rtt,
1050 .close = xs_close, 1051 .close = xs_close,
1051 .destroy = xs_destroy, 1052 .destroy = xs_destroy,
1052}; 1053};
@@ -1055,6 +1056,7 @@ static struct rpc_xprt_ops xs_tcp_ops = {
1055 .set_buffer_size = xs_tcp_set_buffer_size, 1056 .set_buffer_size = xs_tcp_set_buffer_size,
1056 .connect = xs_connect, 1057 .connect = xs_connect,
1057 .send_request = xs_tcp_send_request, 1058 .send_request = xs_tcp_send_request,
1059 .set_retrans_timeout = xprt_set_retrans_timeout_def,
1058 .close = xs_close, 1060 .close = xs_close,
1059 .destroy = xs_destroy, 1061 .destroy = xs_destroy,
1060}; 1062};