This source file includes following definitions.
- rpc_init_rtt
- rpc_update_rtt
- rpc_calc_rto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <asm/param.h>
18
19 #include <linux/types.h>
20 #include <linux/unistd.h>
21 #include <linux/module.h>
22
23 #include <linux/sunrpc/clnt.h>
24
25 #define RPC_RTO_MAX (60*HZ)
26 #define RPC_RTO_INIT (HZ/5)
27 #define RPC_RTO_MIN (HZ/10)
28
29
30
31
32
33
34
35 void rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo)
36 {
37 unsigned long init = 0;
38 unsigned int i;
39
40 rt->timeo = timeo;
41
42 if (timeo > RPC_RTO_INIT)
43 init = (timeo - RPC_RTO_INIT) << 3;
44 for (i = 0; i < 5; i++) {
45 rt->srtt[i] = init;
46 rt->sdrtt[i] = RPC_RTO_INIT;
47 rt->ntimeouts[i] = 0;
48 }
49 }
50 EXPORT_SYMBOL_GPL(rpc_init_rtt);
51
52
53
54
55
56
57
58
59
60
61 void rpc_update_rtt(struct rpc_rtt *rt, unsigned int timer, long m)
62 {
63 long *srtt, *sdrtt;
64
65 if (timer-- == 0)
66 return;
67
68
69 if (m < 0)
70 return;
71
72 if (m == 0)
73 m = 1L;
74
75 srtt = (long *)&rt->srtt[timer];
76 m -= *srtt >> 3;
77 *srtt += m;
78
79 if (m < 0)
80 m = -m;
81
82 sdrtt = (long *)&rt->sdrtt[timer];
83 m -= *sdrtt >> 2;
84 *sdrtt += m;
85
86
87 if (*sdrtt < RPC_RTO_MIN)
88 *sdrtt = RPC_RTO_MIN;
89 }
90 EXPORT_SYMBOL_GPL(rpc_update_rtt);
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 unsigned long rpc_calc_rto(struct rpc_rtt *rt, unsigned int timer)
111 {
112 unsigned long res;
113
114 if (timer-- == 0)
115 return rt->timeo;
116
117 res = ((rt->srtt[timer] + 7) >> 3) + rt->sdrtt[timer];
118 if (res > RPC_RTO_MAX)
119 res = RPC_RTO_MAX;
120
121 return res;
122 }
123 EXPORT_SYMBOL_GPL(rpc_calc_rto);