added structure members referred to by recent changes in vfs-wrap.c
[Samba/gebeck_regimport.git] / source3 / include / smbprofile.h
blob719318195e00cc1336b7a017e92f2862a6988998
1 #ifndef _PROFILE_H_
2 #define _PROFILE_H_
3 /*
4 Unix SMB/Netbios implementation.
5 Version 1.9.
6 store smbd profiling information in shared memory
7 Copyright (C) Andrew Tridgell 1999
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Reasons for cache flush.
29 #define NUM_FLUSH_REASONS 8 /* Keep this in sync with the enum below. */
30 enum flush_reason_enum { SEEK_FLUSH, READ_FLUSH, WRITE_FLUSH, READRAW_FLUSH,
31 OPLOCK_RELEASE_FLUSH, CLOSE_FLUSH, SYNC_FLUSH, SIZECHANGE_FLUSH };
33 /* this file defines the profile structure in the profile shared
34 memory area */
36 #define PROF_SHMEM_KEY ((key_t)0x07021999)
37 #define PROF_SHM_MAGIC 0x6349985
38 #define PROF_SHM_VERSION 6
40 /* time values in the following structure are in microseconds */
42 struct profile_stats {
43 /* general counters */
44 unsigned smb_count; /* how many SMB packets we have processed */
45 unsigned uid_changes; /* how many times we change our effective uid */
46 /* system call counters */
47 unsigned syscall_opendir_count;
48 unsigned syscall_opendir_time;
49 unsigned syscall_readdir_count;
50 unsigned syscall_readdir_time;
51 unsigned syscall_mkdir_count;
52 unsigned syscall_mkdir_time;
53 unsigned syscall_rmdir_count;
54 unsigned syscall_rmdir_time;
55 unsigned syscall_closedir_count;
56 unsigned syscall_closedir_time;
57 unsigned syscall_open_count;
58 unsigned syscall_open_time;
59 unsigned syscall_close_count;
60 unsigned syscall_close_time;
61 unsigned syscall_read_count;
62 unsigned syscall_read_time;
63 unsigned syscall_read_bytes; /* bytes read with read syscall */
64 unsigned syscall_write_count;
65 unsigned syscall_write_time;
66 unsigned syscall_write_bytes; /* bytes written with write syscall */
67 unsigned syscall_lseek_count;
68 unsigned syscall_lseek_time;
69 unsigned syscall_rename_count;
70 unsigned syscall_rename_time;
71 unsigned syscall_fsync_count;
72 unsigned syscall_fsync_time;
73 unsigned syscall_stat_count;
74 unsigned syscall_stat_time;
75 unsigned syscall_fstat_count;
76 unsigned syscall_fstat_time;
77 unsigned syscall_lstat_count;
78 unsigned syscall_lstat_time;
79 unsigned syscall_unlink_count;
80 unsigned syscall_unlink_time;
81 unsigned syscall_chmod_count;
82 unsigned syscall_chmod_time;
83 unsigned syscall_fchmod_count;
84 unsigned syscall_fchmod_time;
85 unsigned syscall_chown_count;
86 unsigned syscall_chown_time;
87 unsigned syscall_fchown_count;
88 unsigned syscall_fchown_time;
89 unsigned syscall_chdir_count;
90 unsigned syscall_chdir_time;
91 unsigned syscall_getwd_count;
92 unsigned syscall_getwd_time;
93 unsigned syscall_utime_count;
94 unsigned syscall_utime_time;
95 unsigned syscall_ftruncate_count;
96 unsigned syscall_ftruncate_time;
97 unsigned syscall_fcntl_lock_count;
98 unsigned syscall_fcntl_lock_time;
99 unsigned syscall_readlink_count;
100 unsigned syscall_readlink_time;
101 unsigned syscall_symlink_count;
102 unsigned syscall_symlink_time;
103 unsigned syscall_link_count;
104 unsigned syscall_link_time;
105 unsigned syscall_mknod_count;
106 unsigned syscall_mknod_time;
107 /* stat cache counters */
108 unsigned statcache_lookups;
109 unsigned statcache_misses;
110 unsigned statcache_hits;
111 /* write cache counters */
112 unsigned writecache_read_hits;
113 unsigned writecache_abutted_writes;
114 unsigned writecache_total_writes;
115 unsigned writecache_non_oplock_writes;
116 unsigned writecache_direct_writes;
117 unsigned writecache_init_writes;
118 unsigned writecache_flushed_writes[NUM_FLUSH_REASONS];
119 unsigned writecache_num_perfect_writes;
120 unsigned writecache_num_write_caches;
121 unsigned writecache_allocated_write_caches;
122 /* counters for individual SMB types */
123 unsigned SMBmkdir_count; /* create directory */
124 unsigned SMBmkdir_time;
125 unsigned SMBrmdir_count; /* delete directory */
126 unsigned SMBrmdir_time;
127 unsigned SMBopen_count; /* open file */
128 unsigned SMBopen_time;
129 unsigned SMBcreate_count; /* create file */
130 unsigned SMBcreate_time;
131 unsigned SMBclose_count; /* close file */
132 unsigned SMBclose_time;
133 unsigned SMBflush_count; /* flush file */
134 unsigned SMBflush_time;
135 unsigned SMBunlink_count; /* delete file */
136 unsigned SMBunlink_time;
137 unsigned SMBmv_count; /* rename file */
138 unsigned SMBmv_time;
139 unsigned SMBgetatr_count; /* get file attributes */
140 unsigned SMBgetatr_time;
141 unsigned SMBsetatr_count; /* set file attributes */
142 unsigned SMBsetatr_time;
143 unsigned SMBread_count; /* read from file */
144 unsigned SMBread_time;
145 unsigned SMBwrite_count; /* write to file */
146 unsigned SMBwrite_time;
147 unsigned SMBlock_count; /* lock byte range */
148 unsigned SMBlock_time;
149 unsigned SMBunlock_count; /* unlock byte range */
150 unsigned SMBunlock_time;
151 unsigned SMBctemp_count; /* create temporary file */
152 unsigned SMBctemp_time;
153 /* SMBmknew stats are currently combined with SMBcreate */
154 unsigned SMBmknew_count; /* make new file */
155 unsigned SMBmknew_time;
156 unsigned SMBchkpth_count; /* check directory path */
157 unsigned SMBchkpth_time;
158 unsigned SMBexit_count; /* process exit */
159 unsigned SMBexit_time;
160 unsigned SMBlseek_count; /* seek */
161 unsigned SMBlseek_time;
162 unsigned SMBlockread_count; /* Lock a range and read */
163 unsigned SMBlockread_time;
164 unsigned SMBwriteunlock_count; /* Unlock a range then write */
165 unsigned SMBwriteunlock_time;
166 unsigned SMBreadbraw_count; /* read a block of data with no smb header */
167 unsigned SMBreadbraw_time;
168 unsigned SMBreadBmpx_count; /* read block multiplexed */
169 unsigned SMBreadBmpx_time;
170 unsigned SMBreadBs_count; /* read block (secondary response) */
171 unsigned SMBreadBs_time;
172 unsigned SMBwritebraw_count; /* write a block of data with no smb header */
173 unsigned SMBwritebraw_time;
174 unsigned SMBwriteBmpx_count; /* write block multiplexed */
175 unsigned SMBwriteBmpx_time;
176 unsigned SMBwriteBs_count; /* write block (secondary request) */
177 unsigned SMBwriteBs_time;
178 unsigned SMBwritec_count; /* secondary write request */
179 unsigned SMBwritec_time;
180 unsigned SMBsetattrE_count; /* set file attributes expanded */
181 unsigned SMBsetattrE_time;
182 unsigned SMBgetattrE_count; /* get file attributes expanded */
183 unsigned SMBgetattrE_time;
184 unsigned SMBlockingX_count; /* lock/unlock byte ranges and X */
185 unsigned SMBlockingX_time;
186 unsigned SMBtrans_count; /* transaction - name, bytes in/out */
187 unsigned SMBtrans_time;
188 unsigned SMBtranss_count; /* transaction (secondary request/response) */
189 unsigned SMBtranss_time;
190 unsigned SMBioctl_count; /* IOCTL */
191 unsigned SMBioctl_time;
192 unsigned SMBioctls_count; /* IOCTL (secondary request/response) */
193 unsigned SMBioctls_time;
194 unsigned SMBcopy_count; /* copy */
195 unsigned SMBcopy_time;
196 unsigned SMBmove_count; /* move */
197 unsigned SMBmove_time;
198 unsigned SMBecho_count; /* echo */
199 unsigned SMBecho_time;
200 unsigned SMBwriteclose_count; /* write a file then close it */
201 unsigned SMBwriteclose_time;
202 unsigned SMBopenX_count; /* open and X */
203 unsigned SMBopenX_time;
204 unsigned SMBreadX_count; /* read and X */
205 unsigned SMBreadX_time;
206 unsigned SMBwriteX_count; /* write and X */
207 unsigned SMBwriteX_time;
208 unsigned SMBtrans2_count; /* TRANS2 protocol set */
209 unsigned SMBtrans2_time;
210 unsigned SMBtranss2_count; /* TRANS2 protocol set, secondary command */
211 unsigned SMBtranss2_time;
212 unsigned SMBfindclose_count; /* Terminate a TRANSACT2_FINDFIRST */
213 unsigned SMBfindclose_time;
214 unsigned SMBfindnclose_count; /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
215 unsigned SMBfindnclose_time;
216 unsigned SMBtcon_count; /* tree connect */
217 unsigned SMBtcon_time;
218 unsigned SMBtdis_count; /* tree disconnect */
219 unsigned SMBtdis_time;
220 unsigned SMBnegprot_count; /* negotiate protocol */
221 unsigned SMBnegprot_time;
222 unsigned SMBsesssetupX_count; /* Session Set Up & X (including User Logon) */
223 unsigned SMBsesssetupX_time;
224 unsigned SMBulogoffX_count; /* user logoff */
225 unsigned SMBulogoffX_time;
226 unsigned SMBtconX_count; /* tree connect and X*/
227 unsigned SMBtconX_time;
228 unsigned SMBdskattr_count; /* get disk attributes */
229 unsigned SMBdskattr_time;
230 unsigned SMBsearch_count; /* search directory */
231 unsigned SMBsearch_time;
232 /* SBMffirst stats combined with SMBsearch */
233 unsigned SMBffirst_count; /* find first */
234 unsigned SMBffirst_time;
235 /* SBMfunique stats combined with SMBsearch */
236 unsigned SMBfunique_count; /* find unique */
237 unsigned SMBfunique_time;
238 unsigned SMBfclose_count; /* find close */
239 unsigned SMBfclose_time;
240 unsigned SMBnttrans_count; /* NT transact */
241 unsigned SMBnttrans_time;
242 unsigned SMBnttranss_count; /* NT transact secondary */
243 unsigned SMBnttranss_time;
244 unsigned SMBntcreateX_count; /* NT create and X */
245 unsigned SMBntcreateX_time;
246 unsigned SMBntcancel_count; /* NT cancel */
247 unsigned SMBntcancel_time;
248 unsigned SMBsplopen_count; /* open print spool file */
249 unsigned SMBsplopen_time;
250 unsigned SMBsplwr_count; /* write to print spool file */
251 unsigned SMBsplwr_time;
252 unsigned SMBsplclose_count; /* close print spool file */
253 unsigned SMBsplclose_time;
254 unsigned SMBsplretq_count; /* return print queue */
255 unsigned SMBsplretq_time;
256 unsigned SMBsends_count; /* send single block message */
257 unsigned SMBsends_time;
258 unsigned SMBsendb_count; /* send broadcast message */
259 unsigned SMBsendb_time;
260 unsigned SMBfwdname_count; /* forward user name */
261 unsigned SMBfwdname_time;
262 unsigned SMBcancelf_count; /* cancel forward */
263 unsigned SMBcancelf_time;
264 unsigned SMBgetmac_count; /* get machine name */
265 unsigned SMBgetmac_time;
266 unsigned SMBsendstrt_count; /* send start of multi-block message */
267 unsigned SMBsendstrt_time;
268 unsigned SMBsendend_count; /* send end of multi-block message */
269 unsigned SMBsendend_time;
270 unsigned SMBsendtxt_count; /* send text of multi-block message */
271 unsigned SMBsendtxt_time;
272 unsigned SMBinvalid_count; /* invalid command */
273 unsigned SMBinvalid_time;
274 /* Pathworks setdir command */
275 unsigned pathworks_setdir_count;
276 unsigned pathworks_setdir_time;
277 /* These are the TRANS2 sub commands */
278 unsigned Trans2_open_count;
279 unsigned Trans2_open_time;
280 unsigned Trans2_findfirst_count;
281 unsigned Trans2_findfirst_time;
282 unsigned Trans2_findnext_count;
283 unsigned Trans2_findnext_time;
284 unsigned Trans2_qfsinfo_count;
285 unsigned Trans2_qfsinfo_time;
286 unsigned Trans2_setfsinfo_count;
287 unsigned Trans2_setfsinfo_time;
288 unsigned Trans2_qpathinfo_count;
289 unsigned Trans2_qpathinfo_time;
290 unsigned Trans2_setpathinfo_count;
291 unsigned Trans2_setpathinfo_time;
292 unsigned Trans2_qfileinfo_count;
293 unsigned Trans2_qfileinfo_time;
294 unsigned Trans2_setfileinfo_count;
295 unsigned Trans2_setfileinfo_time;
296 unsigned Trans2_fsctl_count;
297 unsigned Trans2_fsctl_time;
298 unsigned Trans2_ioctl_count;
299 unsigned Trans2_ioctl_time;
300 unsigned Trans2_findnotifyfirst_count;
301 unsigned Trans2_findnotifyfirst_time;
302 unsigned Trans2_findnotifynext_count;
303 unsigned Trans2_findnotifynext_time;
304 unsigned Trans2_mkdir_count;
305 unsigned Trans2_mkdir_time;
306 unsigned Trans2_session_setup_count;
307 unsigned Trans2_session_setup_time;
308 unsigned Trans2_get_dfs_referral_count;
309 unsigned Trans2_get_dfs_referral_time;
310 unsigned Trans2_report_dfs_inconsistancy_count;
311 unsigned Trans2_report_dfs_inconsistancy_time;
312 /* These are the NT transact sub commands. */
313 unsigned NT_transact_create_count;
314 unsigned NT_transact_create_time;
315 unsigned NT_transact_ioctl_count;
316 unsigned NT_transact_ioctl_time;
317 unsigned NT_transact_set_security_desc_count;
318 unsigned NT_transact_set_security_desc_time;
319 unsigned NT_transact_notify_change_count;
320 unsigned NT_transact_notify_change_time;
321 unsigned NT_transact_rename_count;
322 unsigned NT_transact_rename_time;
323 unsigned NT_transact_query_security_desc_count;
324 unsigned NT_transact_query_security_desc_time;
325 /* These are ACL manipulation calls */
326 unsigned get_nt_acl_count;
327 unsigned get_nt_acl_time;
328 unsigned fget_nt_acl_count;
329 unsigned fget_nt_acl_time;
330 unsigned set_nt_acl_count;
331 unsigned set_nt_acl_time;
332 unsigned fset_nt_acl_count;
333 unsigned fset_nt_acl_time;
334 unsigned chmod_acl_count;
335 unsigned chmod_acl_time;
336 unsigned fchmod_acl_count;
337 unsigned fchmod_acl_time;
338 /* These are nmbd stats */
339 unsigned name_release_count;
340 unsigned name_release_time;
341 unsigned name_refresh_count;
342 unsigned name_refresh_time;
343 unsigned name_registration_count;
344 unsigned name_registration_time;
345 unsigned node_status_count;
346 unsigned node_status_time;
347 unsigned name_query_count;
348 unsigned name_query_time;
349 unsigned host_announce_count;
350 unsigned host_announce_time;
351 unsigned workgroup_announce_count;
352 unsigned workgroup_announce_time;
353 unsigned local_master_announce_count;
354 unsigned local_master_announce_time;
355 unsigned master_browser_announce_count;
356 unsigned master_browser_announce_time;
357 unsigned lm_host_announce_count;
358 unsigned lm_host_announce_time;
359 unsigned get_backup_list_count;
360 unsigned get_backup_list_time;
361 unsigned reset_browser_count;
362 unsigned reset_browser_time;
363 unsigned announce_request_count;
364 unsigned announce_request_time;
365 unsigned lm_announce_request_count;
366 unsigned lm_announce_request_time;
367 unsigned domain_logon_count;
368 unsigned domain_logon_time;
369 unsigned sync_browse_lists_count;
370 unsigned sync_browse_lists_time;
371 unsigned run_elections_count;
372 unsigned run_elections_time;
373 unsigned election_count;
374 unsigned election_time;
377 struct profile_header {
378 int prof_shm_magic;
379 int prof_shm_version;
380 struct profile_stats stats;
383 extern struct profile_header *profile_h;
384 extern struct profile_stats *profile_p;
385 extern struct timeval profile_starttime;
386 extern struct timeval profile_endtime;
387 extern struct timeval profile_starttime_nested;
388 extern struct timeval profile_endtime_nested;
389 extern BOOL do_profile_flag;
390 extern BOOL do_profile_times;
392 /* these are helper macros - do not call them directly in the code
393 * use the DO_PROFILE_* START_PROFILE and END_PROFILE ones
394 * below which test for the profile flage first
396 #define INC_PROFILE_COUNT(x) profile_p->x++
397 #define DEC_PROFILE_COUNT(x) profile_p->x--
398 #define ADD_PROFILE_COUNT(x,y) profile_p->x += (y)
399 #define PROFILE_TIME \
400 ((profile_endtime.tv_sec - profile_starttime.tv_sec) *1000000 + \
401 ((int)profile_endtime.tv_usec - (int)profile_starttime.tv_usec))
402 #define PROFILE_TIME_NESTED \
403 ((profile_endtime_nested.tv_sec - profile_starttime_nested.tv_sec) *1000000 + \
404 ((int)profile_endtime_nested.tv_usec - (int)profile_starttime_nested.tv_usec))
406 #ifdef WITH_PROFILE
407 #define DO_PROFILE_INC(x) \
408 if (do_profile_flag) { \
409 INC_PROFILE_COUNT(x); \
411 #define DO_PROFILE_DEC(x) \
412 if (do_profile_flag) { \
413 DEC_PROFILE_COUNT(x); \
415 #define DO_PROFILE_DEC_INC(x,y) \
416 if (do_profile_flag) { \
417 DEC_PROFILE_COUNT(x); \
418 INC_PROFILE_COUNT(y); \
420 #define DO_PROFILE_ADD(x,n) \
421 if (do_profile_flag) { \
422 ADD_PROFILE_COUNT(x,n); \
424 #define START_PROFILE(x) \
425 if (do_profile_flag) { \
426 if (do_profile_times) \
427 GetTimeOfDay(&profile_starttime); \
428 INC_PROFILE_COUNT(x##_count); \
430 #define START_PROFILE_NESTED(x) \
431 if (do_profile_flag) { \
432 if (do_profile_times) \
433 GetTimeOfDay(&profile_starttime_nested); \
434 INC_PROFILE_COUNT(x##_count); \
436 #define START_PROFILE_BYTES(x,n) \
437 if (do_profile_flag) { \
438 if (do_profile_times) \
439 GetTimeOfDay(&profile_starttime); \
440 INC_PROFILE_COUNT(x##_count); \
441 ADD_PROFILE_COUNT(x##_bytes,n); \
443 #define END_PROFILE(x) \
444 if (do_profile_times) { \
445 GetTimeOfDay(&profile_endtime); \
446 ADD_PROFILE_COUNT(x##_time,PROFILE_TIME); \
448 #define END_PROFILE_NESTED(x) \
449 if (do_profile_times) { \
450 GetTimeOfDay(&profile_endtime_nested); \
451 ADD_PROFILE_COUNT(x##_time,PROFILE_TIME_NESTED); \
453 #else
454 #define DO_PROFILE_INC(x)
455 #define DO_PROFILE_DEC(x)
456 #define DO_PROFILE_DEC_INC(x,y)
457 #define DO_PROFILE_ADD(x,n)
458 #define START_PROFILE(x)
459 #define START_PROFILE_NESTED(x)
460 #define START_PROFILE_BYTES(x,n)
461 #define END_PROFILE(x)
462 #define END_PROFILE_NESTED(x)
463 #endif
465 #endif