123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- #include <asm/param.h>
- #include <linux/types.h>
- #include <linux/unistd.h>
- #include <linux/module.h>
- #include <linux/sunrpc/clnt.h>
- #define RPC_RTO_MAX (60*HZ)
- #define RPC_RTO_INIT (HZ/5)
- #define RPC_RTO_MIN (HZ/10)
- void rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo)
- {
- unsigned long init = 0;
- unsigned int 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;
- rt->ntimeouts[i] = 0;
- }
- }
- EXPORT_SYMBOL_GPL(rpc_init_rtt);
- void rpc_update_rtt(struct rpc_rtt *rt, unsigned int timer, long m)
- {
- long *srtt, *sdrtt;
- if (timer-- == 0)
- return;
-
- if (m < 0)
- return;
- if (m == 0)
- m = 1L;
- srtt = (long *)&rt->srtt[timer];
- m -= *srtt >> 3;
- *srtt += m;
- if (m < 0)
- m = -m;
- sdrtt = (long *)&rt->sdrtt[timer];
- m -= *sdrtt >> 2;
- *sdrtt += m;
-
- if (*sdrtt < RPC_RTO_MIN)
- *sdrtt = RPC_RTO_MIN;
- }
- EXPORT_SYMBOL_GPL(rpc_update_rtt);
- unsigned long rpc_calc_rto(struct rpc_rtt *rt, unsigned int timer)
- {
- unsigned long res;
- if (timer-- == 0)
- return rt->timeo;
- res = ((rt->srtt[timer] + 7) >> 3) + rt->sdrtt[timer];
- if (res > RPC_RTO_MAX)
- res = RPC_RTO_MAX;
- return res;
- }
- EXPORT_SYMBOL_GPL(rpc_calc_rto);
|