Commit a7ec0168 authored by Chuck Lever's avatar Chuck Lever Committed by Linus Torvalds

[PATCH] fix jiffies wrap in new RPC RTO estimator

the new RPC RTO estimator has some jiffies wrap problems.
parent 44a15afe
......@@ -12,16 +12,16 @@
#include <asm/atomic.h>
struct rpc_rtt {
long timeo; /* default timeout value */
long srtt[5]; /* smoothed round trip time << 3 */
long sdrtt[5]; /* soothed medium deviation of RTT */
unsigned long timeo; /* default timeout value */
unsigned long srtt[5]; /* smoothed round trip time << 3 */
unsigned long sdrtt[5]; /* smoothed medium deviation of RTT */
atomic_t ntimeouts; /* Global count of the number of timeouts */
};
extern void rpc_init_rtt(struct rpc_rtt *rt, long timeo);
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 long rpc_calc_rto(struct rpc_rtt *rt, int timer);
extern unsigned long rpc_calc_rto(struct rpc_rtt *rt, int timer);
static inline void rpc_inc_timeo(struct rpc_rtt *rt)
{
......
......@@ -109,7 +109,7 @@ struct rpc_rqst {
u32 rq_bytes_sent; /* Bytes we have sent */
long rq_xtime; /* when transmitted */
unsigned long rq_xtime; /* when transmitted */
int rq_ntimeo;
int rq_nresend;
};
......
......@@ -11,15 +11,15 @@
#define RPC_RTO_MIN (2)
void
rpc_init_rtt(struct rpc_rtt *rt, long timeo)
rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo)
{
long t = (timeo - RPC_RTO_INIT) << 3;
int i;
unsigned long init = 0;
unsigned i;
rt->timeo = timeo;
if (t < 0)
t = 0;
if (timeo > RPC_RTO_INIT)
init = (timeo - RPC_RTO_INIT) << 3;
for (i = 0; i < 5; i++) {
rt->srtt[i] = t;
rt->srtt[i] = init;
rt->sdrtt[i] = RPC_RTO_INIT;
}
atomic_set(&rt->ntimeouts, 0);
......@@ -28,11 +28,14 @@ rpc_init_rtt(struct rpc_rtt *rt, long timeo)
void
rpc_update_rtt(struct rpc_rtt *rt, int timer, long m)
{
long *srtt, *sdrtt;
unsigned long *srtt, *sdrtt;
if (timer-- == 0)
return;
/* jiffies wrapped; ignore this one */
if (m < 0)
return;
if (m == 0)
m = 1;
srtt = &rt->srtt[timer];
......@@ -61,10 +64,10 @@ rpc_update_rtt(struct rpc_rtt *rt, int timer, long m)
* other - timeo
*/
long
unsigned long
rpc_calc_rto(struct rpc_rtt *rt, int timer)
{
long res;
unsigned long res;
if (timer-- == 0)
return rt->timeo;
res = (rt->srtt[timer] >> 3) + rt->sdrtt[timer];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment