Add fdopendir to the VFS. We will use this to reuse a directory fd already open by...
[sfrench/samba-autobuild/.git] / source3 / include / smbprofile.h
index c89815598b4520c3319638b61529801f2a016025..3041f6c87ec03146abfa6d0dd00262957c5c315a 100644 (file)
@@ -26,7 +26,7 @@
 
 #define PROF_SHMEM_KEY ((key_t)0x07021999)
 #define PROF_SHM_MAGIC 0x6349985
-#define PROF_SHM_VERSION 11
+#define PROF_SHM_VERSION 12
 
 /* time values in the following structure are in microseconds */
 
@@ -43,6 +43,10 @@ enum profile_stats_values
 #define syscall_opendir_count __profile_stats_value(PR_VALUE_SYSCALL_OPENDIR, count)
 #define syscall_opendir_time __profile_stats_value(PR_VALUE_SYSCALL_OPENDIR, time)
 
+       PR_VALUE_SYSCALL_FDOPENDIR,
+#define syscall_fdopendir_count __profile_stats_value(PR_VALUE_SYSCALL_FDOPENDIR, count)
+#define syscall_fdopendir_time __profile_stats_value(PR_VALUE_SYSCALL_FDOPENDIR, time)
+
        PR_VALUE_SYSCALL_READDIR,
 #define syscall_readdir_count __profile_stats_value(PR_VALUE_SYSCALL_READDIR, count)
 #define syscall_readdir_time __profile_stats_value(PR_VALUE_SYSCALL_READDIR, time)
@@ -75,6 +79,10 @@ enum profile_stats_values
 #define syscall_open_count __profile_stats_value(PR_VALUE_SYSCALL_OPEN, count)
 #define syscall_open_time __profile_stats_value(PR_VALUE_SYSCALL_OPEN, time)
 
+       PR_VALUE_SYSCALL_CREATEFILE,
+#define syscall_createfile_count __profile_stats_value(PR_VALUE_SYSCALL_CREATEFILE, count)
+#define syscall_createfile_time __profile_stats_value(PR_VALUE_SYSCALL_CREATEFILE, time)
+
        PR_VALUE_SYSCALL_CLOSE,
 #define syscall_close_count __profile_stats_value(PR_VALUE_SYSCALL_CLOSE, count)
 #define syscall_close_time __profile_stats_value(PR_VALUE_SYSCALL_CLOSE, time)
@@ -103,10 +111,18 @@ enum profile_stats_values
 #define syscall_sendfile_count __profile_stats_value(PR_VALUE_SYSCALL_SENDFILE, count)
 #define syscall_sendfile_time __profile_stats_value(PR_VALUE_SYSCALL_SENDFILE, time)
 
+       PR_VALUE_SYSCALL_RECVFILE,
+#define syscall_recvfile_count __profile_stats_value(PR_VALUE_SYSCALL_RECVFILE, count)
+#define syscall_recvfile_time __profile_stats_value(PR_VALUE_SYSCALL_RECVFILE, time)
+
        PR_VALUE_SYSCALL_RENAME,
 #define syscall_rename_count __profile_stats_value(PR_VALUE_SYSCALL_RENAME, count)
 #define syscall_rename_time __profile_stats_value(PR_VALUE_SYSCALL_RENAME, time)
 
+       PR_VALUE_SYSCALL_RENAME_AT,
+#define syscall_rename_at_count __profile_stats_value(PR_VALUE_SYSCALL_RENAME_AT, count)
+#define syscall_rename_at_time __profile_stats_value(PR_VALUE_SYSCALL_RENAME_AT, time)
+
        PR_VALUE_SYSCALL_FSYNC,
 #define syscall_fsync_count __profile_stats_value(PR_VALUE_SYSCALL_FSYNC, count)
 #define syscall_fsync_time __profile_stats_value(PR_VALUE_SYSCALL_FSYNC, time)
@@ -123,6 +139,10 @@ enum profile_stats_values
 #define syscall_lstat_count __profile_stats_value(PR_VALUE_SYSCALL_LSTAT, count)
 #define syscall_lstat_time __profile_stats_value(PR_VALUE_SYSCALL_LSTAT, time)
 
