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 */
26 * Performance numbers.
28 struct afs_PerfStats {
29 afs_int32 numPerfCalls; /*# of performance calls rcvd */
32 * Vnode cache section.
34 afs_int32 vcache_L_Entries; /*Num entries in LARGE vnode cache */
35 afs_int32 vcache_L_Allocs; /*# allocs, large */
36 afs_int32 vcache_L_Gets; /*# gets, large */
37 afs_int32 vcache_L_Reads; /*# reads, large */
38 afs_int32 vcache_L_Writes; /*# writes, large */
40 afs_int32 vcache_S_Entries; /*Num entries in SMALL vnode cache */
41 afs_int32 vcache_S_Allocs; /*# allocs, small */
42 afs_int32 vcache_S_Gets; /*# gets, small */
43 afs_int32 vcache_S_Reads; /*# reads, small */
44 afs_int32 vcache_S_Writes; /*# writes, small */
46 afs_int32 vcache_H_Entries; /*Num entries in HEADER vnode cache */
47 afs_int32 vcache_H_Gets; /*# gets */
48 afs_int32 vcache_H_Replacements; /*# replacements */
51 * Directory package section.
53 afs_int32 dir_Buffers; /*Num buffers in use */
54 afs_int32 dir_Calls; /*Num read calls made */
55 afs_int32 dir_IOs; /*I/O ops performed */
58 * Rx section. These numbers represent the contents of the
59 * rx_stats structure maintained by Rx. All other Rx info,
60 * including struct rx_debug and connection stuff is available
61 * via the rxdebug interface.
63 afs_int32 rx_packetRequests; /*Packet alloc requests */
64 afs_int32 rx_noPackets_RcvClass; /*Failed pkt requests, receives */
65 afs_int32 rx_noPackets_SendClass; /*Ditto, sends */
66 afs_int32 rx_noPackets_SpecialClass; /*Ditto, specials */
67 afs_int32 rx_socketGreedy; /*Did SO_GREEDY succeed? */
68 afs_int32 rx_bogusPacketOnRead; /*Short pkts rcvd */
69 afs_int32 rx_bogusHost; /*Host addr from bogus pkts */
70 afs_int32 rx_noPacketOnRead; /*Read pkts w/no packet there */
71 afs_int32 rx_noPacketBuffersOnRead; /*Pkts dropped from buff shortage */
72 afs_int32 rx_selects; /*Selects waiting on pkt or timeout */
73 afs_int32 rx_sendSelects; /*Selects forced upon sends */
74 afs_int32 rx_packetsRead_RcvClass; /*Packets read, rcv class */
75 afs_int32 rx_packetsRead_SendClass; /*Packets read, send class */
76 afs_int32 rx_packetsRead_SpecialClass; /*Packets read, special class */
77 afs_int32 rx_dataPacketsRead; /*Uniq data packets read off wire */
78 afs_int32 rx_ackPacketsRead; /*Ack packets read */
79 afs_int32 rx_dupPacketsRead; /*Duplicate data packets read */
80 afs_int32 rx_spuriousPacketsRead; /*Inappropriate packets read */
81 afs_int32 rx_packetsSent_RcvClass; /*Packets sent, rcv class */
82 afs_int32 rx_packetsSent_SendClass; /*Packets sent, send class */
83 afs_int32 rx_packetsSent_SpecialClass; /*Packets sent, special class */
84 afs_int32 rx_ackPacketsSent; /*Ack packets sent */
85 afs_int32 rx_pingPacketsSent; /*Ping packets sent */
86 afs_int32 rx_abortPacketsSent; /*Abort packets sent */
87 afs_int32 rx_busyPacketsSent; /*Busy packets sent */
88 afs_int32 rx_dataPacketsSent; /*Unique data packets sent */
89 afs_int32 rx_dataPacketsReSent; /*Retransmissions sent */
90 afs_int32 rx_dataPacketsPushed; /*Retransmissions pushed by NACK */
91 afs_int32 rx_ignoreAckedPacket; /*Packets w/acked flag on rxi_Start */
92 afs_int32 rx_totalRtt_Sec; /*Ttl round trip time, secs */
93 afs_int32 rx_totalRtt_Usec; /*Ttl round trip time, usecs */
94 afs_int32 rx_minRtt_Sec; /*Min round trip time, secs */
95 afs_int32 rx_minRtt_Usec; /*Min round trip time, usecs */
96 afs_int32 rx_maxRtt_Sec; /*Max round trip time, secs */
97 afs_int32 rx_maxRtt_Usec; /*Max round trip time, usecs */
98 afs_int32 rx_nRttSamples; /*Round trip samples */
99 afs_int32 rx_nServerConns; /*Ttl server connections */
100 afs_int32 rx_nClientConns; /*Ttl client connections */
101 afs_int32 rx_nPeerStructs; /*Ttl peer structures */
102 afs_int32 rx_nCallStructs; /*Ttl call structures */
103 afs_int32 rx_nFreeCallStructs; /*Ttl free call structures */
106 * Host module fields.
108 afs_int32 host_NumHostEntries; /*Number of host entries */
109 afs_int32 host_HostBlocks; /*Blocks in use for hosts */
110 afs_int32 host_NonDeletedHosts; /*Non-deleted hosts */
111 afs_int32 host_HostsInSameNetOrSubnet; /*" in same [sub]net as server */
112 afs_int32 host_HostsInDiffSubnet; /*" in different subnet as server */
113 afs_int32 host_HostsInDiffNetwork; /*" in different network as server */
114 afs_int32 host_NumClients; /*Number of client entries */
115 afs_int32 host_ClientBlocks; /*Blocks in use for clients */
120 afs_int32 sysname_ID; /*Unique hardware/OS identifier */
122 afs_int32 rx_nBusies; /*Ttl VBUSYs sent to shed load */
123 afs_int32 fs_nBusies; /*Ttl VBUSYs sent during restart/vol clone */
126 * Can't count this as an RPC because it breaks the data structure
128 afs_int32 fs_nGetCaps; /* Number of GetCapabilities calls */
136 * Assign each of the File Server's RPC interface routines an index.
138 #define FS_STATS_RPCIDX_FETCHDATA 0
139 #define FS_STATS_RPCIDX_FETCHACL 1
140 #define FS_STATS_RPCIDX_FETCHSTATUS 2
141 #define FS_STATS_RPCIDX_STOREDATA 3
142 #define FS_STATS_RPCIDX_STOREACL 4
143 #define FS_STATS_RPCIDX_STORESTATUS 5
144 #define FS_STATS_RPCIDX_REMOVEFILE 6
145 #define FS_STATS_RPCIDX_CREATEFILE 7
146 #define FS_STATS_RPCIDX_RENAME 8
147 #define FS_STATS_RPCIDX_SYMLINK 9
148 #define FS_STATS_RPCIDX_LINK 10
149 #define FS_STATS_RPCIDX_MAKEDIR 11
150 #define FS_STATS_RPCIDX_REMOVEDIR 12
151 #define FS_STATS_RPCIDX_SETLOCK 13
152 #define FS_STATS_RPCIDX_EXTENDLOCK 14
153 #define FS_STATS_RPCIDX_RELEASELOCK 15
154 #define FS_STATS_RPCIDX_GETSTATISTICS 16
155 #define FS_STATS_RPCIDX_GIVEUPCALLBACKS 17
156 #define FS_STATS_RPCIDX_GETVOLUMEINFO 18
157 #define FS_STATS_RPCIDX_GETVOLUMESTATUS 19
158 #define FS_STATS_RPCIDX_SETVOLUMESTATUS 20
159 #define FS_STATS_RPCIDX_GETROOTVOLUME 21
160 #define FS_STATS_RPCIDX_CHECKTOKEN 22
161 #define FS_STATS_RPCIDX_GETTIME 23
162 #define FS_STATS_RPCIDX_NGETVOLUMEINFO 24
163 #define FS_STATS_RPCIDX_BULKSTATUS 25
164 #define FS_STATS_RPCIDX_XSTATSVERSION 26
165 #define FS_STATS_RPCIDX_GETXSTATS 27
167 #define FS_STATS_NUM_RPC_OPS 28
170 * Assign an index to each of the File Server's RPC interface routines
171 * that transfer any data to speak of.
173 #define FS_STATS_XFERIDX_FETCHDATA 0
174 #define FS_STATS_XFERIDX_STOREDATA 1
176 #define FS_STATS_NUM_XFER_OPS 2
179 * Record to track timing numbers for each File Server RPC operation.
181 struct fs_stats_opTimingData {
182 afs_int32 numOps; /*Number of operations executed */
183 afs_int32 numSuccesses; /*Number of successful ops */
184 struct timeval sumTime; /*Sum of sample timings */
185 struct timeval sqrTime; /*Sum of squares of sample timings */
186 struct timeval minTime; /*Minimum timing value observed */
187 struct timeval maxTime; /*Minimum timing value observed */
191 * We discriminate byte size transfers into this many buckets.
193 #define FS_STATS_NUM_XFER_BUCKETS 9
195 #define FS_STATS_MAXBYTES_BUCKET0 128
196 #define FS_STATS_MAXBYTES_BUCKET1 1024
197 #define FS_STATS_MAXBYTES_BUCKET2 8192
198 #define FS_STATS_MAXBYTES_BUCKET3 16384
199 #define FS_STATS_MAXBYTES_BUCKET4 32768
200 #define FS_STATS_MAXBYTES_BUCKET5 131072
201 #define FS_STATS_MAXBYTES_BUCKET6 524288
202 #define FS_STATS_MAXBYTES_BUCKET7 1048576
206 * Record to track timings and byte sizes for data transfers.
208 struct fs_stats_xferData {
209 afs_int32 numXfers; /*Number of xfers */
210 afs_int32 numSuccesses; /*Number of successful xfers */
211 struct timeval sumTime; /*Sum of timing values */
212 struct timeval sqrTime; /*Sum of squares of timing values */
213 struct timeval minTime; /*Minimum xfer time recorded */
214 struct timeval maxTime; /*Maximum xfer time recorded */
215 afs_int32 sumBytes; /*Sum of bytes transferred */
216 afs_int32 minBytes; /*Minimum value observed */
217 afs_int32 maxBytes; /*Maximum value observed */
218 afs_int32 count[FS_STATS_NUM_XFER_BUCKETS]; /*Tally for each range of bytes */
222 * Macros to operate on time values.
224 * fs_stats_TimeLessThan(t1, t2) Non-zero if t1 is less than t2
225 * fs_stats_TimeGreaterThan(t1, t2) Non-zero if t1 is greater than t2
226 * fs_stats_GetDiff(t3, t1, t2) Set t3 to the difference between
227 * t1 and t2 (t1 is less than or
229 * fs_stats_AddTo(t1, t2) Add t2 to t1
230 * fs_stats_TimeAssign(t1, t2) Assign time t2 to t1
231 * afs_stats_SquareAddTo(t1,t2) Add square of t2 to t1
233 #define fs_stats_TimeLessThan(t1, t2) \
234 ((t1.tv_sec < t2.tv_sec) ? 1 : \
235 (t1.tv_sec > t2.tv_sec) ? 0 : \
236 (t1.tv_usec < t2.tv_usec) ? 1 : \
239 #define fs_stats_TimeGreaterThan(t1, t2) \
240 ((t1.tv_sec > t2.tv_sec) ? 1 : \
241 (t1.tv_sec < t2.tv_sec) ? 0 : \
242 (t1.tv_usec > t2.tv_usec) ? 1 : \
245 #define fs_stats_GetDiff(t3, t1, t2) \
248 * If the microseconds of the later time are smaller than \
249 * the earlier time, set up for proper subtraction (doing \
252 if (t2.tv_usec < t1.tv_usec) { \
253 t2.tv_usec += 1000000; \
256 t3.tv_sec = t2.tv_sec - t1.tv_sec; \
257 t3.tv_usec = t2.tv_usec - t1.tv_usec; \
260 #define fs_stats_AddTo(t1, t2) \
262 t1.tv_sec += t2.tv_sec; \
263 t1.tv_usec += t2.tv_usec; \
264 if (t1.tv_usec > 1000000) { \
265 t1.tv_usec -= 1000000; \
270 #define fs_stats_TimeAssign(t1, t2) \
272 t1.tv_sec = t2.tv_sec; \
273 t1.tv_usec = t2.tv_usec; \
276 #define fs_stats_SquareAddTo(t1, t2) \
280 t1.tv_sec += (int) (t2.tv_sec * t2.tv_sec \
281 + (0.000002 * t2.tv_sec) * t2.tv_usec) ; \
282 t1.tv_usec += (int) ((2 * t2.tv_sec * t2.tv_usec) % 1000000 \
283 + (0.000001 * t2.tv_usec) * t2.tv_usec); \
287 t1.tv_usec += (int) ((0.000001 * t2.tv_usec) * t2.tv_usec); \
289 while (t1.tv_usec > 1000000) { \
290 t1.tv_usec -= 1000000; \
296 * This is the detailed performance data collection for the File Server.
298 struct fs_stats_DetailedStats {
299 struct timeval epoch; /*Time when data collection began */
300 struct fs_stats_opTimingData
301 rpcOpTimes[FS_STATS_NUM_RPC_OPS]; /*Individual RPC operation timings */
302 struct fs_stats_xferData
303 xferOpTimes[FS_STATS_NUM_XFER_OPS]; /*Byte info for certain ops */
307 * This is all of the performance data, both overall and detailed.
309 struct fs_stats_FullPerfStats {
310 struct afs_PerfStats overall;
311 struct fs_stats_DetailedStats det;
315 * This is the structure accessible by specifying the
316 * AFS_XSTATSCOLL_FULL_PERF_INFO collection to the xstat package.
318 extern struct fs_stats_FullPerfStats afs_FullPerfStats;
322 * This is the structure accessible by specifying the
323 * AFS_XSTATSCOLL_PERF_INFO collection to the xstat package.
325 extern struct afs_PerfStats afs_perfstats;
328 * FileServer's name and IP address, both network byte order and
331 extern char FS_HostName[];
332 extern afs_uint32 FS_HostAddr_NBO;
333 extern afs_uint32 FS_HostAddr_HBO;
335 /* Logging helper functions */
337 struct fs_stats_opTimingData *opP;
338 struct fs_stats_xferData *xferP;
339 struct timeval opStartTime;
340 struct timeval xferStartTime;
343 extern void fsstats_StartOp(struct fsstats *stats, int index);
344 extern void fsstats_FinishOp(struct fsstats *stats, int code);
345 extern void fsstats_StartXfer(struct fsstats *stats, int index);
346 extern void fsstats_FinishXfer(struct fsstats *, int, afs_sfsize_t,
347 afs_sfsize_t, int *);
349 #endif /* __fs_stats_h */