f59963bc78be4fe470e41bfb0e81d75eab1055c5
[openafs.git] / src / afs / afs_stats.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
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
8  */
9
10 /*
11  * Statistics gathering stuff for the AFS cache manager.
12  */
13 /*
14  *  The remainder of this file contains the statistics gathering stuff.
15  */
16
17 #ifndef __OPENAFS_AFS_STATS_H__
18 #define __OPENAFS_AFS_STATS_H__
19
20 #include "afs/param.h"
21
22 /* the following is to work around a VAX compiler limitation */
23 #if defined(vax)
24 #undef AFS_NOSTATS
25 #define AFS_NOSTATS
26 #endif /* VAX environment */
27
28 #ifdef AFS_NOSTATS
29
30 /*
31  * The data collection routines are simply no-ops
32  */
33 #define AFS_STATCNT(arg)
34 #define AFS_MEANCNT(arg, value)
35 #define AFS_STATS(arg)
36 #define XSTATS_DECLS
37 #define XSTATS_START_TIME(arg)
38 #define XSTATS_START_CMTIME(arg)
39 #define XSTATS_END_TIME
40
41 #else /* AFS_NOSTATS */
42
43 #define AFS_STATS(arg) arg
44 #ifndef KERNEL
45 /* NOTE: Ensure this is the same size in user and kernel mode. */
46 typedef struct timeval osi_timeval_t;
47 #endif /* !KERNEL */
48
49 #define XSTATS_DECLS struct afs_stats_opTimingData *opP = NULL; \
50     osi_timeval_t opStartTime = { 0, 0}, opStopTime, elapsedTime
51
52 #define XSTATS_START_TIME(arg) \
53   opP = &(afs_stats_cmfullperf.rpc.fsRPCTimes[arg]); \
54   osi_GetuTime(&opStartTime);
55
56 #define XSTATS_START_CMTIME(arg) \
57   opP = &(afs_stats_cmfullperf.rpc.cmRPCTimes[arg]); \
58   osi_GetuTime(&opStartTime);
59
60 #define XSTATS_END_TIME osi_GetuTime(&opStopTime); \
61   (opP->numOps)++; \
62   if (!code) { (opP->numSuccesses)++; \
63      afs_stats_GetDiff(elapsedTime, opStartTime, opStopTime); \
64      afs_stats_AddTo((opP->sumTime), elapsedTime); \
65      afs_stats_SquareAddTo((opP->sqrTime), elapsedTime); \
66      if (afs_stats_TimeLessThan(elapsedTime, (opP->minTime))) { \
67         afs_stats_TimeAssign((opP->minTime), elapsedTime); \
68      } if (afs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) { \
69           afs_stats_TimeAssign((opP->maxTime), elapsedTime); } }
70
71 #endif /* AFS_NOSTATS */
72
73
74
75 struct afs_MeanStats {
76     afs_int32 average;
77     afs_int32 elements;
78 };
79
80 /*
81  * struct afs_CMCallStats
82  *      This is the place where we keep records on each and every
83  *      function call.
84  *
85  * This structure is encoded as a binary blob and thrown at the client
86  * for use by the xstat_cm interface. As the datastructure is unversioned,
87  * some rules apply;
88  *    *) Never add elements to the middle of the list. Everything new
89  *       must go at the end
90  *    *) Never remove elements from the list. If a function dies, don't
91  *       remove it's entry here (by all means, flag it as dead, though)
92  *    *) Never make elements conditional on preprocessor symbols. Doing
93  *       this would mean that the client has to be built with exactly
94  *       the same options as you are. Which isn't a great idea.
95  *
96  */
97 struct afs_CMCallStats {
98     afs_int32 C_afs_init;       /* afs_aix_subr.c */
99     afs_int32 C_gop_rdwr;       /* afs_aix_subr.c */
100     afs_int32 C_aix_gnode_rele; /* afs_aix_subr.c */
101     afs_int32 C_gettimeofday;   /* afs_aix_subr.c */
102     afs_int32 C_m_cpytoc;       /* afs_aix_subr.c */
103     afs_int32 C_aix_vattr_null; /* afs_aix_subr.c */
104     afs_int32 C_afs_gn_ftrunc;  /* afs_aixops.c */
105     afs_int32 C_afs_gn_rdwr;    /* afs_aixops.c */
106     afs_int32 C_afs_gn_ioctl;   /* afs_aixops.c */
107     afs_int32 C_afs_gn_lockctl; /* afs_aixops.c */
108     afs_int32 C_afs_gn_readlink;        /* afs_aixops.c */
109     afs_int32 C_afs_gn_readdir; /* afs_aixops.c */
110     afs_int32 C_afs_gn_select;  /* afs_aixops.c */
111     afs_int32 C_afs_gn_strategy;        /* afs_aixops.c */
112     afs_int32 C_afs_gn_symlink; /* afs_aixops.c */
113     afs_int32 C_afs_gn_revoke;  /* afs_aixops.c */
114     afs_int32 C_afs_gn_link;    /* afs_aixops.c */
115     afs_int32 C_afs_gn_mkdir;   /* afs_aixops.c */
116     afs_int32 C_afs_gn_mknod;   /* afs_aixops.c */
117     afs_int32 C_afs_gn_remove;  /* afs_aixops.c */
118     afs_int32 C_afs_gn_rename;  /* afs_aixops.c */
119     afs_int32 C_afs_gn_rmdir;   /* afs_aixops.c */
120     afs_int32 C_afs_gn_fid;     /* afs_aixops.c */
121     afs_int32 C_afs_gn_lookup;  /* afs_aixops.c */
122     afs_int32 C_afs_gn_open;    /* afs_aixops.c */
123     afs_int32 C_afs_gn_create;  /* afs_aixops.c */
124     afs_int32 C_afs_gn_hold;    /* afs_aixops.c */
125     afs_int32 C_afs_gn_close;   /* afs_aixops.c */
126     afs_int32 C_afs_gn_map;     /* afs_aixops.c */
127     afs_int32 C_afs_gn_rele;    /* afs_aixops.c */
128     afs_int32 C_afs_gn_unmap;   /* afs_aixops.c */
129     afs_int32 C_afs_gn_access;  /* afs_aixops.c */
130     afs_int32 C_afs_gn_getattr; /* afs_aixops.c */
131     afs_int32 C_afs_gn_setattr; /* afs_aixops.c */
132     afs_int32 C_afs_gn_fclear;  /* afs_aixops.c */
133     afs_int32 C_afs_gn_fsync;   /* afs_aixops.c */
134     afs_int32 C_pHash;          /* afs_buffer.c */
135     afs_int32 C_DInit;          /* afs_buffer.c */
136     afs_int32 C_DRead;          /* afs_buffer.c */
137     afs_int32 C_FixupBucket;    /* afs_buffer.c */
138     afs_int32 C_afs_newslot;    /* afs_buffer.c */
139     afs_int32 C_DRelease;       /* afs_buffer.c */
140     afs_int32 C_DFlush;         /* afs_buffer.c */
141     afs_int32 C_DFlushEntry;    /* afs_buffer.c */
142     afs_int32 C_DVOffset;       /* afs_buffer.c */
143     afs_int32 C_DZap;           /* afs_buffer.c */
144     afs_int32 C_DNew;           /* afs_buffer.c */
145     afs_int32 C_shutdown_bufferpackage; /* afs_buffer.c */
146     afs_int32 C_afs_CheckKnownBad;      /* afs_cache.c */
147     afs_int32 C_afs_RemoveVCB;  /* afs_cache.c */
148     afs_int32 C_afs_NewVCache;  /* afs_cache.c */
149     afs_int32 C_afs_FlushActiveVcaches; /* afs_cache.c */
150     afs_int32 C_afs_VerifyVCache;       /* afs_cache.c */
151     afs_int32 C_afs_WriteVCache;        /* afs_cache.c */
152     afs_int32 C_afs_GetVCache;  /* afs_cache.c */
153     afs_int32 C_afs_StuffVcache;        /* afs_cache.c */
154     afs_int32 C_afs_FindVCache; /* afs_cache.c */
155     afs_int32 C_afs_PutDCache;  /* afs_cache.c */
156     afs_int32 C_afs_PutVCache;  /* afs_cache.c */
157     afs_int32 C_CacheStoreProc; /* afs_cache.c */
158     afs_int32 C_afs_FindDCache; /* afs_cache.c */
159     afs_int32 C_afs_TryToSmush; /* afs_cache.c */
160     afs_int32 C_afs_AdjustSize; /* afs_cache.c */
161     afs_int32 C_afs_CheckSize;  /* afs_cache.c */
162     afs_int32 C_afs_StoreWarn;  /* afs_cache.c */
163     afs_int32 C_CacheFetchProc; /* afs_cache.c */
164     afs_int32 C_UFS_CacheStoreProc;     /* afs_cache.c */
165     afs_int32 C_UFS_CacheFetchProc;     /* afs_cache.c */
166     afs_int32 C_afs_GetDCache;  /* afs_cache.c */
167     afs_int32 C_afs_SimpleVStat;        /* afs_cache.c */
168     afs_int32 C_afs_ProcessFS;  /* afs_cache.c */
169     afs_int32 C_afs_InitCacheInfo;      /* afs_cache.c */
170     afs_int32 C_afs_InitVolumeInfo;     /* afs_cache.c */
171     afs_int32 C_afs_InitCacheFile;      /* afs_cache.c */
172     afs_int32 C_afs_CacheInit;  /* afs_cache.c */
173     afs_int32 C_afs_GetDSlot;   /* afs_cache.c */
174     afs_int32 C_afs_WriteThroughDSlots; /* afs_cache.c */
175     afs_int32 C_afs_MemGetDSlot;        /* afs_cache.c */
176     afs_int32 C_afs_UFSGetDSlot;        /* afs_cache.c */
177     afs_int32 C_afs_StoreDCache;        /* afs_cache.c */
178     afs_int32 C_afs_StoreMini;  /* afs_cache.c */
179     afs_int32 C_shutdown_cache; /* afs_cache.c */
180     afs_int32 C_afs_StoreAllSegments;   /* afs_cache.c */
181     afs_int32 C_afs_InvalidateAllSegments;      /* afs_cache.c */
182     afs_int32 C_afs_TruncateAllSegments;        /* afs_cache.c */
183     afs_int32 C_afs_CheckVolSync;       /* afs_cache.c */
184     afs_int32 C_afs_wakeup;     /* afs_cache.c */
185     afs_int32 C_afs_CFileOpen;  /* afs_cache.c */
186     afs_int32 C_afs_CFileTruncate;      /* afs_cache.c */
187     afs_int32 C_afs_GetDownD;   /* afs_cache.c */
188     afs_int32 C_afs_WriteDCache;        /* afs_cache.c */
189     afs_int32 C_afs_FlushDCache;        /* afs_cache.c */
190     afs_int32 C_afs_GetDownDSlot;       /* afs_cache.c */
191     afs_int32 C_afs_FlushVCache;        /* afs_cache.c */
192     afs_int32 C_afs_GetDownV;   /* afs_cache.c */
193     afs_int32 C_afs_QueueVCB;   /* afs_cache.c */
194     afs_int32 C_afs_call;       /* afs_call.c */
195     afs_int32 C_afs_syscall_call;       /* afs_call.c */
196     afs_int32 C_syscall;        /* afs_call.c */
197     afs_int32 C_lpioctl;        /* afs_call.c */
198     afs_int32 C_lsetpag;        /* afs_call.c */
199     afs_int32 C_afs_syscall;    /* afs_call.c */
200     afs_int32 C_afs_CheckInit;  /* afs_call.c */
201     afs_int32 C_afs_shutdown;   /* afs_call.c */
202     afs_int32 C_shutdown_BKG;   /* afs_call.c */
203     afs_int32 C_shutdown_afstest;       /* afs_call.c */
204     afs_int32 C_SRXAFSCB_GetCE; /* afs_callback.c */
205     afs_int32 C_ClearCallBack;  /* afs_callback.c */
206     afs_int32 C_SRXAFSCB_GetLock;       /* afs_callback.c */
207     afs_int32 C_SRXAFSCB_CallBack;      /* afs_callback.c */
208     afs_int32 C_SRXAFSCB_InitCallBackState;     /* afs_callback.c */
209     afs_int32 C_SRXAFSCB_Probe; /* afs_callback.c */
210     afs_int32 C_afs_RXCallBackServer;   /* afs_callback.c */
211     afs_int32 C_shutdown_CB;    /* afs_callback.c */
212     afs_int32 C_afs_Chunk;      /* afs_chunk.c */
213     afs_int32 C_afs_ChunkBase;  /* afs_chunk.c */
214     afs_int32 C_afs_ChunkOffset;        /* afs_chunk.c */
215     afs_int32 C_afs_ChunkSize;  /* afs_chunk.c */
216     afs_int32 C_afs_ChunkToBase;        /* afs_chunk.c */
217     afs_int32 C_afs_ChunkToSize;        /* afs_chunk.c */
218     afs_int32 C_afs_SetChunkSize;       /* afs_chunk.c */
219
220     afs_int32 C_afs_config;     /* afs_config.c */
221     afs_int32 C_mem_freebytes;  /* afs_config.c */
222     afs_int32 C_mem_getbytes;   /* afs_config.c */
223     afs_int32 C_fpalloc;        /* afs_config.c */
224     afs_int32 C_kluge_init;     /* afs_config.c */
225     afs_int32 C_ufdalloc;       /* afs_config.c */
226     afs_int32 C_ufdfree;        /* afs_config.c */
227     afs_int32 C_commit;         /* afs_config.c */
228     afs_int32 C_dev_ialloc;     /* afs_config.c */
229     afs_int32 C_ffree;          /* afs_config.c */
230     afs_int32 C_iget;           /* afs_config.c */
231     afs_int32 C_iptovp;         /* afs_config.c */
232     afs_int32 C_ilock;          /* afs_config.c */
233     afs_int32 C_irele;          /* afs_config.c */
234     afs_int32 C_iput;           /* afs_config.c */
235
236     afs_int32 C_afs_Daemon;     /* afs_daemons.c */
237     afs_int32 C_afs_CheckRootVolume;    /* afs_daemons.c */
238     afs_int32 C_BPath;          /* afs_daemons.c */
239     afs_int32 C_BPrefetch;      /* afs_daemons.c */
240     afs_int32 C_BStore;         /* afs_daemons.c */
241     afs_int32 C_afs_BBusy;      /* afs_daemons.c */
242     afs_int32 C_afs_BQueue;     /* afs_daemons.c */
243     afs_int32 C_afs_BRelease;   /* afs_daemons.c */
244     afs_int32 C_afs_BackgroundDaemon;   /* afs_daemons.c */
245     afs_int32 C_shutdown_daemons;       /* afs_daemons.c */
246     afs_int32 C_exporter_add;   /* afs_exporter.c */
247     afs_int32 C_exporter_find;  /* afs_exporter.c */
248     afs_int32 C_afs_gfs_kalloc; /* afs_gfs_subr.c */
249     afs_int32 C_IsAfsVnode;     /* afs_gfs_subr.c */
250     afs_int32 C_SetAfsVnode;    /* afs_gfs_subr.c */
251     afs_int32 C_afs_gfs_kfree;  /* afs_gfs_subr.c */
252     afs_int32 C_gop_lookupname; /* afs_gfs_subr.c */
253     afs_int32 C_gfsvop_getattr; /* afs_gfs_subr.c */
254     afs_int32 C_gfsvop_rdwr;    /* afs_gfs_subr.c */
255     afs_int32 C_afs_uniqtime;   /* afs_gfs_subr.c */
256     afs_int32 C_gfs_vattr_null; /* afs_gfs_subr.c */
257     afs_int32 C_afs_lock;       /* afs_gfsops.c */
258     afs_int32 C_afs_unlock;     /* afs_gfsops.c */
259     afs_int32 C_afs_update;     /* afs_gfsops.c */
260     afs_int32 C_afs_gclose;     /* afs_gfsops.c */
261     afs_int32 C_afs_gopen;      /* afs_gfsops.c */
262     afs_int32 C_afs_greadlink;  /* afs_gfsops.c */
263     afs_int32 C_afs_select;     /* afs_gfsops.c */
264     afs_int32 C_afs_gbmap;      /* afs_gfsops.c */
265     afs_int32 C_afs_getfsdata;  /* afs_gfsops.c */
266     afs_int32 C_afs_gsymlink;   /* afs_gfsops.c */
267     afs_int32 C_afs_namei;      /* afs_gfsops.c */
268     afs_int32 C_printgnode;     /* afs_gfsops.c */
269     afs_int32 C_HaveGFSLock;    /* afs_gfsops.c */
270     afs_int32 C_afs_gmount;     /* afs_gfsops.c */
271     afs_int32 C_AddGFSLock;     /* afs_gfsops.c */
272     afs_int32 C_RemoveGFSLock;  /* afs_gfsops.c */
273     afs_int32 C_afs_grlock;     /* afs_gfsops.c */
274     afs_int32 C_afs_gumount;    /* afs_gfsops.c */
275     afs_int32 C_afs_gget;       /* afs_gfsops.c */
276     afs_int32 C_afs_glink;      /* afs_gfsops.c */
277     afs_int32 C_afs_gmkdir;     /* afs_gfsops.c */
278     afs_int32 C_afs_sbupdate;   /* afs_gfsops.c */
279     afs_int32 C_afs_unlink;     /* afs_gfsops.c */
280     afs_int32 C_afs_grmdir;     /* afs_gfsops.c */
281     afs_int32 C_afs_makenode;   /* afs_gfsops.c */
282     afs_int32 C_afs_grename;    /* afs_gfsops.c */
283     afs_int32 C_afs_rele;       /* afs_gfsops.c */
284     afs_int32 C_afs_syncgp;     /* afs_gfsops.c */
285     afs_int32 C_afs_getval;     /* afs_gfsops.c */
286     afs_int32 C_afs_gfshack;    /* afs_gfsops.c */
287     afs_int32 C_afs_trunc;      /* afs_gfsops.c */
288     afs_int32 C_afs_rwgp;       /* afs_gfsops.c */
289     afs_int32 C_afs_stat;       /* afs_gfsops.c */
290     afs_int32 C_afsc_link;      /* afs_hp_subr.c */
291     afs_int32 C_hpsobind;       /* afs_hp_subr.c */
292     afs_int32 C_hpsoclose;      /* afs_hp_subr.c */
293     afs_int32 C_hpsocreate;     /* afs_hp_subr.c */
294     afs_int32 C_hpsoreserve;    /* afs_hp_subr.c */
295     afs_int32 C_afs_vfs_mount;  /* afs_hp_subr.c */
296     afs_int32 C_devtovfs;       /* afs_istuff.c */
297     afs_int32 C_igetinode;      /* afs_istuff.c */
298     afs_int32 C_afs_syscall_iopen;      /* afs_istuff.c */
299     afs_int32 C_iopen;          /* afs_istuff.c */
300     afs_int32 C_afs_syscall_iincdec;    /* afs_istuff.c */
301     afs_int32 C_afs_syscall_ireadwrite; /* afs_istuff.c */
302     afs_int32 C_iincdec;        /* afs_istuff.c */
303     afs_int32 C_ireadwrite;     /* afs_istuff.c */
304     afs_int32 C_oiread;         /* afs_istuff.c */
305     afs_int32 C_AHash;          /* afs_istuff.c */
306     afs_int32 C_QTOA;           /* afs_istuff.c */
307     afs_int32 C_afs_FindPartByDev;      /* afs_istuff.c */
308     afs_int32 C_aux_init;       /* afs_istuff.c */
309     afs_int32 C_afs_GetNewPart; /* afs_istuff.c */
310     afs_int32 C_afs_InitAuxVolFile;     /* afs_istuff.c */
311     afs_int32 C_afs_CreateAuxEntry;     /* afs_istuff.c */
312     afs_int32 C_afs_GetAuxSlot; /* afs_istuff.c */
313     afs_int32 C_afs_GetDownAux; /* afs_istuff.c */
314     afs_int32 C_afs_FlushAuxCache;      /* afs_istuff.c */
315     afs_int32 C_afs_GetAuxInode;        /* afs_istuff.c */
316     afs_int32 C_afs_PutAuxInode;        /* afs_istuff.c */
317     afs_int32 C_afs_ReadAuxInode;       /* afs_istuff.c */
318     afs_int32 C_afs_WriteAuxInode;      /* afs_istuff.c */
319     afs_int32 C_afs_auxcall;    /* afs_istuff.c */
320     afs_int32 C_tmpdbg_auxtbl;  /* afs_istuff.c */
321     afs_int32 C_tmpdbg_parttbl; /* afs_istuff.c */
322     afs_int32 C_idec;           /* afs_istuff.c */
323     afs_int32 C_iinc;           /* afs_istuff.c */
324     afs_int32 C_iread;          /* afs_istuff.c */
325     afs_int32 C_iwrite;         /* afs_istuff.c */
326     afs_int32 C_getinode;       /* afs_istuff.c */
327     afs_int32 C_trygetfs;       /* afs_istuff.c */
328     afs_int32 C_iforget;        /* afs_istuff.c */
329     afs_int32 C_afs_syscall_icreate;    /* afs_istuff.c */
330     afs_int32 C_icreate;        /* afs_istuff.c */
331     afs_int32 C_Lock_Init;      /* afs_lock.c */
332     afs_int32 C_Lock_Obtain;    /* afs_lock.c */
333     afs_int32 C_Lock_ReleaseR;  /* afs_lock.c */
334     afs_int32 C_Lock_ReleaseW;  /* afs_lock.c */
335     afs_int32 C_afs_BozonLock;  /* afs_lock.c */
336     afs_int32 C_afs_BozonUnlock;        /* afs_lock.c */
337     afs_int32 C_osi_SleepR;     /* afs_lock.c */
338     afs_int32 C_osi_SleepS;     /* afs_lock.c */
339     afs_int32 C_osi_SleepW;     /* afs_lock.c */
340     afs_int32 C_osi_Sleep;      /* afs_lock */
341     afs_int32 C_afs_BozonInit;  /* afs_lock.c */
342     afs_int32 C_afs_CheckBozonLock;     /* afs_lock.c */
343     afs_int32 C_afs_CheckBozonLockBlocking;     /* afs_lock.c */
344     afs_int32 C_xxxinit;        /* afs_main.c */
345     afs_int32 C_KernelEntry;    /* afs_main.c */
346     afs_int32 C_afs_InitMemCache;       /* afs_memcache.c */
347     afs_int32 C_afs_LookupMCE;  /* afs_memcache.c */
348     afs_int32 C_afs_MemReadBlk; /* afs_memcache.c */
349     afs_int32 C_afs_MemReadUIO; /* afs_memcache.c */
350     afs_int32 C_afs_MemWriteBlk;        /* afs_memcache.c */
351     afs_int32 C_afs_MemCacheStoreProc;  /* afs_memcache.c */
352     afs_int32 C_afs_MemCacheTruncate;   /* afs_memcache.c */
353     afs_int32 C_afs_MemWriteUIO;        /* afs_memcache.c */
354     afs_int32 C_afs_MemCacheFetchProc;  /* afs_memcache.c */
355     afs_int32 C_afs_vnode_pager_create; /* afs_next_aux.c */
356     afs_int32 C_next_KernelEntry;       /* afs_next_subr.c */
357     afs_int32 C_afs_GetNfsClientPag;    /* afs_nfsclnt.c */
358     afs_int32 C_afs_FindNfsClientPag;   /* afs_nfsclnt.c */
359     afs_int32 C_afs_PutNfsClientPag;    /* afs_nfsclnt.c */
360     afs_int32 C_afs_nfsclient_reqhandler;       /* afs_nfsclnt.c */
361     afs_int32 C_afs_nfsclient_GC;       /* afs_nfsclnt.c */
362     afs_int32 C_afs_nfsclient_hold;     /* afs_nfsclnt.c */
363     afs_int32 C_afs_nfsclient_stats;    /* afs_nfsclnt.c */
364     afs_int32 C_afs_nfsclient_sysname;  /* afs_nfsclnt.c */
365     afs_int32 C_afs_nfsclient_shutdown; /* afs_nfsclnt.c */
366     afs_int32 C_afs_rfs_readdir_fixup;  /* afs_nfssrv.c */
367     afs_int32 C_afs_rfs_dispatch;       /* afs_nfssrv.c */
368     afs_int32 C_afs_xnfs_svc;   /* afs_nfssrv.c */
369     afs_int32 C_afs_xdr_putrddirres;    /* afs_nfssrv.c */
370     afs_int32 C_afs_rfs_readdir;        /* afs_nfssrv.c */
371     afs_int32 C_afs_rfs_rddirfree;      /* afs_nfssrv.c */
372     afs_int32 C_rfs_dupcreate;  /* afs_nfssrv.c */
373     afs_int32 C_rfs_dupsetattr; /* afs_nfssrv.c */
374     afs_int32 C_Nfs2AfsCall;    /* afs_nfssrv.c */
375     afs_int32 C_afs_sun_xuntext;        /* afs_osi.c */
376     afs_int32 C_osi_Active;     /* afs_osi.c */
377     afs_int32 C_osi_FlushPages; /* afs_osi.c */
378     afs_int32 C_osi_FlushText;  /* afs_osi.c */
379     afs_int32 C_osi_CallProc;   /* afs_osi.c */
380     afs_int32 C_osi_CancelProc; /* afs_osi.c */
381     afs_int32 C_osi_Invisible;  /* afs_osi.c */
382     afs_int32 C_osi_Time;       /* afs_osi.c */
383     afs_int32 C_osi_Alloc;      /* afs_osi.c */
384     afs_int32 C_osi_SetTime;    /* afs_osi.c */
385     afs_int32 C_osi_Dump;       /* afs_osi.c */
386     afs_int32 C_osi_Free;       /* afs_osi.c */
387     afs_int32 C_shutdown_osi;   /* afs_osi.c */
388     afs_int32 C_osi_UFSOpen;    /* afs_osifile.c */
389     afs_int32 C_osi_Close;      /* afs_osifile.c */
390     afs_int32 C_osi_Stat;       /* afs_osifile.c */
391     afs_int32 C_osi_Truncate;   /* afs_osifile.c */
392     afs_int32 C_osi_Read;       /* afs_osifile.c */
393     afs_int32 C_osi_Write;      /* afs_osifile.c */
394     afs_int32 C_osi_MapStrategy;        /* afs_osifile.c */
395     afs_int32 C_shutdown_osifile;       /* afs_osifile.c */
396     afs_int32 C_osi_FreeLargeSpace;     /* afs_osinet.c */
397     afs_int32 C_osi_FreeSmallSpace;     /* afs_osinet.c */
398     afs_int32 C_pkt_iodone;     /* afs_osinet.c */
399     afs_int32 C_shutdown_osinet;        /* afs_osinet.c */
400     afs_int32 C_afs_cs;         /* afs_osinet.c */
401     afs_int32 C_osi_AllocLargeSpace;    /* afs_osinet.c */
402     afs_int32 C_osi_AllocSmallSpace;    /* afs_osinet.c */
403     afs_int32 C_osi_CloseToTheEdge;     /* afs_osinet.c */
404     afs_int32 C_osi_xgreedy;    /* afs_osinet.c */
405     afs_int32 C_osi_FreeSocket; /* afs_osinet.c */
406     afs_int32 C_osi_NewSocket;  /* afs_osinet.c */
407     afs_int32 C_trysblock;      /* afs_osinet.c */
408     afs_int32 C_osi_NetSend;    /* afs_osinet.c */
409     afs_int32 C_WaitHack;       /* afs_osinet.c */
410     afs_int32 C_osi_CancelWait; /* afs_osinet.c */
411     afs_int32 C_osi_InitWaitHandle;     /* afs_osinet.c */
412     afs_int32 C_osi_Wakeup;     /* afs_osinet.c */
413     afs_int32 C_osi_Wait;       /* afs_osinet.c */
414     afs_int32 C_dirp_Read;      /* afs_physio.c */
415     afs_int32 C_dirp_SetCacheDev;       /* afs_physio.c */
416     afs_int32 C_Die;            /* afs_physio.c */
417     afs_int32 C_dirp_Cpy;       /* afs_physio.c */
418     afs_int32 C_dirp_Eq;        /* afs_physio.c */
419     afs_int32 C_dirp_Write;     /* afs_physio.c */
420     afs_int32 C_dirp_Zap;       /* afs_physio.c */
421     afs_int32 C_PSetVolumeStatus;       /* afs_pioctl.c */
422     afs_int32 C_PFlush;         /* afs_pioctl.c */
423     afs_int32 C_PNewStatMount;  /* afs_pioctl.c */
424     afs_int32 C_PGetTokens;     /* afs_pioctl.c */
425     afs_int32 C_PUnlog;         /* afs_pioctl.c */
426     afs_int32 C_PCheckServers;  /* afs_pioctl.c */
427     afs_int32 C_PMariner;       /* afs_pioctl.c */
428     afs_int32 C_PCheckAuth;     /* afs_pioctl.c */
429     afs_int32 C_PCheckVolNames; /* afs_pioctl.c */
430     afs_int32 C_PFindVolume;    /* afs_pioctl.c */
431     afs_int32 C_Prefetch;       /* afs_pioctl.c */
432     afs_int32 C_PGetCacheSize;  /* afs_pioctl.c */
433     afs_int32 C_PRemoveCallBack;        /* afs_pioctl.c */
434     afs_int32 C_PSetCacheSize;  /* afs_pioctl.c */
435     afs_int32 C_PViceAccess;    /* afs_pioctl.c */
436     afs_int32 C_PListCells;     /* afs_pioctl.c */
437     afs_int32 C_PNewCell;       /* afs_pioctl.c */
438     afs_int32 C_PRemoveMount;   /* afs_pioctl.c */
439     afs_int32 C_HandleIoctl;    /* afs_pioctl.c */
440     afs_int32 C__AFSIOCTL;      /* afs_pioctl.c */
441     afs_int32 C__VALIDAFSIOCTL; /* afs_pioctl.c */
442     afs_int32 C_PGetCellStatus; /* afs_pioctl.c */
443     afs_int32 C_PSetCellStatus; /* afs_pioctl.c */
444     afs_int32 C_PVenusLogging;  /* afs_pioctl.c */
445     afs_int32 C_PFlushVolumeData;       /* afs_pioctl.c */
446     afs_int32 C_PSetSysName;    /* afs_pioctl.c */
447     afs_int32 C_PExportAfs;     /* afs_pioctl.c */
448     afs_int32 C_HandleClientContext;    /* afs_pioctl.c */
449     afs_int32 C_afs_ioctl;      /* afs_pioctl.c */
450     afs_int32 C_afs_xioctl;     /* afs_pioctl.c */
451     afs_int32 C_afs_pioctl;     /* afs_pioctl.c */
452     afs_int32 C_afs_syscall_pioctl;     /* afs_pioctl.c */
453     afs_int32 C_HandlePioctl;   /* afs_pioctl.c */
454     afs_int32 C_PGetAcl;        /* afs_pioctl.c */
455     afs_int32 C_PGetFID;        /* afs_pioctl.c */
456     afs_int32 C_PSetAcl;        /* afs_pioctl.c */
457     afs_int32 C_PBogus;         /* afs_pioctl.c */
458     afs_int32 C_PGetFileCell;   /* afs_pioctl.c */
459     afs_int32 C_PGetWSCell;     /* afs_pioctl.c */
460     afs_int32 C_PNoop;          /* afs_pioctl.c */
461     afs_int32 C_PGetUserCell;   /* afs_pioctl.c */
462     afs_int32 C_PSetTokens;     /* afs_pioctl.c */
463     afs_int32 C_PGetVolumeStatus;       /* afs_pioctl.c */
464     afs_int32 C_afs_ResetAccessCache;   /* afs_resource.c */
465     afs_int32 C_afs_FindUser;   /* afs_resource.c */
466     afs_int32 C_afs_ResetUserConns;     /* afs_resource.c */
467     afs_int32 C_afs_ResourceInit;       /* afs_resource.c */
468     afs_int32 C_afs_GetCell;    /* afs_resource.c */
469     afs_int32 C_afs_GetCellByIndex;     /* afs_resource.c */
470     afs_int32 C_afs_GetCellByName;      /* afs_resource.c */
471     afs_int32 C_afs_GetRealCellByIndex; /* afs_resource.c */
472     afs_int32 C_afs_NewCell;    /* afs_resource.c */
473     afs_int32 C_afs_GetUser;    /* afs_resource.c */
474     afs_int32 C_afs_PutUser;    /* afs_resource.c */
475     afs_int32 C_afs_SetPrimary; /* afs_resource.c */
476     afs_int32 C_CheckVLDB;      /* afs_resource.c */
477     afs_int32 C_afs_GetVolume;  /* afs_resource.c */
478     afs_int32 C_afs_GetVolumeByName;    /* afs_resource.c */
479     afs_int32 C_InstallVolumeEntry;     /* afs_resource.c */
480     afs_int32 C_InstallVolumeInfo;      /* afs_resource.c */
481     afs_int32 C_afs_FindServer; /* afs_resource.c */
482     afs_int32 C_afs_PutVolume;  /* afs_resource.c */
483     afs_int32 C_afs_random;     /* afs_resource.c */
484     afs_int32 C_ranstage;       /* afs_resource.c */
485     afs_int32 C_RemoveUserConns;        /* afs_resource.c */
486     afs_int32 C_afs_MarinerLog; /* afs_resource.c */
487     afs_int32 C_afs_vtoi;       /* afs_resource.c */
488     afs_int32 C_afs_GetServer;  /* afs_resource.c */
489     afs_int32 C_afs_SortServers;        /* afs_resource.c */
490     afs_int32 C_afs_Conn;       /* afs_resource.c */
491     afs_int32 C_afs_ConnByHost; /* afs_resource.c */
492     afs_int32 C_afs_ConnByMHosts;       /* afs_resource.c */
493     afs_int32 C_afs_Analyze;    /* afs_resource.c */
494     afs_int32 C_afs_PutConn;    /* afs_resource.c */
495     afs_int32 C_afs_ResetVolumeInfo;    /* afs_resource.c */
496     afs_int32 C_StartLogFile;   /* afs_resource.c */
497     afs_int32 C_afs_SetLogFile; /* afs_resource.c */
498     afs_int32 C_EndLogFile;     /* afs_resource.c */
499     afs_int32 C_afs_dp;         /* afs_resource.c */
500     afs_int32 C_fprf;           /* afs_resource.c */
501     afs_int32 C_fprint;         /* afs_resource.c */
502     afs_int32 C_fprintn;        /* afs_resource.c */
503     afs_int32 C_afs_CheckLocks; /* afs_resource.c */
504     afs_int32 C_puttofile;      /* afs_resource.c */
505     afs_int32 C_shutdown_AFS;   /* afs_resource.c */
506     afs_int32 C_afs_CheckCacheResets;   /* afs_resource.c */
507     afs_int32 C_afs_GCUserData; /* afs_resource.c */
508     afs_int32 C_VSleep;         /* afs_resource.c */
509     afs_int32 C_afs_CheckCode;  /* afs_resource.c */
510     afs_int32 C_afs_CopyError;  /* afs_resource.c */
511     afs_int32 C_afs_FinalizeReq;        /* afs_resource.c */
512     afs_int32 C_afs_cv2string;  /* afs_resource.c */
513     afs_int32 C_afs_FindVolCache;       /* afs_resource.c */
514     afs_int32 C_afs_GetVolCache;        /* afs_resource.c */
515     afs_int32 C_afs_GetVolSlot; /* afs_resource.c */
516     afs_int32 C_afs_WriteVolCache;      /* afs_resource.c */
517     afs_int32 C_afs_UFSGetVolSlot;      /* afs_resource.c */
518     afs_int32 C_afs_CheckVolumeNames;   /* afs_resource.c */
519     afs_int32 C_afs_MemGetVolSlot;      /* afs_resource.c */
520     afs_int32 C_print_internet_address; /* afs_resource.c */
521     afs_int32 C_CheckVLServer;  /* afs_resource.c */
522     afs_int32 C_HaveCallBacksFrom;      /* afs_resource.c */
523     afs_int32 C_ServerDown;     /* afs_resource.c */
524     afs_int32 C_afs_CheckServers;       /* afs_resource.c */
525     afs_int32 C_afs_AddToMean;  /* afs_stat.c */
526     afs_int32 C_afs_GetCMStat;  /* afs_stat.c */
527     afs_int32 C_afs_getpage;    /* afs_sun_subr.c */
528     afs_int32 C_afs_putpage;    /* afs_sun_subr.c */
529     afs_int32 C_afs_nfsrdwr;    /* afs_sun_subr.c */
530     afs_int32 C_afs_map;        /* afs_sun_subr.c */
531     afs_int32 C_afs_cmp;        /* afs_sun_subr.c */
532     afs_int32 C_afs_cntl;       /* afs_sun_subr.c */
533     afs_int32 C_afs_dump;       /* afs_sun_subr.c */
534     afs_int32 C_afs_realvp;     /* afs_sun_subr.c */
535     afs_int32 C_afs_PageLeft;   /* afs_sun_subr.c */
536     afs_int32 C_afsinit;        /* afs_vfsops.c */
537     afs_int32 C_afs_mount;      /* afs_vfsops.c */
538     afs_int32 C_afs_unmount;    /* afs_vfsops.c */
539     afs_int32 C_afs_root;       /* afs_vfsops.c */
540     afs_int32 C_afs_statfs;     /* afs_vfsops.c */
541     afs_int32 C_afs_sync;       /* afs_vfsops.c */
542     afs_int32 C_afs_vget;       /* afs_vfsops.c */
543     afs_int32 C_afs_mountroot;  /* afs_vfsops.c */
544     afs_int32 C_afs_swapvp;     /* afs_vfsops.c */
545     afs_int32 C_afs_AddMarinerName;     /* afs_vnodeops.c */
546     afs_int32 C_afs_setpag;     /* afs_vnodeops.c */
547     afs_int32 C_genpag;         /* afs_vnodeops.c */
548     afs_int32 C_getpag;         /* afs_vnodeops.c */
549     afs_int32 C_afs_GetMariner; /* afs_vnodeops.c */
550     afs_int32 C_afs_badop;      /* afs_vnodeops.c */
551     afs_int32 C_afs_index;      /* afs_vnodeops.c */
552     afs_int32 C_afs_noop;       /* afs_vnodeops.c */
553     afs_int32 C_afs_open;       /* afs_vnodeops.c */
554     afs_int32 C_afs_closex;     /* afs_vnodeops.c */
555     afs_int32 C_afs_close;      /* afs_vnodeops.c */
556     afs_int32 C_afs_MemWrite;   /* afs_vnodeops.c */
557     afs_int32 C_afs_write;      /* afs_vnodeops.c */
558     afs_int32 C_afs_UFSWrite;   /* afs_vnodeops.c */
559     afs_int32 C_afs_rdwr;       /* afs_vnodeops.c */
560     afs_int32 C_afs_MemRead;    /* afs_vnodeops.c */
561     afs_int32 C_afs_read;       /* afs_vnodeops.c */
562     afs_int32 C_FIXUPSTUPIDINODE;       /* afs_vnodeops.c */
563     afs_int32 C_afs_UFSRead;    /* afs_vnodeops.c */
564     afs_int32 C_afs_CopyOutAttrs;       /* afs_vnodeops.c */
565     afs_int32 C_afs_getattr;    /* afs_vnodeops.c */
566     afs_int32 C_afs_VAttrToAS;  /* afs_vnodeops.c */
567     afs_int32 C_afs_setattr;    /* afs_vnodeops.c */
568     afs_int32 C_EvalMountPoint; /* afs_vnodeops.c */
569     afs_int32 C_afs_access;     /* afs_vnodeops.c */
570     afs_int32 C_ENameOK;        /* afs_vnodeops.c */
571     afs_int32 C_HandleAtName;   /* afs_vnodeops.c */
572     afs_int32 C_getsysname;     /* afs_vnodeops.c */
573     afs_int32 C_strcat;         /* afs_vnodeops.c */
574     afs_int32 C_afs_lookup;     /* afs_vnodeops.c */
575     afs_int32 C_afs_create;     /* afs_vnodeops.c */
576     afs_int32 C_afs_LocalHero;  /* afs_vnodeops.c */
577     afs_int32 C_FetchWholeEnchilada;    /* afs_vnodeops.c */
578     afs_int32 C_afs_remove;     /* afs_vnodeops.c */
579     afs_int32 C_afs_link;       /* afs_vnodeops.c */
580     afs_int32 C_afs_rename;     /* afs_vnodeops.c */
581     afs_int32 C_afs_InitReq;    /* afs_vnodeops.c */
582     afs_int32 C_afs_mkdir;      /* afs_vnodeops.c */
583     afs_int32 C_BlobScan;       /* afs_vnodeops.c */
584     afs_int32 C_afs_rmdir;      /* afs_vnodeops.c */
585     afs_int32 C_RecLen;         /* afs_vnodeops.c */
586     afs_int32 C_RoundToInt;     /* afs_vnodeops.c */
587     afs_int32 C_afs_readdir_with_offlist;       /* afs_vnodeops.c */
588     afs_int32 C_DIRSIZ_LEN;     /* afs_vnodeops.c */
589     afs_int32 C_afs_readdir_move;       /* afs_vnodeops.c */
590     afs_int32 C_afs_readdir_iter;       /* afs_vnodeops.c */
591     afs_int32 C_HandleFlock;    /* afs_vnodeops.c */
592     afs_int32 C_afs_readdir;    /* afs_vnodeops.c */
593     afs_int32 C_afs_symlink;    /* afs_vnodeops.c */
594     afs_int32 C_afs_HandleLink; /* afs_vnodeops.c */
595     afs_int32 C_afs_MemHandleLink;      /* afs_vnodeops.c */
596     afs_int32 C_afs_UFSHandleLink;      /* afs_vnodeops.c */
597     afs_int32 C_afs_readlink;   /* afs_vnodeops.c */
598     afs_int32 C_afs_fsync;      /* afs_vnodeops.c */
599     afs_int32 C_afs_inactive;   /* afs_vnodeops.c */
600     afs_int32 C_afs_ustrategy;  /* afs_vnodeops.c */
601     afs_int32 C_afs_bread;      /* afs_vnodeops.c */
602     afs_int32 C_afs_brelse;     /* afs_vnodeops.c */
603     afs_int32 C_afs_bmap;       /* afs_vnodeops.c */
604     afs_int32 C_afs_fid;        /* afs_vnodeops.c */
605     afs_int32 C_afs_strategy;   /* afs_vnodeops.c */
606     afs_int32 C_afs_FakeClose;  /* afs_vnodeops.c */
607     afs_int32 C_afs_FakeOpen;   /* afs_vnodeops.c */
608     afs_int32 C_afs_StoreOnLastReference;       /* afs_vnodeops.c */
609     afs_int32 C_afs_GetAccessBits;      /* afs_vnodeops.c */
610     afs_int32 C_afs_AccessOK;   /* afs_vnodeops.c */
611     afs_int32 C_shutdown_vnodeops;      /* afs_vnodeops.c */
612     afs_int32 C_afsio_copy;     /* afs_vnodeops.c */
613     afs_int32 C_afsio_trim;     /* afs_vnodeops.c */
614     afs_int32 C_afs_page_read;  /* afs_vnodeops.c */
615     afs_int32 C_afs_page_write; /* afs_vnodeops.c */
616     afs_int32 C_afsio_skip;     /* afs_vnodeops.c */
617     afs_int32 C_afs_read1dir;   /* afs_vnodeops.c */
618     afs_int32 C_afs_get_groups_from_pag;        /* afs_vnodeops.c */
619     afs_int32 C_afs_get_pag_from_groups;        /* afs_vnodeops.c */
620     afs_int32 C_PagInCred;      /* afs_vnodeops.c */
621     afs_int32 C_afs_getgroups;  /* afs_vnodeops.c */
622     afs_int32 C_setpag;         /* afs_vnodeops.c */
623     afs_int32 C_afs_setgroups;  /* afs_vnodeops.c */
624     afs_int32 C_afs_page_in;    /* afs_vnodeops.c */
625     afs_int32 C_afs_page_out;   /* afs_vnodeops.c */
626     afs_int32 C_AddPag;         /* afs_vnodeops.c */
627     afs_int32 C_afs_AdvanceFD;  /* afs_vnodeops.c */
628     afs_int32 C_afs_lockf;      /* afs_vnodeops.c */
629     afs_int32 C_afs_xsetgroups; /* afs_vnodeops.c */
630     afs_int32 C_afs_nlinks;     /* afs_vnodeops.c */
631     afs_int32 C_DoLockWarning;  /* afs_vnodeops.c */
632     afs_int32 C_afs_lockctl;    /* afs_vnodeops.c */
633     afs_int32 C_afs_xflock;     /* afs_vnodeops.c */
634     afs_int32 C_PSetSPrefs;     /* afs_pioctl.c */
635     afs_int32 C_PGetSPrefs;     /* afs_pioctl.c */
636     afs_int32 C_afs_warn;       /* afs_resource.c */
637     afs_int32 C_afs_warnuser;   /* afs_resource.c */
638     afs_int32 C_afs_pagein;     /* afs_hp_subr.c */
639     afs_int32 C_afs_pageout;    /* afs_hp_subr.c */
640     afs_int32 C_afs_hp_strategy;        /* afs_hp_subr.c */
641     afs_int32 C_PGetCPrefs;     /* afs_pioctl.c */
642     afs_int32 C_PSetCPrefs;     /* afs_pioctl.c */
643     afs_int32 C_SRXAFSCB_WhoAreYou;     /* afs_callback.c */
644     afs_int32 C_afs_DiscardDCache;      /* afs_dcache.c */
645     afs_int32 C_afs_FreeDiscardedDCache;        /* afs_dcache.c */
646     afs_int32 C_afs_MaybeFreeDiscardedDCache;   /* afs_dcache.c */
647     afs_int32 C_PFlushMount;    /* afs_pioctl.c */
648     afs_int32 C_SRXAFSCB_GetServerPrefs;        /* afs_callback.c */
649     afs_int32 C_SRXAFSCB_GetCellServDB; /* afs_callback.c */
650     afs_int32 C_SRXAFSCB_GetLocalCell;  /* afs_callback.c */
651     afs_int32 C_afs_MarshallCacheConfig;        /* afs_callback.c */
652     afs_int32 C_SRXAFSCB_GetCacheConfig;        /* afs_callback.c */
653     afs_int32 C_SRXAFSCB_GetCE64;       /* afs_callback.c */
654     afs_int32 C_SRXAFSCB_GetCellByNum;  /* afs_callback.c */
655     afs_int32 C_BPrefetchNoCache;       /* afs_daemons.c */
656     afs_int32 C_afs_ReadNoCache;        /* osi_vnodeops.c */
657 };
658
659 struct afs_CMMeanStats {
660     struct afs_MeanStats something;     /* fill this in */
661 };
662
663 struct afs_CMStats {
664     struct afs_CMCallStats callInfo;
665     struct afs_CMMeanStats meanInfo;
666 };
667
668 /*
669  * This is the structure accessible by specifying the
670  * AFSCB_XSTATSCOLL_CALL_INFO collection to the xstat package.
671  */
672 extern struct afs_CMStats afs_cmstats;
673
674 /*
675  * Constants to track downtime durations:
676  *      Bucket 0:           dur <= 10 min
677  *      Bucket 1: 10 min  < dur <= 30 min
678  *      Bucket 2: 30 min  < dur <= 1 hour
679  *      Bucket 3: 1 hour  < dur <= 2 hours
680  *      Bucket 4: 2 hours < dur <= 4 hours
681  *      Bucket 5: 4 hours < dur <= 8 hours
682  *      Bucket 6:           dur >= 8 hours
683  */
684 #define AFS_STATS_NUM_DOWNTIME_DURATION_BUCKETS       7
685
686 #define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET0     600 /*10 minutes */
687 #define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET1    1800 /*30 minutes */
688 #define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET2    3600 /*60 minutes */
689 #define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET3    7200 /*2 hours */
690 #define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET4   14400 /*4 hours */
691 #define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET5   28800 /*8 hours */
692
693 /*
694  * Constants to track downtime incidents:
695  *      Bucket 0:            down  =  0 times
696  *      Bucket 1:            down  =  1 time
697  *      Bucket 2:  1 time  < down <=  5 times
698  *      Bucket 3:  5 times < down <= 10 times
699  *      Bucket 4: 10 times < down <= 50 times
700  *      Bucket 5:            down >  50 times
701  */
702 #define AFS_STATS_NUM_DOWNTIME_INCIDENTS_BUCKETS 6
703
704 #define AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET0   0
705 #define AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET1   1
706 #define AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET2   5
707 #define AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET3   10
708 #define AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET4   50
709
710 /*
711  * Numbers used to track aggregate up/downtime stats for servers.  We'll
712  * keep these numbers separately for FS and VL server records, and then
713  * again separately for servers in the same cell as this client machine
714  * and those outside the client's cell.
715  */
716 struct afs_stats_SrvUpDownInfo {
717     afs_int32 numTtlRecords;    /*# records, active or inactive */
718     afs_int32 numUpRecords;     /*# (active) records currently marked up */
719     afs_int32 numDownRecords;   /*# (active) records currently marked down */
720     afs_int32 sumOfRecordAges;  /*Sum of server record lifetimes */
721     afs_int32 ageOfYoungestRecord;      /*Age of youngest server record */
722     afs_int32 ageOfOldestRecord;        /*Age of oldest server record */
723     afs_int32 numDowntimeIncidents;     /*Number of (completed) downtime incidents */
724     afs_int32 numRecordsNeverDown;      /*Number of server records never marked down */
725     afs_int32 maxDowntimesInARecord;    /*Max downtimes seen by any record */
726     afs_int32 sumOfDowntimes;   /*Sum of all (completed) downtimes, in seconds */
727     afs_int32 shortestDowntime; /*Shortest downtime, in seconds */
728     afs_int32 longestDowntime;  /*Longest downtime, in seconds */
729     /*
730      * Arrays keeping distributions on downtime durations and number of
731      * downtime incidents.
732      */
733     afs_int32 downDurations[AFS_STATS_NUM_DOWNTIME_DURATION_BUCKETS];
734     afs_int32 downIncidents[AFS_STATS_NUM_DOWNTIME_INCIDENTS_BUCKETS];
735 };
736
737 /*
738  * Define indices for the server up/downtime arrays below.
739  */
740 #define AFS_STATS_UPDOWN_IDX_SAME_CELL 0
741 #define AFS_STATS_UPDOWN_IDX_DIFF_CELL 1
742
743 /*
744  * Performance numbers for the Cache Manager.
745  */
746 struct afs_stats_CMPerf {
747     afs_int32 numPerfCalls;     /*# of performance calls rcvd */
748
749     afs_int32 epoch;            /*Cache Manager epoch time */
750     afs_int32 numCellsVisible;  /*# cells we know about */
751     afs_int32 numCellsContacted;        /*# cells corresponded with */
752     afs_int32 dlocalAccesses;   /*# data accesses to files within cell */
753     afs_int32 vlocalAccesses;   /*# stat accesses to files within cell */
754     afs_int32 dremoteAccesses;  /*# data accesses to files outside of cell */
755     afs_int32 vremoteAccesses;  /*# stat accesses to files outside of cell */
756     afs_int32 cacheNumEntries;  /*# cache entries */
757     afs_int32 cacheBlocksTotal; /*# (1K) blocks configured for cache */
758     afs_int32 cacheBlocksInUse; /*# cache blocks actively in use */
759     afs_int32 cacheBlocksOrig;  /*# cache blocks at bootup */
760     afs_int32 cacheMaxDirtyChunks;      /*Max # dirty cache chunks tolerated */
761     afs_int32 cacheCurrDirtyChunks;     /*Current # dirty cache chunks */
762     afs_int32 dcacheHits;       /*# data files found in local cache */
763     afs_int32 vcacheHits;       /*# stat entries found in local cache */
764     afs_int32 dcacheMisses;     /*# data files NOT found in local cache */
765     afs_int32 vcacheMisses;     /*# stat entries NOT found in local cache */
766     afs_int32 cacheFlushes;     /*# files flushed from cache */
767     afs_int32 cacheFilesReused; /*# cache files reused */
768     afs_int32 ProtServerAddr;   /*Addr of Protection Server used */
769     afs_int32 vcacheXAllocs;    /* Additionally allocated vcaches */
770     afs_int32 dcacheXAllocs;    /* Additionally allocated dcaches */
771
772     /*
773      * Some stats related to our buffer package
774      */
775     afs_int32 bufAlloced;       /* # of buffers allocated by afs */
776     afs_int32 bufHits;          /* # of pages found on buffer cache */
777     afs_int32 bufMisses;        /* # of pages NOT found on buffer cache */
778     afs_int32 bufFlushDirty;    /* # of cached dirty bufs flushed because all busy */
779
780     /*
781      * Stats that keep track of all allocated/used objects in CM
782      */
783     afs_int32 LargeBlocksActive;        /* # of currently used large free pool entries */
784     afs_int32 LargeBlocksAlloced;       /* # of allocated large free pool entries */
785     afs_int32 SmallBlocksActive;        /* # of currently used small free pool entries */
786     afs_int32 SmallBlocksAlloced;       /* # of allocated used small free pool entries */
787     afs_int32 MediumBlocksActive;       /* # of currently used medium free pool entries */
788     afs_int32 MediumBlocksAlloced;      /* # of allocated used medium free pool entries */
789     afs_int32 OutStandingMemUsage;      /* # of alloced memory */
790     afs_int32 OutStandingAllocs;        /* Outstanding osi_allocs (no osi_frees yet) */
791     afs_int32 CallBackAlloced;  /* # callback structures allocated */
792     afs_int32 CallBackFlushes;  /* # callback flush operations performed */
793
794     /*
795      * Accounting stats having to do with the server table & records.
796      */
797     afs_int32 srvRecords;       /*# of servers currently on record */
798     afs_int32 srvRecordsHWM;    /* Server record high water mark */
799     afs_int32 srvNumBuckets;    /* Num server hash chain buckets */
800     afs_int32 srvMaxChainLength;        /* Max server hash chain length */
801     afs_int32 srvMaxChainLengthHWM;     /* Server hash chain high water mark */
802
803     /*
804      * Stats having to do with the systype upon which the Cache Manager
805      * is running.
806      */
807     afs_int32 sysName_ID;       /*Sysname ID for host hardware */
808
809     /*
810      * Stats recording downtime characteristics for each File Server and Volume
811      * Location Server we've dealt with, both within the same cell and in
812      * other cells.
813      */
814     struct afs_stats_SrvUpDownInfo fs_UpDown[2];
815     struct afs_stats_SrvUpDownInfo vl_UpDown[2];
816
817     afs_uint32 cbloops;
818     afs_uint32 osiread_efaults;
819     afs_int32 cacheBlocksDiscarded;     /*# cache blocks free but not truncated */
820     afs_int32 cacheBucket0_Discarded;
821     afs_int32 cacheBucket1_Discarded;
822     afs_int32 cacheBucket2_Discarded;
823
824     /*
825      * Spares for future expansion.
826      */
827     afs_int32 spare[10];        /*Spares */
828 };
829
830
831 /*
832  * Values denoting the File Server and Cache Manager opcodes.
833  */
834 #define AFS_STATS_FS_RPCIDX_FETCHDATA            0
835 #define AFS_STATS_FS_RPCIDX_FETCHACL             1
836 #define AFS_STATS_FS_RPCIDX_FETCHSTATUS          2
837 #define AFS_STATS_FS_RPCIDX_STOREDATA            3
838 #define AFS_STATS_FS_RPCIDX_STOREACL             4
839 #define AFS_STATS_FS_RPCIDX_STORESTATUS          5
840 #define AFS_STATS_FS_RPCIDX_REMOVEFILE           6
841 #define AFS_STATS_FS_RPCIDX_CREATEFILE           7
842 #define AFS_STATS_FS_RPCIDX_RENAME               8
843 #define AFS_STATS_FS_RPCIDX_SYMLINK              9
844 #define AFS_STATS_FS_RPCIDX_LINK                10
845 #define AFS_STATS_FS_RPCIDX_MAKEDIR             11
846 #define AFS_STATS_FS_RPCIDX_REMOVEDIR           12
847 #define AFS_STATS_FS_RPCIDX_SETLOCK             13
848 #define AFS_STATS_FS_RPCIDX_EXTENDLOCK          14
849 #define AFS_STATS_FS_RPCIDX_RELEASELOCK         15
850 #define AFS_STATS_FS_RPCIDX_GETSTATISTICS       16
851 #define AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS     17
852 #define AFS_STATS_FS_RPCIDX_GETVOLUMEINFO       18
853 #define AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS     19
854 #define AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS     20
855 #define AFS_STATS_FS_RPCIDX_GETROOTVOLUME       21
856 #define AFS_STATS_FS_RPCIDX_CHECKTOKEN          22
857 #define AFS_STATS_FS_RPCIDX_GETTIME             23
858 #define AFS_STATS_FS_RPCIDX_NGETVOLUMEINFO      24
859 #define AFS_STATS_FS_RPCIDX_BULKSTATUS          25
860 #define AFS_STATS_FS_RPCIDX_XSTATSVERSION       26
861 #define AFS_STATS_FS_RPCIDX_GETXSTATS           27
862 #define AFS_STATS_FS_RPCIDX_XLOOKUP             28
863 #define AFS_STATS_FS_RPCIDX_RESIDENCYRPCS       29
864
865 #define AFS_STATS_NUM_FS_RPC_OPS                29
866
867 #define AFS_STATS_FS_XFERIDX_FETCHDATA           0
868 #define AFS_STATS_FS_XFERIDX_STOREDATA           1
869
870 #define AFS_STATS_NUM_FS_XFER_OPS                2
871
872 #define AFS_STATS_CM_RPCIDX_CALLBACK             0
873 #define AFS_STATS_CM_RPCIDX_INITCALLBACKSTATE    1
874 #define AFS_STATS_CM_RPCIDX_PROBE                2
875 #define AFS_STATS_CM_RPCIDX_GETLOCK              3
876 #define AFS_STATS_CM_RPCIDX_GETCE                4
877 #define AFS_STATS_CM_RPCIDX_XSTATSVERSION        5
878 #define AFS_STATS_CM_RPCIDX_GETXSTATS            6
879
880 #define AFS_STATS_NUM_CM_RPC_OPS                 7
881
882
883 /*
884  * Record to track timing numbers for each Cache Manager RPC operation.
885  */
886 struct afs_stats_opTimingData {
887     afs_int32 numOps;           /*Number of operations executed */
888     afs_int32 numSuccesses;     /*Number of successful ops */
889     osi_timeval_t sumTime;      /*Sum of sample timings */
890     osi_timeval_t sqrTime;      /*Sum of squares of sample timings */
891     osi_timeval_t minTime;      /*Minimum timing value observed */
892     osi_timeval_t maxTime;      /*Minimum timing value observed */
893 };
894
895 /*
896  * We discriminate byte size transfers into this many buckets.
897  */
898 #define AFS_STATS_NUM_XFER_BUCKETS       9
899
900 #define AFS_STATS_MAXBYTES_BUCKET0     128
901 #define AFS_STATS_MAXBYTES_BUCKET1    1024
902 #define AFS_STATS_MAXBYTES_BUCKET2    8192
903 #define AFS_STATS_MAXBYTES_BUCKET3   16384
904 #define AFS_STATS_MAXBYTES_BUCKET4   32768
905 #define AFS_STATS_MAXBYTES_BUCKET5  131072
906 #define AFS_STATS_MAXBYTES_BUCKET6  524288
907 #define AFS_STATS_MAXBYTES_BUCKET7 1048576
908
909 /*
910  * Record to track timings and byte sizes for data transfers.
911  */
912 struct afs_stats_xferData {
913     afs_int32 numXfers;         /*Number of successful xfers */
914     afs_int32 numSuccesses;     /*Number of successful xfers */
915     osi_timeval_t sumTime;      /*Sum of timing values */
916     osi_timeval_t sqrTime;      /*Sum of squares of timing values */
917     osi_timeval_t minTime;      /*Minimum xfer time recorded */
918     osi_timeval_t maxTime;      /*Maximum xfer time recorded */
919     afs_int32 sumBytes;         /*Sum of KBytes transferred */
920     afs_int32 minBytes;         /*Minimum value observed */
921     afs_int32 maxBytes;         /*Maximum value observed */
922     afs_int32 count[AFS_STATS_NUM_XFER_BUCKETS];        /*Tally for each range of bytes */
923 };
924
925 /*
926  * Macros to operate on time values.
927  *
928  * afs_stats_TimeLessThan(t1, t2)     Non-zero if t1 is less than t2
929  * afs_stats_TimeGreaterThan(t1, t2)  Non-zero if t1 is greater than t2
930  * afs_stats_GetDiff(t3, t1, t2)      Set t3 to the difference between
931  *                                      t1 and t2 (t1 is less than or
932  *                                      equal to t2).
933  * afs_stats_AddTo(t1, t2)            Add t2 to t1
934  * afs_stats_TimeAssign(t1, t2)      Assign time t2 to t1
935  * afs_stats_SquareAddTo(t1,t2)      Add square of t2 to t1
936  */
937 #define afs_stats_TimeLessThan(t1, t2)        \
938             ((t1.tv_sec  < t2.tv_sec)  ? 1 : \
939              (t1.tv_sec  > t2.tv_sec)  ? 0 : \
940              (t1.tv_usec < t2.tv_usec) ? 1 : \
941              0)
942
943 #define afs_stats_TimeGreaterThan(t1, t2)     \
944             ((t1.tv_sec  > t2.tv_sec)  ? 1 : \
945              (t1.tv_sec  < t2.tv_sec)  ? 0 : \
946              (t1.tv_usec > t2.tv_usec) ? 1 : \
947              0)
948
949 #define afs_stats_GetDiff(t3, t1, t2)                           \
950 {                                                               \
951     /*                                                          \
952      * If the microseconds of the later time are smaller than   \
953      * the earlier time, set up for proper subtraction (doing   \
954      * the carry).                                              \
955      */                                                         \
956     if (t2.tv_usec < t1.tv_usec) {                              \
957         t2.tv_usec += 1000000;                                  \
958         t2.tv_sec -= 1;                                         \
959     }                                                           \
960     t3.tv_sec  = t2.tv_sec  - t1.tv_sec;                        \
961     t3.tv_usec = t2.tv_usec - t1.tv_usec;                       \
962 }
963
964 #define afs_stats_AddTo(t1, t2)    \
965 {                                 \
966     t1.tv_sec  += t2.tv_sec;      \
967     t1.tv_usec += t2.tv_usec;     \
968     if (t1.tv_usec > 1000000) {   \
969         t1.tv_usec -= 1000000;    \
970         t1.tv_sec++;              \
971     }                             \
972 }
973
974 #define afs_stats_TimeAssign(t1, t2)    \
975 {                                       \
976     t1.tv_sec = t2.tv_sec;              \
977     t1.tv_usec = t2.tv_usec;            \
978 }
979 /*
980  * We calculate the square of a timeval as follows:
981  *
982  * The timeval struct contains two ints - the number of seconds and the
983  * number of microseconds.  These two numbers together gives the correct
984  * amount of time => t = t.tv_sec + (t.tv_usec / 1000000);
985  *
986  * if x = t.tv_sec and y = (t.tv_usec / 1000000) then the square is simply:
987  *
988  * x^2 + 2xy + y^2
989  *
990  * Since we are trying to avoid floating point math, we use the following
991  * observations to simplify the above equation:
992  *
993  * The resulting t.tv_sec (x') only depends upon the x^2 + 2xy portion
994  * of the equation.  This is easy to see if you think about y^2 in
995  * decimal notation.  y^2 is always < 0 since y < 0.  Therefore in calculating
996  * x', we can ignore y^2 (we do need to take care of rounding which is
997  * done below).
998  *
999  * Similarly, in calculating t.tv_usec (y') we can ignore x^2 and concentrate
1000  * on 2xy + y^2.
1001  *
1002  * You'll notice that both x' and y' depend upon 2xy.  We can further
1003  * simplify things by realizing that x' depends on upon the integer
1004  * portion of the 2xy term.  We can get part of this integer by
1005  * multiplying 2 * x * t.tv_usec and then truncating the result by
1006  * / 1000000.  Similarly, we can get the decimal portion of this term
1007  * by performing the same multiplication and then % 1000000.  It is
1008  * possible that the decimal portion will in fact contain some of the
1009  * integer portion (this will be taken care of when we ensure that y'
1010  * is less than 1000000).
1011  *
1012  * The only other non-obvious calculation involves y^2.  The key to
1013  * understanding this part of the calculation is to expand y again
1014  * in a nonobvious manner.  We do this via the following expansion:
1015  *
1016  * y = t.tv_usec / 1000000;
1017  * let abcdef represent the six digits of t.tv_usec then we have:
1018  * t.tv_usec / 1000000 = abc/1000 + def/1000000;
1019  *
1020  * squaring yields:
1021  *
1022  * y^2 = (abc/1000)^2 + 2 * (abc/1000) * (def/1000000) + (def/1000000)^2
1023  *
1024  * Examining this equation yields the following observations:
1025  *
1026  * The second term can be calculated by multiplying abc and def then
1027  * shifting the decimal correctly.
1028  *
1029  * (def/1000000)^2 contributes only to rounding and we only round up
1030  * if def > 707.
1031  *
1032  * These two observations are the basis for the somewhat cryptic
1033  * calculation of usec^2 (i.e. they are the "tricks").
1034  */
1035
1036 #define afs_stats_SquareAddTo(t1, t2)                     \
1037 {                                                         \
1038     /*                                                    \
1039      *  We use some tricks here to avoid floating point arithmetic  \
1040      */                                                             \
1041    if(t2.tv_sec > 0 )                                               \
1042      {                                                                        \
1043        t1.tv_sec += t2.tv_sec * t2.tv_sec                                     \
1044                     +  2 * t2.tv_sec * t2.tv_usec /1000000;                   \
1045        t1.tv_usec += (2 * t2.tv_sec * t2.tv_usec) % 1000000                   \
1046                      + (t2.tv_usec / 1000)*(t2.tv_usec / 1000)                \
1047                      + 2 * (t2.tv_usec / 1000) * (t2.tv_usec % 1000) / 1000   \
1048                      + (((t2.tv_usec % 1000) > 707) ? 1 : 0);                 \
1049      }                                                                        \
1050    else                                                                       \
1051      {                                                                        \
1052        t1.tv_usec += (t2.tv_usec / 1000)*(t2.tv_usec / 1000)                  \
1053                      + 2 * (t2.tv_usec / 1000) * (t2.tv_usec % 1000) / 1000   \
1054                      + (((t2.tv_usec % 1000) > 707) ? 1 : 0);                 \
1055      }                                                                        \
1056    if (t1.tv_usec > 1000000) {                                                \
1057         t1.tv_usec -= 1000000;                                                \
1058         t1.tv_sec++;                                                          \
1059    }                                                                          \
1060 }
1061
1062
1063
1064
1065 /*
1066  * Structure recording RPC outcomes.
1067  */
1068 struct afs_stats_RPCErrors {
1069     afs_int32 err_Server;       /*Server down error */
1070     afs_int32 err_Network;      /*Network error */
1071     afs_int32 err_Protection;   /*Protection violation */
1072     afs_int32 err_Volume;       /*Volume-related error */
1073     afs_int32 err_VolumeBusies; /*"Volume busy conditions encountered */
1074     afs_int32 err_Other;        /*Misc other errors */
1075 };
1076
1077
1078 /*
1079  * Structure holding RPC interface opcode measurements for the Cache Manager.
1080  */
1081 struct afs_stats_RPCOpInfo {
1082     struct afs_stats_opTimingData
1083       fsRPCTimes[AFS_STATS_NUM_FS_RPC_OPS];     /*Individual FS RPC op timings */
1084     struct afs_stats_RPCErrors
1085       fsRPCErrors[AFS_STATS_NUM_FS_RPC_OPS];    /*Individual FS RPC op errors */
1086     struct afs_stats_xferData
1087       fsXferTimes[AFS_STATS_NUM_FS_XFER_OPS];   /*Individual FS RPC xfer timings */
1088     struct afs_stats_opTimingData
1089       cmRPCTimes[AFS_STATS_NUM_CM_RPC_OPS];     /*Individual CM RPC op timings */
1090 };
1091
1092 /*
1093  * Structure holding authentication info for the CM.
1094  */
1095 struct afs_stats_AuthentInfo {
1096     /*
1097      * This first set of fields don't have any history - they are simply
1098      * snapshots of the system at the time of the probe.
1099      */
1100     afs_int32 curr_PAGs;        /*Current number of PAGs */
1101     afs_int32 curr_Records;     /*Current # of records in table */
1102     afs_int32 curr_AuthRecords; /*Current # of authenticated
1103                                  * records (w/valid ticket) */
1104     afs_int32 curr_UnauthRecords;       /*Current # of unauthenticated
1105                                          * records (w/o any ticket at all) */
1106     afs_int32 curr_MaxRecordsInPAG;     /*Max records for a single PAG */
1107     afs_int32 curr_LongestChain;        /*Length of longest current hash chain */
1108
1109     /*
1110      * This second set of fields are values accumulated over the lifetme
1111      * of the current CM incarnation.
1112      */
1113     afs_int32 PAGCreations;     /*# PAG creations */
1114     afs_int32 TicketUpdates;    /*# ticket additions/refreshes */
1115     afs_int32 HWM_PAGs;         /*High water mark - # PAGs */
1116     afs_int32 HWM_Records;      /* " - # records */
1117     afs_int32 HWM_MaxRecordsInPAG;      /* " - max records for a single PAG */
1118     afs_int32 HWM_LongestChain; /* " - longest hash chain */
1119 };
1120
1121 /*
1122  * [Un]replicated file access.  These count the number of RXAFS_FetchData
1123  * calls get accomplished, and their need to call upon other replicas in
1124  * case of failure.
1125  */
1126 struct afs_stats_AccessInfo {
1127     afs_int32 unreplicatedRefs; /*# references to unreplicated data */
1128     afs_int32 replicatedRefs;   /*# references to replicated data */
1129     afs_int32 numReplicasAccessed;      /*# replicas accessed */
1130     afs_int32 maxReplicasPerRef;        /*Max # replicas accessed per ref */
1131     afs_int32 refFirstReplicaOK;        /*# references satisfied by 1st replica */
1132 };
1133
1134 /*
1135  * Structure holding authoring info for the CM.  We keep track of
1136  * the results of writes on files and directories independently.
1137  * Results cover all objects in the cache uniformly.
1138  */
1139 struct afs_stats_AuthorInfo {
1140     afs_int32 fileSameAuthor;   /*File write by same author */
1141     afs_int32 fileDiffAuthor;   /*File write by diff author */
1142     afs_int32 dirSameAuthor;    /*Directory write by same author */
1143     afs_int32 dirDiffAuthor;    /*Directory write by diff author */
1144 };
1145
1146 /*
1147  * Structure holding ``full'' CM peformance measurements.
1148  */
1149 struct afs_stats_CMFullPerf {
1150     afs_int32 numFullPerfCalls; /*Number of accesses */
1151     struct afs_stats_CMPerf perf;       /*General performance stats */
1152     struct afs_stats_RPCOpInfo rpc;     /*RPC op stats */
1153     struct afs_stats_AuthentInfo authent;       /*Authentication stats */
1154     struct afs_stats_AccessInfo accessinf;      /*Access stats */
1155     struct afs_stats_AuthorInfo author; /*Authorship stats */
1156 };
1157
1158 /*
1159  * These are the storage declarations for the structures accessible
1160  * via the xstat package.
1161  */
1162 /* extern struct afs_stats_CMPerf afs_stats_cmperf; */
1163 /* extern struct afs_stats_CMFullPerf afs_stats_cmfullperf; */
1164 /* extern afs_int32 afs_stats_XferSumBytes[]; */
1165
1166 #ifndef AFS_NOSTATS
1167 /*
1168  * We define routines to keep running counts and means.  For the
1169  * running count, we have to concatenate the ``C_'' prefix on to
1170  * the routine name passed in as an argument to get the right
1171  * field name.
1172  */
1173 #define AFS_STATCNT(arg)  ((afs_cmstats.callInfo.C_ ## arg)++)
1174
1175 #define AFS_MEANCNT(arg, value) \
1176     (afs_AddToMean(((afs_cmstats.meanInfo).(arg)),value))
1177
1178 #endif /* AFS_NOSTATS */
1179
1180
1181 #endif /* __OPENAFS_AFS_STATS_H__ */