2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #define __fs_stats_h 1
13 /*------------------------------------------------------------------------
16 * Definitions supporting call and performance information gathering for
17 * the FileServer xstat (extended statistics) interface.
19 *------------------------------------------------------------------------*/
22 #include <afs/param.h> /*System configuration info */
25 * Decide if we're keeping detailed File Server stats.
27 #define FS_STATS_DETAILED 1
30 * Performance numbers.
32 struct afs_PerfStats {
33 afs_int32 numPerfCalls; /*# of performance calls rcvd */
36 * Vnode cache section.
38 afs_int32 vcache_L_Entries; /*Num entries in LARGE vnode cache */
39 afs_int32 vcache_L_Allocs; /*# allocs, large */
40 afs_int32 vcache_L_Gets; /*# gets, large */
41 afs_int32 vcache_L_Reads; /*# reads, large */
42 afs_int32 vcache_L_Writes; /*# writes, large */
44 afs_int32 vcache_S_Entries; /*Num entries in SMALL vnode cache */
45 afs_int32 vcache_S_Allocs; /*# allocs, small */
46 afs_int32 vcache_S_Gets; /*# gets, small */
47 afs_int32 vcache_S_Reads; /*# reads, small */
48 afs_int32 vcache_S_Writes; /*# writes, small */
50 afs_int32 vcache_H_Entries; /*Num entries in HEADER vnode cache */
51 afs_int32 vcache_H_Gets; /*# gets */
52 afs_int32 vcache_H_Replacements; /*# replacements */
55 * Directory package section.
57 afs_int32 dir_Buffers; /*Num buffers in use */
58 afs_int32 dir_Calls; /*Num read calls made */
59 afs_int32 dir_IOs; /*I/O ops performed */
62 * Rx section. These numbers represent the contents of the
63 * rx_stats structure maintained by Rx. All other Rx info,
64 * including struct rx_debug and connection stuff is available
65 * via the rxdebug interface.
67 afs_int32 rx_packetRequests; /*Packet alloc requests */
68 afs_int32 rx_noPackets_RcvClass; /*Failed pkt requests, receives */
69 afs_int32 rx_noPackets_SendClass; /*Ditto, sends */
70 afs_int32 rx_noPackets_SpecialClass; /*Ditto, specials */
71 afs_int32 rx_socketGreedy; /*Did SO_GREEDY succeed? */
72 afs_int32 rx_bogusPacketOnRead; /*Short pkts rcvd */
73 afs_int32 rx_bogusHost; /*Host addr from bogus pkts */
74 afs_int32 rx_noPacketOnRead; /*Read pkts w/no packet there */
75 afs_int32 rx_noPacketBuffersOnRead; /*Pkts dropped from buff shortage */
76 afs_int32 rx_selects; /*Selects waiting on pkt or timeout */
77 afs_int32 rx_sendSelects; /*Selects forced upon sends */
78 afs_int32 rx_packetsRead_RcvClass; /*Packets read, rcv class */
79 afs_int32 rx_packetsRead_SendClass; /*Packets read, send class */
80 afs_int32 rx_packetsRead_SpecialClass; /*Packets read, special class */
81 afs_int32 rx_dataPacketsRead; /*Uniq data packets read off wire */
82 afs_int32 rx_ackPacketsRead; /*Ack packets read */
83 afs_int32 rx_dupPacketsRead; /*Duplicate data packets read */
84 afs_int32 rx_spuriousPacketsRead; /*Inappropriate packets read */
85 afs_int32 rx_packetsSent_RcvClass; /*Packets sent, rcv class */
86 afs_int32 rx_packetsSent_SendClass; /*Packets sent, send class */
87 afs_int32 rx_packetsSent_SpecialClass; /*Packets sent, special class */
88 afs_int32 rx_ackPacketsSent; /*Ack packets sent */
89 afs_int32 rx_pingPacketsSent; /*Ping packets sent */
90 afs_int32 rx_abortPacketsSent; /*Abort packets sent */
91 afs_int32 rx_busyPacketsSent; /*Busy packets sent */
92 afs_int32 rx_dataPacketsSent; /*Unique data packets sent */
93 afs_int32 rx_dataPacketsReSent; /*Retransmissions sent */
94 afs_int32 rx_dataPacketsPushed; /*Retransmissions pushed by NACK */
95 afs_int32 rx_ignoreAckedPacket; /*Packets w/acked flag on rxi_Start */
96 afs_int32 rx_totalRtt_Sec; /*Ttl round trip time, secs */
97 afs_int32 rx_totalRtt_Usec; /*Ttl round trip time, usecs */
98 afs_int32 rx_minRtt_Sec; /*Min round trip time, secs */
99 afs_int32 rx_minRtt_Usec; /*Min round trip time, usecs */
100 afs_int32 rx_maxRtt_Sec; /*Max round trip time, secs */
101 afs_int32 rx_maxRtt_Usec; /*Max round trip time, usecs */
102 afs_int32 rx_nRttSamples; /*Round trip samples */
103 afs_int32 rx_nServerConns; /*Ttl server connections */
104 afs_int32 rx_nClientConns; /*Ttl client connections */
105 afs_int32 rx_nPeerStructs; /*Ttl peer structures */
106 afs_int32 rx_nCallStructs; /*Ttl call structures */
107 afs_int32 rx_nFreeCallStructs; /*Ttl free call structures */
110 * Host module fields.
112 afs_int32 host_NumHostEntries; /*Number of host entries */
113 afs_int32 host_HostBlocks; /*Blocks in use for hosts */
114 afs_int32 host_NonDeletedHosts; /*Non-deleted hosts */
115 afs_int32 host_HostsInSameNetOrSubnet; /*" in same [sub]net as server */
116 afs_int32 host_HostsInDiffSubnet; /*" in different subnet as server */
117 afs_int32 host_HostsInDiffNetwork; /*" in different network as server */
118 afs_int32 host_NumClients; /*Number of client entries */
119 afs_int32 host_ClientBlocks; /*Blocks in use for clients */
124 afs_int32 sysname_ID; /*Unique hardware/OS identifier */
126 afs_int32 rx_nBusies; /*Ttl VBUSYs sent to shed load */
127 afs_int32 fs_nBusies; /*Ttl VBUSYs sent during restart/vol clone */
135 #if FS_STATS_DETAILED
137 * Assign each of the File Server's RPC interface routines an index.
139 #define FS_STATS_RPCIDX_FETCHDATA 0
140 #define FS_STATS_RPCIDX_FETCHACL 1
141 #define FS_STATS_RPCIDX_FETCHSTATUS 2
142 #define FS_STATS_RPCIDX_STOREDATA 3
143 #define FS_STATS_RPCIDX_STOREACL 4
144 #define FS_STATS_RPCIDX_STORESTATUS 5
145 #define FS_STATS_RPCIDX_REMOVEFILE 6
146 #define FS_STATS_RPCIDX_CREATEFILE 7
147 #define FS_STATS_RPCIDX_RENAME 8
148 #define FS_STATS_RPCIDX_SYMLINK 9
149 #define FS_STATS_RPCIDX_LINK 10
150 #define FS_STATS_RPCIDX_MAKEDIR 11
151 #define FS_STATS_RPCIDX_REMOVEDIR 12
152 #define FS_STATS_RPCIDX_SETLOCK 13
153 #define FS_STATS_RPCIDX_EXTENDLOCK 14
154 #define FS_STATS_RPCIDX_RELEASELOCK 15
155 #define FS_STATS_RPCIDX_GETSTATISTICS 16
156 #define FS_STATS_RPCIDX_GIVEUPCALLBACKS 17
157 #define FS_STATS_RPCIDX_GETVOLUMEINFO 18
158 #define FS_STATS_RPCIDX_GETVOLUMESTATUS 19
159 #define FS_STATS_RPCIDX_SETVOLUMESTATUS 20
160 #define FS_STATS_RPCIDX_GETROOTVOLUME 21
161 #define FS_STATS_RPCIDX_CHECKTOKEN 22
162 #define FS_STATS_RPCIDX_GETTIME 23
163 #define FS_STATS_RPCIDX_NGETVOLUMEINFO 24
164 #define FS_STATS_RPCIDX_BULKSTATUS 25
165 #define FS_STATS_RPCIDX_XSTATSVERSION 26
166 #define FS_STATS_RPCIDX_GETXSTATS 27
168 #define FS_STATS_NUM_RPC_OPS 28
171 * Assign an index to each of the File Server's RPC interface routines
172 * that transfer any data to speak of.
174 #define FS_STATS_XFERIDX_FETCHDATA 0
175 #define FS_STATS_XFERIDX_STOREDATA 1
177 #define FS_STATS_NUM_XFER_OPS 2
180 * Record to track timing numbers for each File Server RPC operation.
182 struct fs_stats_opTimingData {
183 afs_int32 numOps; /*Number of operations executed */
184 afs_int32 numSuccesses; /*Number of successful ops */
185 struct timeval sumTime; /*Sum of sample timings */
186 struct timeval sqrTime; /*Sum of squares of sample timings */
187 struct timeval minTime; /*Minimum timing value observed */
188 struct timeval maxTime; /*Minimum timing value observed */
192 * We discriminate byte size transfers into this many buckets.
194 #define FS_STATS_NUM_XFER_BUCKETS 9
196 #define FS_STATS_MAXBYTES_BUCKET0 128
197 #define FS_STATS_MAXBYTES_BUCKET1 1024
198 #define FS_STATS_MAXBYTES_BUCKET2 8192
199 #define FS_STATS_MAXBYTES_BUCKET3 16384
200 #define FS_STATS_MAXBYTES_BUCKET4 32768
201 #define FS_STATS_MAXBYTES_BUCKET5 131072
202 #define FS_STATS_MAXBYTES_BUCKET6 524288
203 #define FS_STATS_MAXBYTES_BUCKET7 1048576
207 * Record to track timings and byte sizes for data transfers.
209 struct fs_stats_xferData {
210 afs_int32 numXfers; /*Number of xfers */
211 afs_int32 numSuccesses; /*Number of successful xfers */
212 struct timeval sumTime; /*Sum of timing values */
213 struct timeval sqrTime; /*Sum of squares of timing values */
214 struct timeval minTime; /*Minimum xfer time recorded */
215 struct timeval maxTime; /*Maximum xfer time recorded */
216 afs_int32 sumBytes; /*Sum of bytes transferred */
217 afs_int32 minBytes; /*Minimum value observed */
218 afs_int32 maxBytes; /*Maximum value observed */
219 afs_int32 count[FS_STATS_NUM_XFER_BUCKETS]; /*Tally for each range of bytes */
223 * Macros to operate on time values.
225 * fs_stats_TimeLessThan(t1, t2) Non-zero if t1 is less than t2
226 * fs_stats_TimeGreaterThan(t1, t2) Non-zero if t1 is greater than t2
227 * fs_stats_GetDiff(t3, t1, t2) Set t3 to the difference between
228 * t1 and t2 (t1 is less than or
230 * fs_stats_AddTo(t1, t2) Add t2 to t1
231 * fs_stats_TimeAssign(t1, t2) Assign time t2 to t1
232 * afs_stats_SquareAddTo(t1,t2) Add square of t2 to t1
234 #define fs_stats_TimeLessThan(t1, t2) \
235 ((t1.tv_sec < t2.tv_sec) ? 1 : \
236 (t1.tv_sec > t2.tv_sec) ? 0 : \
237 (t1.tv_usec < t2.tv_usec) ? 1 : \
240 #define fs_stats_TimeGreaterThan(t1, t2) \
241 ((t1.tv_sec > t2.tv_sec) ? 1 : \
242 (t1.tv_sec < t2.tv_sec) ? 0 : \
243 (t1.tv_usec > t2.tv_usec) ? 1 : \
246 #define fs_stats_GetDiff(t3, t1, t2) \
249 * If the microseconds of the later time are smaller than \
250 * the earlier time, set up for proper subtraction (doing \
253 if (t2.tv_usec < t1.tv_usec) { \
254 t2.tv_usec += 1000000; \
257 t3.tv_sec = t2.tv_sec - t1.tv_sec; \
258 t3.tv_usec = t2.tv_usec - t1.tv_usec; \
261 #define fs_stats_AddTo(t1, t2) \
263 t1.tv_sec += t2.tv_sec; \
264 t1.tv_usec += t2.tv_usec; \
265 if (t1.tv_usec > 1000000) { \
266 t1.tv_usec -= 1000000; \
271 #define fs_stats_TimeAssign(t1, t2) \
273 t1.tv_sec = t2.tv_sec; \
274 t1.tv_usec = t2.tv_usec; \
277 #define fs_stats_SquareAddTo(t1, t2) \
281 t1.tv_sec += (int) (t2.tv_sec * t2.tv_sec \
282 + (0.000002 * t2.tv_sec) * t2.tv_usec) ; \
283 t1.tv_usec += (int) ((2 * t2.tv_sec * t2.tv_usec) % 1000000 \
284 + (0.000001 * t2.tv_usec) * t2.tv_usec); \
288 t1.tv_usec += (int) ((0.000001 * t2.tv_usec) * t2.tv_usec); \
290 if (t1.tv_usec > 1000000) { \
291 t1.tv_usec -= 1000000; \
297 * This is the detailed performance data collection for the File Server.
299 struct fs_stats_DetailedStats {
300 struct timeval epoch; /*Time when data collection began */
301 struct fs_stats_opTimingData
302 rpcOpTimes[FS_STATS_NUM_RPC_OPS]; /*Individual RPC operation timings */
303 struct fs_stats_xferData
304 xferOpTimes[FS_STATS_NUM_XFER_OPS]; /*Byte info for certain ops */
308 * This is all of the performance data, both overall and detailed.
310 struct fs_stats_FullPerfStats {
311 struct afs_PerfStats overall;
312 struct fs_stats_DetailedStats det;
316 * This is the structure accessible by specifying the
317 * AFS_XSTATSCOLL_FULL_PERF_INFO collection to the xstat package.
319 extern struct fs_stats_FullPerfStats afs_FullPerfStats;
320 #endif /* FS_STATS_DETAILED */
324 * This is the structure accessible by specifying the
325 * AFS_XSTATSCOLL_PERF_INFO collection to the xstat package.
327 extern struct afs_PerfStats afs_perfstats;
330 * FileServer's name and IP address, both network byte order and
333 extern char FS_HostName[];
334 extern afs_uint32 FS_HostAddr_NBO;
335 extern afs_uint32 FS_HostAddr_HBO;
337 #endif /* __fs_stats_h */