]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_default: use per-share profile macros
authorShachar Sharon <ssharon@redhat.com>
Mon, 28 Apr 2025 18:36:39 +0000 (21:36 +0300)
committerAnoop C S <anoopcs@samba.org>
Mon, 23 Jun 2025 13:04:31 +0000 (13:04 +0000)
Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/modules/vfs_default.c

index d0cdffa790ae2b334c64bbd8f17ff9a15d01bc49..83c9cc06de8659afb63312606156ea91ea316783 100644 (file)
@@ -109,9 +109,9 @@ static int vfswrap_get_quota(struct vfs_handle_struct *handle,
 #ifdef HAVE_SYS_QUOTAS
        int result;
 
-       START_PROFILE(syscall_get_quota);
+       START_PROFILE_X(SNUM(handle->conn), syscall_get_quota);
        result = sys_get_quota(smb_fname->base_name, qtype, id, qt);
-       END_PROFILE(syscall_get_quota);
+       END_PROFILE_X(syscall_get_quota);
        return result;
 #else
        errno = ENOSYS;
@@ -124,9 +124,9 @@ static int vfswrap_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TY
 #ifdef HAVE_SYS_QUOTAS
        int result;
 
-       START_PROFILE(syscall_set_quota);
+       START_PROFILE_X(SNUM(handle->conn), syscall_set_quota);
        result = sys_set_quota(handle->conn->connectpath, qtype, id, qt);
-       END_PROFILE(syscall_set_quota);
+       END_PROFILE_X(syscall_set_quota);
        return result;
 #else
        errno = ENOSYS;
@@ -539,9 +539,9 @@ static DIR *vfswrap_fdopendir(vfs_handle_struct *handle,
 {
        DIR *result;
 
-       START_PROFILE(syscall_fdopendir);
+       START_PROFILE_X(SNUM(handle->conn), syscall_fdopendir);
        result = sys_fdopendir(fsp_get_io_fd(fsp));
-       END_PROFILE(syscall_fdopendir);
+       END_PROFILE_X(syscall_fdopendir);
        return result;
 }
 
@@ -551,10 +551,10 @@ static struct dirent *vfswrap_readdir(vfs_handle_struct *handle,
 {
        struct dirent *result;
 
-       START_PROFILE(syscall_readdir);
+       START_PROFILE_X(SNUM(handle->conn), syscall_readdir);
 
        result = readdir(dirp);
-       END_PROFILE(syscall_readdir);
+       END_PROFILE_X(syscall_readdir);
 
        return result;
 }
@@ -569,9 +569,9 @@ static NTSTATUS vfswrap_freaddir_attr(struct vfs_handle_struct *handle,
 
 static void vfswrap_rewinddir(vfs_handle_struct *handle, DIR *dirp)
 {
-       START_PROFILE(syscall_rewinddir);
+       START_PROFILE_X(SNUM(handle->conn), syscall_rewinddir);
        rewinddir(dirp);
-       END_PROFILE(syscall_rewinddir);
+       END_PROFILE_X(syscall_rewinddir);
 }
 
 static int vfswrap_mkdirat(vfs_handle_struct *handle,
@@ -581,11 +581,11 @@ static int vfswrap_mkdirat(vfs_handle_struct *handle,
 {
        int result;
 
-       START_PROFILE(syscall_mkdirat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_mkdirat);
 
        result = mkdirat(fsp_get_pathref_fd(dirfsp), smb_fname->base_name, mode);
 
-       END_PROFILE(syscall_mkdirat);
+       END_PROFILE_X(syscall_mkdirat);
        return result;
 }
 
@@ -593,9 +593,9 @@ static int vfswrap_closedir(vfs_handle_struct *handle, DIR *dirp)
 {
        int result;
 
-       START_PROFILE(syscall_closedir);
+       START_PROFILE_X(SNUM(handle->conn), syscall_closedir);
        result = closedir(dirp);
-       END_PROFILE(syscall_closedir);
+       END_PROFILE_X(syscall_closedir);
        return result;
 }
 
@@ -614,7 +614,7 @@ static int vfswrap_openat(vfs_handle_struct *handle,
        bool became_root = false;
        int result;
 
-       START_PROFILE(syscall_openat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_openat);
 
        SMB_ASSERT((dirfd != -1) || (smb_fname->base_name[0] == '/'));
 
@@ -710,7 +710,7 @@ done:
        }
 
 out:
-       END_PROFILE(syscall_openat);
+       END_PROFILE_X(syscall_openat);
        return result;
 }
 static NTSTATUS vfswrap_create_file(vfs_handle_struct *handle,
@@ -746,9 +746,9 @@ static int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp)
 {
        int result;
 
-       START_PROFILE(syscall_close);
+       START_PROFILE_X(SNUM(handle->conn), syscall_close);
        result = fd_close_posix(fsp);
-       END_PROFILE(syscall_close);
+       END_PROFILE_X(syscall_close);
        return result;
 }
 
@@ -758,9 +758,9 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void
        ssize_t result;
 
 #if defined(HAVE_PREAD) || defined(HAVE_PREAD64)
-       START_PROFILE_BYTES(syscall_pread, n);
+       START_PROFILE_BYTES_X(SNUM(handle->conn), syscall_pread, n);
        result = sys_pread_full(fsp_get_io_fd(fsp), data, n, offset);
-       END_PROFILE_BYTES(syscall_pread);
+       END_PROFILE_BYTES_X(syscall_pread);
 
        if (result == -1 && errno == ESPIPE) {
                /* Maintain the fiction that pipes can be seeked (sought?) on. */
@@ -782,7 +782,7 @@ static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, cons
        ssize_t result;
 
 #if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64)
-       START_PROFILE_BYTES(syscall_pwrite, n);
+       START_PROFILE_BYTES_X(SNUM(handle->conn), syscall_pwrite, n);
 
        if (fsp->fsp_flags.posix_append) {
                SMB_ASSERT(offset == VFS_PWRITE_APPEND_OFFSET);
@@ -795,7 +795,7 @@ static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, cons
        } else {
                result = sys_pwrite_full(fsp_get_io_fd(fsp), data, n, offset);
        }
-       END_PROFILE_BYTES(syscall_pwrite);
+       END_PROFILE_BYTES_X(syscall_pwrite);
 
        if (result == -1 && errno == ESPIPE) {
                /* Maintain the fiction that pipes can be sought on. */
@@ -819,6 +819,7 @@ struct vfswrap_pread_state {
 
        struct vfs_aio_state vfs_aio_state;
        SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes_x);
 };
 
 static void vfs_pread_do(void *private_data);
@@ -846,9 +847,13 @@ static struct tevent_req *vfswrap_pread_send(struct vfs_handle_struct *handle,
        state->count = n;
        state->offset = offset;
 
-       SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pread, profile_p,
-                                    state->profile_bytes, n);
-       SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_START_X(SNUM(handle->conn),
+                                      syscall_asys_pread,
+                                      state->profile_bytes,
+                                      state->profile_bytes_x,
+                                      n);
+       SMBPROFILE_BYTES_ASYNC_SET_IDLE_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 
        subreq = pthreadpool_tevent_job_send(
                state, ev, handle->conn->sconn->pool,
@@ -870,7 +875,8 @@ static void vfs_pread_do(void *private_data)
        struct timespec start_time;
        struct timespec end_time;
 
-       SMBPROFILE_BYTES_ASYNC_SET_BUSY(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_SET_BUSY_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 
        PROFILE_TIMESTAMP(&start_time);
 
@@ -887,7 +893,8 @@ static void vfs_pread_do(void *private_data)
 
        state->vfs_aio_state.duration = nsec_time_diff(&end_time, &start_time);
 
-       SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_SET_IDLE_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 }
 
 static int vfs_pread_state_destructor(struct vfswrap_pread_state *state)
@@ -906,6 +913,7 @@ static void vfs_pread_done(struct tevent_req *subreq)
        ret = pthreadpool_tevent_job_recv(subreq);
        TALLOC_FREE(subreq);
        SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes_x);
        talloc_set_destructor(state, NULL);
        if (ret != 0) {
                if (ret != EAGAIN) {
@@ -948,6 +956,7 @@ struct vfswrap_pwrite_state {
 
        struct vfs_aio_state vfs_aio_state;
        SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes_x);
 };
 
 static void vfs_pwrite_do(void *private_data);
@@ -982,9 +991,13 @@ static struct tevent_req *vfswrap_pwrite_send(struct vfs_handle_struct *handle,
                SMB_ASSERT(state->offset >= 0);
        }
 
-       SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pwrite, profile_p,
-                                    state->profile_bytes, n);
-       SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_START_X(SNUM(handle->conn),
+                                      syscall_asys_pwrite,
+                                      state->profile_bytes,
+                                      state->profile_bytes_x,
+                                      n);
+       SMBPROFILE_BYTES_ASYNC_SET_IDLE_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 
        subreq = pthreadpool_tevent_job_send(
                state, ev, handle->conn->sconn->pool,
@@ -1006,7 +1019,8 @@ static void vfs_pwrite_do(void *private_data)
        struct timespec start_time;
        struct timespec end_time;
 
-       SMBPROFILE_BYTES_ASYNC_SET_BUSY(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_SET_BUSY_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 
        PROFILE_TIMESTAMP(&start_time);
 
@@ -1029,7 +1043,8 @@ static void vfs_pwrite_do(void *private_data)
 
        state->vfs_aio_state.duration = nsec_time_diff(&end_time, &start_time);
 
-       SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_SET_IDLE_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 }
 
 static int vfs_pwrite_state_destructor(struct vfswrap_pwrite_state *state)
@@ -1048,6 +1063,7 @@ static void vfs_pwrite_done(struct tevent_req *subreq)
        ret = pthreadpool_tevent_job_recv(subreq);
        TALLOC_FREE(subreq);
        SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes_x);
        talloc_set_destructor(state, NULL);
        if (ret != 0) {
                if (ret != EAGAIN) {
@@ -1086,6 +1102,7 @@ struct vfswrap_fsync_state {
 
        struct vfs_aio_state vfs_aio_state;
        SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes_x);
 };
 
 static void vfs_fsync_do(void *private_data);
@@ -1108,9 +1125,13 @@ static struct tevent_req *vfswrap_fsync_send(struct vfs_handle_struct *handle,
        state->ret = -1;
        state->fd = fsp_get_io_fd(fsp);
 
-       SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync, profile_p,
-                                    state->profile_bytes, 0);
-       SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_START_X(SNUM(handle->conn),
+                                      syscall_asys_fsync,
+                                      state->profile_bytes,
+                                      state->profile_bytes_x,
+                                      0);
+       SMBPROFILE_BYTES_ASYNC_SET_IDLE_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 
        subreq = pthreadpool_tevent_job_send(
                state, ev, handle->conn->sconn->pool, vfs_fsync_do, state);
@@ -1131,7 +1152,8 @@ static void vfs_fsync_do(void *private_data)
        struct timespec start_time;
        struct timespec end_time;
 
-       SMBPROFILE_BYTES_ASYNC_SET_BUSY(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_SET_BUSY_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 
        PROFILE_TIMESTAMP(&start_time);
 
@@ -1147,7 +1169,8 @@ static void vfs_fsync_do(void *private_data)
 
        state->vfs_aio_state.duration = nsec_time_diff(&end_time, &start_time);
 
-       SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_SET_IDLE_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 }
 
 static int vfs_fsync_state_destructor(struct vfswrap_fsync_state *state)
@@ -1166,6 +1189,7 @@ static void vfs_fsync_done(struct tevent_req *subreq)
        ret = pthreadpool_tevent_job_recv(subreq);
        TALLOC_FREE(subreq);
        SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes_x);
        talloc_set_destructor(state, NULL);
        if (ret != 0) {
                if (ret != EAGAIN) {
@@ -1202,7 +1226,7 @@ static off_t vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, off_t o
 {
        off_t result = 0;
 
-       START_PROFILE(syscall_lseek);
+       START_PROFILE_X(SNUM(handle->conn), syscall_lseek);
 
        result = lseek(fsp_get_io_fd(fsp), offset, whence);
        /*
@@ -1217,7 +1241,7 @@ static off_t vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, off_t o
                errno = 0;
        }
 
-       END_PROFILE(syscall_lseek);
+       END_PROFILE_X(syscall_lseek);
        return result;
 }
 
@@ -1226,9 +1250,9 @@ static ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struc
 {
        ssize_t result;
 
-       START_PROFILE_BYTES(syscall_sendfile, n);
+       START_PROFILE_BYTES_X(SNUM(handle->conn), syscall_sendfile, n);
        result = sys_sendfile(tofd, fsp_get_io_fd(fromfsp), hdr, offset, n);
-       END_PROFILE_BYTES(syscall_sendfile);
+       END_PROFILE_BYTES_X(syscall_sendfile);
        return result;
 }
 
@@ -1240,9 +1264,9 @@ static ssize_t vfswrap_recvfile(vfs_handle_struct *handle,
 {
        ssize_t result;
 
-       START_PROFILE_BYTES(syscall_recvfile, n);
+       START_PROFILE_BYTES_X(SNUM(handle->conn), syscall_recvfile, n);
        result = sys_recvfile(fromfd, fsp_get_io_fd(tofsp), offset, n);
-       END_PROFILE_BYTES(syscall_recvfile);
+       END_PROFILE_BYTES_X(syscall_recvfile);
        return result;
 }
 
@@ -1256,13 +1280,13 @@ static int vfswrap_renameat(vfs_handle_struct *handle,
        int result = -1;
        int flags = 0;
 
-       START_PROFILE(syscall_renameat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_renameat);
 
        SMB_ASSERT(!is_named_stream(smb_fname_src));
        SMB_ASSERT(!is_named_stream(smb_fname_dst));
 
        if (how->flags & ~VFS_RENAME_HOW_NO_REPLACE) {
-               END_PROFILE(syscall_renameat);
+               END_PROFILE_X(syscall_renameat);
                errno = EINVAL;
                return -1;
        }
@@ -1277,7 +1301,7 @@ static int vfswrap_renameat(vfs_handle_struct *handle,
                           smb_fname_dst->base_name,
                           flags);
 
-       END_PROFILE(syscall_renameat);
+       END_PROFILE_X(syscall_renameat);
        return result;
 }
 
@@ -1286,14 +1310,14 @@ static int vfswrap_stat(vfs_handle_struct *handle,
 {
        int result = -1;
 
-       START_PROFILE(syscall_stat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_stat);
 
        SMB_ASSERT(!is_named_stream(smb_fname));
 
        result = sys_stat(smb_fname->base_name, &smb_fname->st,
                          lp_fake_directory_create_times(SNUM(handle->conn)));
 
-       END_PROFILE(syscall_stat);
+       END_PROFILE_X(syscall_stat);
        return result;
 }
 
@@ -1301,10 +1325,10 @@ static int vfswrap_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUC
 {
        int result;
 
-       START_PROFILE(syscall_fstat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_fstat);
        result = sys_fstat(fsp_get_pathref_fd(fsp),
                           sbuf, lp_fake_directory_create_times(SNUM(handle->conn)));
-       END_PROFILE(syscall_fstat);
+       END_PROFILE_X(syscall_fstat);
        return result;
 }
 
@@ -1313,14 +1337,14 @@ static int vfswrap_lstat(vfs_handle_struct *handle,
 {
        int result = -1;
 
-       START_PROFILE(syscall_lstat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_lstat);
 
        SMB_ASSERT(!is_named_stream(smb_fname));
 
        result = sys_lstat(smb_fname->base_name, &smb_fname->st,
                           lp_fake_directory_create_times(SNUM(handle->conn)));
 
-       END_PROFILE(syscall_lstat);
+       END_PROFILE_X(syscall_lstat);
        return result;
 }
 
@@ -1333,7 +1357,7 @@ static int vfswrap_fstatat(
 {
        int result = -1;
 
-       START_PROFILE(syscall_fstatat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_fstatat);
 
        SMB_ASSERT(!is_named_stream(smb_fname));
 
@@ -1344,7 +1368,7 @@ static int vfswrap_fstatat(
                flags,
                lp_fake_directory_create_times(SNUM(handle->conn)));
 
-       END_PROFILE(syscall_fstatat);
+       END_PROFILE_X(syscall_fstatat);
        return result;
 }
 
@@ -2638,7 +2662,7 @@ static uint64_t vfswrap_get_alloc_size(vfs_handle_struct *handle,
 {
        uint64_t result;
 
-       START_PROFILE(syscall_get_alloc_size);
+       START_PROFILE_X(SNUM(handle->conn), syscall_get_alloc_size);
 
        if(S_ISDIR(sbuf->st_ex_mode)) {
                result = 0;
@@ -2682,8 +2706,8 @@ static uint64_t vfswrap_get_alloc_size(vfs_handle_struct *handle,
        result = smb_roundup(handle->conn, result);
 
  out:
-       END_PROFILE(syscall_get_alloc_size);
-       return result;
+        END_PROFILE_X(syscall_get_alloc_size);
+        return result;
 }
 
 static int vfswrap_unlinkat(vfs_handle_struct *handle,
@@ -2693,7 +2717,7 @@ static int vfswrap_unlinkat(vfs_handle_struct *handle,
 {
        int result = -1;
 
-       START_PROFILE(syscall_unlinkat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_unlinkat);
 
        SMB_ASSERT(!is_named_stream(smb_fname));
 
@@ -2701,7 +2725,7 @@ static int vfswrap_unlinkat(vfs_handle_struct *handle,
                        smb_fname->base_name,
                        flags);
 
-       END_PROFILE(syscall_unlinkat);
+       END_PROFILE_X(syscall_unlinkat);
        return result;
 }
 
@@ -2709,11 +2733,11 @@ static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t m
 {
        int result;
 
-       START_PROFILE(syscall_fchmod);
+       START_PROFILE_X(SNUM(handle->conn), syscall_fchmod);
 
        if (!fsp->fsp_flags.is_pathref) {
                result = fchmod(fsp_get_io_fd(fsp), mode);
-               END_PROFILE(syscall_fchmod);
+               END_PROFILE_X(syscall_fchmod);
                return result;
        }
 
@@ -2723,7 +2747,7 @@ static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t m
 
                result = chmod(sys_proc_fd_path(fd, &buf), mode);
 
-               END_PROFILE(syscall_fchmod);
+               END_PROFILE_X(syscall_fchmod);
                return result;
        }
 
@@ -2732,7 +2756,7 @@ static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t m
         */
        result = chmod(fsp->fsp_name->base_name, mode);
 
-       END_PROFILE(syscall_fchmod);
+       END_PROFILE_X(syscall_fchmod);
        return result;
 }
 
@@ -2741,10 +2765,10 @@ static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t ui
 #ifdef HAVE_FCHOWN
        int result;
 
-       START_PROFILE(syscall_fchown);
+       START_PROFILE_X(SNUM(handle->conn), syscall_fchown);
        if (!fsp->fsp_flags.is_pathref) {
                result = fchown(fsp_get_io_fd(fsp), uid, gid);
-               END_PROFILE(syscall_fchown);
+               END_PROFILE_X(syscall_fchown);
                return result;
        }
 
@@ -2754,7 +2778,7 @@ static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t ui
 
                result = chown(sys_proc_fd_path(fd, &buf), uid, gid);
 
-               END_PROFILE(syscall_fchown);
+               END_PROFILE_X(syscall_fchown);
                return result;
        }
 
@@ -2762,7 +2786,7 @@ static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t ui
         * This is no longer a handle based call.
         */
        result = chown(fsp->fsp_name->base_name, uid, gid);
-       END_PROFILE(syscall_fchown);
+       END_PROFILE_X(syscall_fchown);
        return result;
 #else
        errno = ENOSYS;
@@ -2777,9 +2801,9 @@ static int vfswrap_lchown(vfs_handle_struct *handle,
 {
        int result;
 
-       START_PROFILE(syscall_lchown);
+       START_PROFILE_X(SNUM(handle->conn), syscall_lchown);
        result = lchown(smb_fname->base_name, uid, gid);
-       END_PROFILE(syscall_lchown);
+       END_PROFILE_X(syscall_lchown);
        return result;
 }
 
@@ -2788,9 +2812,9 @@ static int vfswrap_chdir(vfs_handle_struct *handle,
 {
        int result;
 
-       START_PROFILE(syscall_chdir);
+       START_PROFILE_X(SNUM(handle->conn), syscall_chdir);
        result = chdir(smb_fname->base_name);
-       END_PROFILE(syscall_chdir);
+       END_PROFILE_X(syscall_chdir);
        return result;
 }
 
@@ -2800,9 +2824,9 @@ static struct smb_filename *vfswrap_getwd(vfs_handle_struct *handle,
        char *result;
        struct smb_filename *smb_fname = NULL;
 
-       START_PROFILE(syscall_getwd);
+       START_PROFILE_X(SNUM(handle->conn), syscall_getwd);
        result = sys_getwd();
-       END_PROFILE(syscall_getwd);
+       END_PROFILE_X(syscall_getwd);
 
        if (result == NULL) {
                return NULL;
@@ -2835,7 +2859,7 @@ static int vfswrap_fntimes(vfs_handle_struct *handle,
        struct timespec ts[2];
        struct timespec *times = NULL;
 
-       START_PROFILE(syscall_fntimes);
+       START_PROFILE_X(SNUM(handle->conn), syscall_fntimes);
 
        if (fsp_is_alternate_stream(fsp)) {
                errno = ENOENT;
@@ -2895,7 +2919,7 @@ static int vfswrap_fntimes(vfs_handle_struct *handle,
        result = utimensat(AT_FDCWD, fsp->fsp_name->base_name, times, 0);
 
 out:
-       END_PROFILE(syscall_fntimes);
+       END_PROFILE_X(syscall_fntimes);
 
        return result;
 }
@@ -2983,11 +3007,11 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t
        NTSTATUS status;
        char c = 0;
 
-       START_PROFILE(syscall_ftruncate);
+       START_PROFILE_X(SNUM(handle->conn), syscall_ftruncate);
 
        if (lp_strict_allocate(SNUM(fsp->conn)) && !fsp->fsp_flags.is_sparse) {
                result = strict_allocate_ftruncate(handle, fsp, len);
-               END_PROFILE(syscall_ftruncate);
+               END_PROFILE_X(syscall_ftruncate);
                return result;
        }
 
@@ -3044,8 +3068,8 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t
 
   done:
 
-       END_PROFILE(syscall_ftruncate);
-       return result;
+         END_PROFILE_X(syscall_ftruncate);
+         return result;
 }
 
 static int vfswrap_fallocate(vfs_handle_struct *handle,
@@ -3056,7 +3080,7 @@ static int vfswrap_fallocate(vfs_handle_struct *handle,
 {
        int result;
 
-       START_PROFILE(syscall_fallocate);
+       START_PROFILE_X(SNUM(handle->conn), syscall_fallocate);
        if (mode == 0) {
                result = sys_posix_fallocate(fsp_get_io_fd(fsp), offset, len);
                /*
@@ -3072,7 +3096,7 @@ static int vfswrap_fallocate(vfs_handle_struct *handle,
                /* sys_fallocate handles filtering of unsupported mode flags */
                result = sys_fallocate(fsp_get_io_fd(fsp), mode, offset, len);
        }
-       END_PROFILE(syscall_fallocate);
+       END_PROFILE_X(syscall_fallocate);
        return result;
 }
 
@@ -3080,14 +3104,14 @@ static bool vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int op, o
 {
        bool result;
 
-       START_PROFILE(syscall_fcntl_lock);
+       START_PROFILE_X(SNUM(handle->conn), syscall_fcntl_lock);
 
        if (fsp->fsp_flags.use_ofd_locks) {
                op = map_process_lock_to_ofd_lock(op);
        }
 
        result =  fcntl_lock(fsp_get_io_fd(fsp), op, offset, count, type);
-       END_PROFILE(syscall_fcntl_lock);
+       END_PROFILE_X(syscall_fcntl_lock);
        return result;
 }
 
@@ -3108,7 +3132,7 @@ static int vfswrap_fcntl(vfs_handle_struct *handle, files_struct *fsp, int cmd,
        int result;
        int val;
 
-       START_PROFILE(syscall_fcntl);
+       START_PROFILE_X(SNUM(handle->conn), syscall_fcntl);
 
        va_copy(dup_cmd_arg, cmd_arg);
 
@@ -3141,7 +3165,7 @@ static int vfswrap_fcntl(vfs_handle_struct *handle, files_struct *fsp, int cmd,
 
        va_end(dup_cmd_arg);
 
-       END_PROFILE(syscall_fcntl);
+       END_PROFILE_X(syscall_fcntl);
        return result;
 }
 
@@ -3150,14 +3174,14 @@ static bool vfswrap_getlock(vfs_handle_struct *handle, files_struct *fsp, off_t
        bool result;
        int op = F_GETLK;
 
-       START_PROFILE(syscall_fcntl_getlock);
+       START_PROFILE_X(SNUM(handle->conn), syscall_fcntl_getlock);
 
        if (fsp->fsp_flags.use_ofd_locks) {
                op = map_process_lock_to_ofd_lock(op);
        }
 
        result = fcntl_getlock(fsp_get_io_fd(fsp), op, poffset, pcount, ptype, ppid);
-       END_PROFILE(syscall_fcntl_getlock);
+       END_PROFILE_X(syscall_fcntl_getlock);
        return result;
 }
 
@@ -3166,7 +3190,7 @@ static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
 {
        int result = -1;
 
-       START_PROFILE(syscall_linux_setlease);
+       START_PROFILE_X(SNUM(handle->conn), syscall_linux_setlease);
 
        SMB_ASSERT(!fsp_is_alternate_stream(fsp));
 
@@ -3175,7 +3199,7 @@ static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
 #else
        errno = ENOSYS;
 #endif
-       END_PROFILE(syscall_linux_setlease);
+       END_PROFILE_X(syscall_linux_setlease);
        return result;
 }
 
@@ -3186,14 +3210,14 @@ static int vfswrap_symlinkat(vfs_handle_struct *handle,
 {
        int result;
 
-       START_PROFILE(syscall_symlinkat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_symlinkat);
 
        SMB_ASSERT(!is_named_stream(new_smb_fname));
 
        result = symlinkat(link_target->base_name,
                        fsp_get_pathref_fd(dirfsp),
                        new_smb_fname->base_name);
-       END_PROFILE(syscall_symlinkat);
+       END_PROFILE_X(syscall_symlinkat);
        return result;
 }
 
@@ -3205,7 +3229,7 @@ static int vfswrap_readlinkat(vfs_handle_struct *handle,
 {
        int result;
 
-       START_PROFILE(syscall_readlinkat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_readlinkat);
 
        SMB_ASSERT(!is_named_stream(smb_fname));
 
@@ -3214,7 +3238,7 @@ static int vfswrap_readlinkat(vfs_handle_struct *handle,
                        buf,
                        bufsiz);
 
-       END_PROFILE(syscall_readlinkat);
+       END_PROFILE_X(syscall_readlinkat);
        return result;
 }
 
@@ -3227,7 +3251,7 @@ static int vfswrap_linkat(vfs_handle_struct *handle,
 {
        int result;
 
-       START_PROFILE(syscall_linkat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_linkat);
 
        SMB_ASSERT(!is_named_stream(old_smb_fname));
        SMB_ASSERT(!is_named_stream(new_smb_fname));
@@ -3238,7 +3262,7 @@ static int vfswrap_linkat(vfs_handle_struct *handle,
                        new_smb_fname->base_name,
                        flags);
 
-       END_PROFILE(syscall_linkat);
+       END_PROFILE_X(syscall_linkat);
        return result;
 }
 
@@ -3250,7 +3274,7 @@ static int vfswrap_mknodat(vfs_handle_struct *handle,
 {
        int result;
 
-       START_PROFILE(syscall_mknodat);
+       START_PROFILE_X(SNUM(handle->conn), syscall_mknodat);
 
        SMB_ASSERT(!is_named_stream(smb_fname));
 
@@ -3259,7 +3283,7 @@ static int vfswrap_mknodat(vfs_handle_struct *handle,
                        mode,
                        dev);
 
-       END_PROFILE(syscall_mknodat);
+       END_PROFILE_X(syscall_mknodat);
        return result;
 }
 
@@ -3270,9 +3294,9 @@ static struct smb_filename *vfswrap_realpath(vfs_handle_struct *handle,
        char *result;
        struct smb_filename *result_fname = NULL;
 
-       START_PROFILE(syscall_realpath);
+       START_PROFILE_X(SNUM(handle->conn), syscall_realpath);
        result = sys_realpath(smb_fname->base_name);
-       END_PROFILE(syscall_realpath);
+       END_PROFILE_X(syscall_realpath);
        if (result) {
                result_fname = synthetic_smb_fname(ctx,
                                                   result,
@@ -3461,13 +3485,13 @@ static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle,
 {
        NTSTATUS result;
 
-       START_PROFILE(fget_nt_acl);
+       START_PROFILE_X(SNUM(handle->conn), fget_nt_acl);
 
        SMB_ASSERT(!fsp_is_alternate_stream(fsp));
 
        result = posix_fget_nt_acl(fsp, security_info,
                                   mem_ctx, ppdesc);
-       END_PROFILE(fget_nt_acl);
+       END_PROFILE_X(fget_nt_acl);
        return result;
 }
 
@@ -3475,12 +3499,12 @@ static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp
 {
        NTSTATUS result;
 
-       START_PROFILE(fset_nt_acl);
+       START_PROFILE_X(SNUM(handle->conn), fset_nt_acl);
 
        SMB_ASSERT(!fsp_is_alternate_stream(fsp));
 
        result = set_nt_acl(fsp, security_info_sent, psd);
-       END_PROFILE(fset_nt_acl);
+       END_PROFILE_X(fset_nt_acl);
        return result;
 }
 
@@ -3570,6 +3594,7 @@ struct vfswrap_getxattrat_state {
        ssize_t xattr_size;
        struct vfs_aio_state vfs_aio_state;
        SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes_x);
 };
 
 static int vfswrap_getxattrat_state_destructor(
@@ -3627,8 +3652,11 @@ static struct tevent_req *vfswrap_getxattrat_send(
                do_async = true;
        }
 
-       SMBPROFILE_BYTES_ASYNC_START(syscall_asys_getxattrat, profile_p,
-                                    state->profile_bytes, 0);
+       SMBPROFILE_BYTES_ASYNC_START_X(SNUM(handle->conn),
+                                      syscall_asys_getxattrat,
+                                      state->profile_bytes,
+                                      state->profile_bytes_x,
+                                      0);
 
        if (fsp_get_pathref_fd(dir_fsp) == -1) {
                DBG_ERR("Need a valid directory fd\n");
@@ -3685,7 +3713,8 @@ static struct tevent_req *vfswrap_getxattrat_send(
                return tevent_req_post(req, ev);
        }
 
-       SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_SET_IDLE_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 
        subreq = pthreadpool_tevent_job_send(
                        state,
@@ -3731,7 +3760,8 @@ static void vfswrap_getxattrat_do_async(void *private_data)
        int ret;
 
        PROFILE_TIMESTAMP(&start_time);
-       SMBPROFILE_BYTES_ASYNC_SET_BUSY(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_SET_BUSY_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 
        /*
         * Here we simulate a getxattrat()
@@ -3763,7 +3793,8 @@ static void vfswrap_getxattrat_do_async(void *private_data)
 end_profile:
        PROFILE_TIMESTAMP(&end_time);
        state->vfs_aio_state.duration = nsec_time_diff(&end_time, &start_time);
-       SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_SET_IDLE_X(state->profile_bytes,
+                                         state->profile_bytes_x);
 }
 
 static void vfswrap_getxattrat_done(struct tevent_req *subreq)
@@ -3784,6 +3815,7 @@ static void vfswrap_getxattrat_done(struct tevent_req *subreq)
        ret = pthreadpool_tevent_job_recv(subreq);
        TALLOC_FREE(subreq);
        SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes);
+       SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes_x);
        talloc_set_destructor(state, NULL);
        if (ret != 0) {
                if (ret != EAGAIN) {