extern void rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo);
-extern void rpc_update_rtt(struct rpc_rtt *rt, int timer, long m);
-extern unsigned long rpc_calc_rto(struct rpc_rtt *rt, int timer);
+extern void rpc_update_rtt(struct rpc_rtt *rt, unsigned timer, long m);
+extern unsigned long rpc_calc_rto(struct rpc_rtt *rt, unsigned timer);
static inline void rpc_inc_timeo(struct rpc_rtt *rt)
{
to_initval, /* initial timeout */
to_maxval, /* max timeout */
to_increment; /* if !exponential */
- short to_retries; /* max # of retries */
+ unsigned int to_retries; /* max # of retries */
unsigned char to_exponential;
};
+/*
+ * linux/net/sunrpc/timer.c
+ *
+ * Estimate RPC request round trip time.
+ *
+ * Based on packet round-trip and variance estimator algorithms described
+ * in appendix A of "Congestion Avoidance and Control" by Van Jacobson
+ * and Michael J. Karels (ACM Computer Communication Review; Proceedings
+ * of the Sigcomm '88 Symposium in Stanford, CA, August, 1988).
+ *
+ * This RTT estimator is used only for RPC over datagram protocols.
+ *
+ * Copyright (C) 2002 Trond Myklebust <trond.myklebust@fys.uio.no>
+ */
+
+#include <asm/param.h>
+
#include <linux/version.h>
#include <linux/types.h>
#include <linux/unistd.h>
{
unsigned long init = 0;
unsigned i;
+
rt->timeo = timeo;
+
if (timeo > RPC_RTO_INIT)
init = (timeo - RPC_RTO_INIT) << 3;
for (i = 0; i < 5; i++) {
rt->srtt[i] = init;
rt->sdrtt[i] = RPC_RTO_INIT;
}
+
atomic_set(&rt->ntimeouts, 0);
}
+/*
+ * NB: When computing the smoothed RTT and standard deviation,
+ * be careful not to produce negative intermediate results.
+ */
void
-rpc_update_rtt(struct rpc_rtt *rt, int timer, long m)
+rpc_update_rtt(struct rpc_rtt *rt, unsigned timer, long m)
{
unsigned long *srtt, *sdrtt;
/* jiffies wrapped; ignore this one */
if (m < 0)
return;
+
if (m == 0)
- m = 1;
+ m = 1L;
+
srtt = &rt->srtt[timer];
m -= *srtt >> 3;
*srtt += m;
+
if (m < 0)
m = -m;
+
sdrtt = &rt->sdrtt[timer];
m -= *sdrtt >> 2;
*sdrtt += m;
+
/* Set lower bound on the variance */
if (*sdrtt < RPC_RTO_MIN)
*sdrtt = RPC_RTO_MIN;
*/
unsigned long
-rpc_calc_rto(struct rpc_rtt *rt, int timer)
+rpc_calc_rto(struct rpc_rtt *rt, unsigned timer)
{
unsigned long res;
+
if (timer-- == 0)
return rt->timeo;
+
res = (rt->srtt[timer] >> 3) + rt->sdrtt[timer];
if (res > RPC_RTO_MAX)
res = RPC_RTO_MAX;
+
return res;
}
xprt_adjust_cwnd(xprt, copied);
__xprt_put_cong(xprt, req);
if (!req->rq_nresend) {
- int timer = rpcproc_timer(clnt, task->tk_msg.rpc_proc);
+ unsigned timer =
+ rpcproc_timer(clnt, task->tk_msg.rpc_proc);
if (timer)
- rpc_update_rtt(&clnt->cl_rtt, timer, (long)jiffies - req->rq_xtime);
+ rpc_update_rtt(&clnt->cl_rtt, timer,
+ (long)jiffies - req->rq_xtime);
}
rpc_clear_timeo(&clnt->cl_rtt);
}