+       PR_VALUE_SYSCALL_GET_ALLOC_SIZE,
+#define syscall_get_alloc_size_count __profile_stats_value(PR_VALUE_SYSCALL_GET_ALLOC_SIZE, count)
+#define syscall_get_alloc_size_time __profile_stats_value(PR_VALUE_SYSCALL_GET_ALLOC_SIZE, time)
+
        PR_VALUE_SYSCALL_UNLINK,
 #define syscall_unlink_count __profile_stats_value(PR_VALUE_SYSCALL_UNLINK, count)
 #define syscall_unlink_time __profile_stats_value(PR_VALUE_SYSCALL_UNLINK, time)
@@ -163,6 +183,10 @@ enum profile_stats_values
 #define syscall_ftruncate_count __profile_stats_value(PR_VALUE_SYSCALL_FTRUNCATE, count)
 #define syscall_ftruncate_time __profile_stats_value(PR_VALUE_SYSCALL_FTRUNCATE, time)
 
+       PR_VALUE_SYSCALL_FALLOCATE,
+#define syscall_fallocate_count __profile_stats_value(PR_VALUE_SYSCALL_FALLOCATE, count)
+#define syscall_fallocate_time __profile_stats_value(PR_VALUE_SYSCALL_FALLOCATE, time)
+
        PR_VALUE_SYSCALL_FCNTL_LOCK,
 #define syscall_fcntl_lock_count __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_LOCK, count)
 #define syscall_fcntl_lock_time __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_LOCK, time)
@@ -207,6 +231,34 @@ enum profile_stats_values
 #define syscall_set_quota_count __profile_stats_value(PR_VALUE_SYSCALL_SET_QUOTA, count)
 #define syscall_set_quota_time __profile_stats_value(PR_VALUE_SYSCALL_SET_QUOTA, time)
 
+       PR_VALUE_SYSCALL_GET_SD,
+#define syscall_get_sd_count __profile_stats_value(PR_VALUE_SYSCALL_GET_SD, count)
+#define syscall_get_sd_time __profile_stats_value(PR_VALUE_SYSCALL_GET_SD, time)
+
+       PR_VALUE_SYSCALL_SET_SD,
+#define syscall_set_sd_count __profile_stats_value(PR_VALUE_SYSCALL_SET_SD, count)
+#define syscall_set_sd_time __profile_stats_value(PR_VALUE_SYSCALL_SET_SD, time)
+
+       PR_VALUE_SYSCALL_BRL_LOCK,
+#define syscall_brl_lock_count __profile_stats_value(PR_VALUE_SYSCALL_BRL_LOCK, count)
+#define syscall_brl_lock_time __profile_stats_value(PR_VALUE_SYSCALL_BRL_LOCK, time)
+
+       PR_VALUE_SYSCALL_BRL_UNLOCK,
+#define syscall_brl_unlock_count __profile_stats_value(PR_VALUE_SYSCALL_BRL_UNLOCK, count)
+#define syscall_brl_unlock_time __profile_stats_value(PR_VALUE_SYSCALL_BRL_UNLOCK, time)
+
+       PR_VALUE_SYSCALL_BRL_CANCEL,
+#define syscall_brl_cancel_count __profile_stats_value(PR_VALUE_SYSCALL_BRL_CANCEL, count)
+#define syscall_brl_cancel_time __profile_stats_value(PR_VALUE_SYSCALL_BRL_CANCEL, time)
+
+       PR_VALUE_SYSCALL_STRICT_LOCK,
+#define syscall_strict_lock_count __profile_stats_value(PR_VALUE_SYSCALL_STRICT_LOCK, count)
+#define syscall_strict_lock_time __profile_stats_value(PR_VALUE_SYSCALL_STRICT_LOCK, time)
+
+       PR_VALUE_SYSCALL_STRICT_UNLOCK,
+#define syscall_strict_unlock_count __profile_stats_value(PR_VALUE_SYSCALL_STRICT_UNLOCK, count)
+#define syscall_strict_unlock_time __profile_stats_value(PR_VALUE_SYSCALL_STRICT_UNLOCK, time)
+
 /* counters for individual SMB types */
        PR_VALUE_SMBMKDIR,
 #define SMBmkdir_count __profile_stats_value(PR_VALUE_SMBMKDIR, count)
@@ -627,10 +679,6 @@ enum profile_stats_values
 #define fget_nt_acl_count __profile_stats_value(PR_VALUE_FGET_NT_ACL, count)
 #define fget_nt_acl_time __profile_stats_value(PR_VALUE_FGET_NT_ACL, time)
 
-       PR_VALUE_SET_NT_ACL,
-#define set_nt_acl_count __profile_stats_value(PR_VALUE_SET_NT_ACL, count)
-#define set_nt_acl_time __profile_stats_value(PR_VALUE_SET_NT_ACL, time)
-
        PR_VALUE_FSET_NT_ACL,
 #define fset_nt_acl_count __profile_stats_value(PR_VALUE_FSET_NT_ACL, count)
 #define fset_nt_acl_time __profile_stats_value(PR_VALUE_FSET_NT_ACL, time)
@@ -716,6 +764,82 @@ enum profile_stats_values
 #define election_count __profile_stats_value(PR_VALUE_ELECTION, count)
 #define election_time __profile_stats_value(PR_VALUE_ELECTION, time)
 
+       PR_VALUE_SMB2_NEGPROT,
+#define smb2_negprot_count __profile_stats_value(PR_VALUE_SMB2_NEGPROT, count)
+#define smb2_negprot_time __profile_stats_value(PR_VALUE_SMB2_NEGPROT, time)
+
+       PR_VALUE_SMB2_SESSSETUP,
+#define smb2_sesssetup_count __profile_stats_value(PR_VALUE_SMB2_SESSSETUP, count)
+#define smb2_sesssetup_time __profile_stats_value(PR_VALUE_SMB2_SESSSETUP, time)
+
+       PR_VALUE_SMB2_LOGOFF,
+#define smb2_logoff_count __profile_stats_value(PR_VALUE_SMB2_LOGOFF, count)
+#define smb2_logoff_time __profile_stats_value(PR_VALUE_SMB2_LOGOFF, time)
+
+       PR_VALUE_SMB2_TCON,
+#define smb2_tcon_count __profile_stats_value(PR_VALUE_SMB2_TCON, count)
+#define smb2_tcon_time __profile_stats_value(PR_VALUE_SMB2_TCON, time)
+
+       PR_VALUE_SMB2_TDIS,
+#define smb2_tdis_count __profile_stats_value(PR_VALUE_SMB2_TDIS, count)
+#define smb2_tdis_time __profile_stats_value(PR_VALUE_SMB2_TDIS, time)
+
+       PR_VALUE_SMB2_CREATE,
+#define smb2_create_count __profile_stats_value(PR_VALUE_SMB2_CREATE, count)
+#define smb2_create_time __profile_stats_value(PR_VALUE_SMB2_CREATE, time)
+
+       PR_VALUE_SMB2_CLOSE,
+#define smb2_close_count __profile_stats_value(PR_VALUE_SMB2_CLOSE, count)
+#define smb2_close_time __profile_stats_value(PR_VALUE_SMB2_CLOSE, time)
+
+       PR_VALUE_SMB2_FLUSH,
+#define smb2_flush_count __profile_stats_value(PR_VALUE_SMB2_FLUSH, count)
+#define smb2_flush_time __profile_stats_value(PR_VALUE_SMB2_FLUSH, time)
+
+       PR_VALUE_SMB2_READ,
+#define smb2_read_count __profile_stats_value(PR_VALUE_SMB2_READ, count)
+#define smb2_read_time __profile_stats_value(PR_VALUE_SMB2_READ, time)
+
+       PR_VALUE_SMB2_WRITE,
+#define smb2_write_count __profile_stats_value(PR_VALUE_SMB2_WRITE, count)
+#define smb2_write_time __profile_stats_value(PR_VALUE_SMB2_WRITE, time)
+
+       PR_VALUE_SMB2_LOCK,
+#define smb2_lock_count __profile_stats_value(PR_VALUE_SMB2_LOCK, count)
+#define smb2_lock_time __profile_stats_value(PR_VALUE_SMB2_LOCK, time)
+
+       PR_VALUE_SMB2_IOCTL,
+#define smb2_ioctl_count __profile_stats_value(PR_VALUE_SMB2_IOCTL, count)
+#define smb2_ioctl_time __profile_stats_value(PR_VALUE_SMB2_IOCTL, time)
+
+       PR_VALUE_SMB2_CANCEL,
+#define smb2_cancel_count __profile_stats_value(PR_VALUE_SMB2_CANCEL, count)
+#define smb2_cancel_time __profile_stats_value(PR_VALUE_SMB2_CANCEL, time)
+
+       PR_VALUE_SMB2_KEEPALIVE,
+#define smb2_keepalive_count __profile_stats_value(PR_VALUE_SMB2_KEEPALIVE, count)
+#define smb2_keepalive_time __profile_stats_value(PR_VALUE_SMB2_KEEPALIVE, time)
+
+       PR_VALUE_SMB2_FIND,
+#define smb2_find_count __profile_stats_value(PR_VALUE_SMB2_FIND, count)
+#define smb2_find_time __profile_stats_value(PR_VALUE_SMB2_FIND, time)
+
+       PR_VALUE_SMB2_NOTIFY,
+#define smb2_notify_count __profile_stats_value(PR_VALUE_SMB2_NOTIFY, count)
+#define smb2_notify_time __profile_stats_value(PR_VALUE_SMB2_NOTIFY, time)
+
+       PR_VALUE_SMB2_GETINFO,
+#define smb2_getinfo_count __profile_stats_value(PR_VALUE_SMB2_GETINFO, count)
+#define smb2_getinfo_time __profile_stats_value(PR_VALUE_SMB2_GETINFO, time)
+
+       PR_VALUE_SMB2_SETINFO,
+#define smb2_setinfo_count __profile_stats_value(PR_VALUE_SMB2_SETINFO, count)
+#define smb2_setinfo_time __profile_stats_value(PR_VALUE_SMB2_SETINFO, time)
+
+       PR_VALUE_SMB2_BREAK,
+#define smb2_break_count __profile_stats_value(PR_VALUE_SMB2_BREAK, count)
+#define smb2_break_time __profile_stats_value(PR_VALUE_SMB2_BREAK, time)
+
        /* This mist remain the last value. */
        PR_VALUE_MAX
 }; /* enum profile_stats_values */
@@ -737,6 +861,7 @@ struct profile_stats {
        unsigned syscall_read_bytes;
        unsigned syscall_write_bytes;
        unsigned syscall_sendfile_bytes;
+       unsigned syscall_recvfile_bytes;
 
 /* stat cache counters */
        unsigned statcache_lookups;
@@ -777,34 +902,16 @@ extern bool do_profile_times;
 #define DEC_PROFILE_COUNT(x) profile_p->x--
 #define ADD_PROFILE_COUNT(x,y) profile_p->x += (y)
 
-#if defined(HAVE_CLOCK_GETTIME)
-
-extern clockid_t __profile_clock;
-
-static inline SMB_BIG_UINT profile_timestamp(void)
+static inline uint64_t profile_timestamp(void)
 {
        struct timespec ts;
 
-       /* FIXME: On a single-CPU system, or a system where we have bound
-        * daemon threads to single CPUs (eg. using cpusets or processor
-        * affinity), it might be preferable to use CLOCK_PROCESS_CPUTIME_ID.
-        */
-
-       clock_gettime(__profile_clock, &ts);
+       /* we might prefer to use the _COARSE clock variant of CLOCK_MONOTONIC
+          that one is faster but cached and "just" tick-wise precise */
+       clock_gettime_mono(&ts);
        return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); /* usec */
 }
 
-#else
-
-static inline SMB_BIG_UINT profile_timestamp(void)
-{
-       struct timeval tv;
-       GetTimeOfDay(&tv);
-       return (tv.tv_sec * 1000000) + tv.tv_usec;
-}
-
-#endif
-
 /* end of helper macros */
 
 #define DO_PROFILE_INC(x) \
@@ -829,14 +936,14 @@ static inline SMB_BIG_UINT profile_timestamp(void)
        }
 
 #define START_PROFILE(x) \
-       SMB_BIG_UINT __profstamp_##x = 0; \
+       uint64_t __profstamp_##x = 0; \
        if (do_profile_flag) { \
                __profstamp_##x = do_profile_times ? profile_timestamp() : 0;\
                INC_PROFILE_COUNT(x##_count); \
        }
 
 #define START_PROFILE_BYTES(x,n) \
-       SMB_BIG_UINT __profstamp_##x = 0; \
+       uint64_t __profstamp_##x = 0; \
        if (do_profile_flag) { \
                __profstamp_##x = do_profile_times ? profile_timestamp() : 0;\
                INC_PROFILE_COUNT(x##_count); \
@@ -848,8 +955,6 @@ static inline SMB_BIG_UINT profile_timestamp(void)
                ADD_PROFILE_COUNT(x##_time, \
                    profile_timestamp() - __profstamp_##x); \
        }
-
-
 #else /* WITH_PROFILE */
 
 #define DO_PROFILE_INC(x)
@@ -859,7 +964,6 @@ static inline SMB_BIG_UINT profile_timestamp(void)
 #define START_PROFILE(x)
 #define START_PROFILE_BYTES(x,n)
 #define END_PROFILE(x)
-
 #endif /* WITH_PROFILE */
 
 #endif