]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_glusterfs: Enable profiling for file system operations
authorAnoop C S <anoopcs@redhat.com>
Mon, 5 Aug 2019 05:15:01 +0000 (10:45 +0530)
committerJeremy Allison <jra@samba.org>
Tue, 20 Aug 2019 19:25:28 +0000 (19:25 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14093

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Aug 20 19:25:28 UTC 2019 on sn-devel-184

source3/modules/vfs_glusterfs.c

index 9a8e32c8fa9680d1e4f16e341801e93d9b94b1a2..fd60926d8153d63aa858cf3ac334ee9e4522aca3 100644 (file)
@@ -492,12 +492,16 @@ static DIR *vfs_gluster_opendir(struct vfs_handle_struct *handle,
 {
        glfs_fd_t *fd;
 
+       START_PROFILE(syscall_opendir);
+
        fd = glfs_opendir(handle->data, smb_fname->base_name);
        if (fd == NULL) {
                DEBUG(0, ("glfs_opendir(%s) failed: %s\n",
                          smb_fname->base_name, strerror(errno)));
        }
 
+       END_PROFILE(syscall_opendir);
+
        return (DIR *) fd;
 }
 
@@ -532,7 +536,13 @@ static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct *handle,
 
 static int vfs_gluster_closedir(struct vfs_handle_struct *handle, DIR *dirp)
 {
-       return glfs_closedir((void *)dirp);
+       int ret;
+
+       START_PROFILE(syscall_closedir);
+       ret = glfs_closedir((void *)dirp);
+       END_PROFILE(syscall_closedir);
+
+       return ret;
 }
 
 static struct dirent *vfs_gluster_readdir(struct vfs_handle_struct *handle,
@@ -543,6 +553,7 @@ static struct dirent *vfs_gluster_readdir(struct vfs_handle_struct *handle,
        struct stat stat;
        struct dirent *dirent = 0;
 
+       START_PROFILE(syscall_readdir);
        if (sbuf != NULL) {
                ret = glfs_readdirplus_r((void *)dirp, &stat, (void *)direntbuf,
                                         &dirent);
@@ -551,6 +562,7 @@ static struct dirent *vfs_gluster_readdir(struct vfs_handle_struct *handle,
        }
 
        if ((ret < 0) || (dirent == NULL)) {
+               END_PROFILE(syscall_readdir);
                return NULL;
        }
 
@@ -558,36 +570,59 @@ static struct dirent *vfs_gluster_readdir(struct vfs_handle_struct *handle,
                smb_stat_ex_from_stat(sbuf, &stat);
        }
 
+       END_PROFILE(syscall_readdir);
        return dirent;
 }
 
 static long vfs_gluster_telldir(struct vfs_handle_struct *handle, DIR *dirp)
 {
-       return glfs_telldir((void *)dirp);
+       long ret;
+
+       START_PROFILE(syscall_telldir);
+       ret = glfs_telldir((void *)dirp);
+       END_PROFILE(syscall_telldir);
+
+       return ret;
 }
 
 static void vfs_gluster_seekdir(struct vfs_handle_struct *handle, DIR *dirp,
                                long offset)
 {
+       START_PROFILE(syscall_seekdir);
        glfs_seekdir((void *)dirp, offset);
+       END_PROFILE(syscall_seekdir);
 }
 
 static void vfs_gluster_rewinddir(struct vfs_handle_struct *handle, DIR *dirp)
 {
+       START_PROFILE(syscall_rewinddir);
        glfs_seekdir((void *)dirp, 0);
+       END_PROFILE(syscall_rewinddir);
 }
 
 static int vfs_gluster_mkdir(struct vfs_handle_struct *handle,
                             const struct smb_filename *smb_fname,
                             mode_t mode)
 {
-       return glfs_mkdir(handle->data, smb_fname->base_name, mode);
+       int ret;
+
+       START_PROFILE(syscall_mkdir);
+       ret = glfs_mkdir(handle->data, smb_fname->base_name, mode);
+       END_PROFILE(syscall_mkdir);
+
+       return ret;
 }
 
 static int vfs_gluster_rmdir(struct vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname)
 {
-       return glfs_rmdir(handle->data, smb_fname->base_name);
+       int ret;
+
+       START_PROFILE(syscall_rmdir);
+       ret = glfs_rmdir(handle->data, smb_fname->base_name);
+       END_PROFILE(syscall_rmdir);
+
+       return ret;
 }
 
 static int vfs_gluster_open(struct vfs_handle_struct *handle,
@@ -597,8 +632,11 @@ static int vfs_gluster_open(struct vfs_handle_struct *handle,
        glfs_fd_t *glfd;
        glfs_fd_t **p_tmp;
 
+       START_PROFILE(syscall_open);
+
        p_tmp = VFS_ADD_FSP_EXTENSION(handle, fsp, glfs_fd_t *, NULL);
        if (p_tmp == NULL) {
+               END_PROFILE(syscall_open);
                errno = ENOMEM;
                return -1;
        }
@@ -613,12 +651,15 @@ static int vfs_gluster_open(struct vfs_handle_struct *handle,
        }
 
        if (glfd == NULL) {
+               END_PROFILE(syscall_open);
                /* no extension destroy_fn, so no need to save errno */
                VFS_REMOVE_FSP_EXTENSION(handle, fsp);
                return -1;
        }
 
        *p_tmp = glfd;
+
+       END_PROFILE(syscall_open);
        /* An arbitrary value for error reporting, so you know its us. */
        return 13371337;
 }
@@ -626,31 +667,50 @@ static int vfs_gluster_open(struct vfs_handle_struct *handle,
 static int vfs_gluster_close(struct vfs_handle_struct *handle,
                             files_struct *fsp)
 {
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       int ret;
+       glfs_fd_t *glfd = NULL;
+
+       START_PROFILE(syscall_close);
+
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
+               END_PROFILE(syscall_close);
                DBG_ERR("Failed to fetch gluster fd\n");
                return -1;
        }
 
        VFS_REMOVE_FSP_EXTENSION(handle, fsp);
-       return glfs_close(glfd);
+
+       ret = glfs_close(glfd);
+       END_PROFILE(syscall_close);
+
+       return ret;
 }
 
 static ssize_t vfs_gluster_pread(struct vfs_handle_struct *handle,
                                 files_struct *fsp, void *data, size_t n,
                                 off_t offset)
 {
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       ssize_t ret;
+       glfs_fd_t *glfd = NULL;
+
+       START_PROFILE_BYTES(syscall_pread, n);
+
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
+               END_PROFILE_BYTES(syscall_pread);
                DBG_ERR("Failed to fetch gluster fd\n");
                return -1;
        }
 
 #ifdef HAVE_GFAPI_VER_7_6
-       return glfs_pread(glfd, data, n, offset, 0, NULL);
+       ret = glfs_pread(glfd, data, n, offset, 0, NULL);
 #else
-       return glfs_pread(glfd, data, n, offset, 0);
+       ret = glfs_pread(glfd, data, n, offset, 0);
 #endif
+       END_PROFILE_BYTES(syscall_pread);
+
+       return ret;
 }
 
 struct glusterfs_aio_state;
@@ -665,6 +725,7 @@ struct glusterfs_aio_state {
        bool cancelled;
        struct vfs_aio_state vfs_aio_state;
        struct timespec start;
+       SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes);
 };
 
 static int aio_wrapper_destructor(struct glusterfs_aio_wrapper *wrap)
@@ -706,6 +767,8 @@ static void aio_glusterfs_done(glfs_fd_t *fd, ssize_t ret, void *data)
        }
        state->vfs_aio_state.duration = nsec_time_diff(&end, &state->start);
 
+       SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes);
+
        /*
         * Write the state pointer to glusterfs_aio_state to the
         * pipe, so we can call tevent_req_done() from the main thread,
@@ -878,6 +941,8 @@ static struct tevent_req *vfs_gluster_pread_send(struct vfs_handle_struct
         */
        tevent_req_defer_callback(req, ev);
 
+       SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pread, profile_p,
+                                    state->profile_bytes, n);
        PROFILE_TIMESTAMP(&state->start);
        ret = glfs_pread_async(glfd, data, n, offset, 0, aio_glusterfs_done,
                                state);
@@ -927,6 +992,8 @@ static struct tevent_req *vfs_gluster_pwrite_send(struct vfs_handle_struct
         */
        tevent_req_defer_callback(req, ev);
 
+       SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pwrite, profile_p,
+                                    state->profile_bytes, n);
        PROFILE_TIMESTAMP(&state->start);
        ret = glfs_pwrite_async(glfd, data, n, offset, 0, aio_glusterfs_done,
                                state);
@@ -972,29 +1039,47 @@ static ssize_t vfs_gluster_pwrite(struct vfs_handle_struct *handle,
                                  files_struct *fsp, const void *data,
                                  size_t n, off_t offset)
 {
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       ssize_t ret;
+       glfs_fd_t *glfd = NULL;
+
+       START_PROFILE_BYTES(syscall_pwrite, n);
+
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
+               END_PROFILE_BYTES(syscall_pwrite);
                DBG_ERR("Failed to fetch gluster fd\n");
                return -1;
        }
 
 #ifdef HAVE_GFAPI_VER_7_6
-       return glfs_pwrite(glfd, data, n, offset, 0, NULL, NULL);
+       ret = glfs_pwrite(glfd, data, n, offset, 0, NULL, NULL);
 #else
-       return glfs_pwrite(glfd, data, n, offset, 0);
+       ret = glfs_pwrite(glfd, data, n, offset, 0);
 #endif
+       END_PROFILE_BYTES(syscall_pwrite);
+
+       return ret;
 }
 
 static off_t vfs_gluster_lseek(struct vfs_handle_struct *handle,
                               files_struct *fsp, off_t offset, int whence)
 {
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       off_t ret = 0;
+       glfs_fd_t *glfd = NULL;
+
+       START_PROFILE(syscall_lseek);
+
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
+               END_PROFILE(syscall_lseek);
                DBG_ERR("Failed to fetch gluster fd\n");
                return -1;
        }
 
-       return glfs_lseek(glfd, offset, whence);
+       ret = glfs_lseek(glfd, offset, whence);
+       END_PROFILE(syscall_lseek);
+
+       return ret;
 }
 
 static ssize_t vfs_gluster_sendfile(struct vfs_handle_struct *handle, int tofd,
@@ -1020,8 +1105,14 @@ static int vfs_gluster_renameat(struct vfs_handle_struct *handle,
                        files_struct *dstfsp,
                        const struct smb_filename *smb_fname_dst)
 {
-       return glfs_rename(handle->data, smb_fname_src->base_name,
-                          smb_fname_dst->base_name);
+       int ret;
+
+       START_PROFILE(syscall_renameat);
+       ret = glfs_rename(handle->data, smb_fname_src->base_name,
+                         smb_fname_dst->base_name);
+       END_PROFILE(syscall_renameat);
+
+       return ret;
 }
 
 static struct tevent_req *vfs_gluster_fsync_send(struct vfs_handle_struct
@@ -1060,6 +1151,8 @@ static struct tevent_req *vfs_gluster_fsync_send(struct vfs_handle_struct
         */
        tevent_req_defer_callback(req, ev);
 
+       SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync, profile_p,
+                                    state->profile_bytes, 0);
        PROFILE_TIMESTAMP(&state->start);
        ret = glfs_fsync_async(glfd, aio_glusterfs_done, state);
        if (ret < 0) {
@@ -1084,6 +1177,7 @@ static int vfs_gluster_stat(struct vfs_handle_struct *handle,
        struct stat st;
        int ret;
 
+       START_PROFILE(syscall_stat);
        ret = glfs_stat(handle->data, smb_fname->base_name, &st);
        if (ret == 0) {
                smb_stat_ex_from_stat(&smb_fname->st, &st);
@@ -1092,6 +1186,8 @@ static int vfs_gluster_stat(struct vfs_handle_struct *handle,
                DEBUG(0, ("glfs_stat(%s) failed: %s\n",
                          smb_fname->base_name, strerror(errno)));
        }
+       END_PROFILE(syscall_stat);
+
        return ret;
 }
 
@@ -1100,9 +1196,13 @@ static int vfs_gluster_fstat(struct vfs_handle_struct *handle,
 {
        struct stat st;
        int ret;
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       glfs_fd_t *glfd = NULL;
+
+       START_PROFILE(syscall_fstat);
 
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
+               END_PROFILE(syscall_fstat);
                DBG_ERR("Failed to fetch gluster fd\n");
                return -1;
        }
@@ -1115,6 +1215,8 @@ static int vfs_gluster_fstat(struct vfs_handle_struct *handle,
                DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
                          fsp->fh->fd, strerror(errno)));
        }
+       END_PROFILE(syscall_fstat);
+
        return ret;
 }
 
@@ -1124,6 +1226,7 @@ static int vfs_gluster_lstat(struct vfs_handle_struct *handle,
        struct stat st;
        int ret;
 
+       START_PROFILE(syscall_lstat);
        ret = glfs_lstat(handle->data, smb_fname->base_name, &st);
        if (ret == 0) {
                smb_stat_ex_from_stat(&smb_fname->st, &st);
@@ -1132,6 +1235,8 @@ static int vfs_gluster_lstat(struct vfs_handle_struct *handle,
                DEBUG(0, ("glfs_lstat(%s) failed: %s\n",
                          smb_fname->base_name, strerror(errno)));
        }
+       END_PROFILE(syscall_lstat);
+
        return ret;
 }
 
@@ -1139,33 +1244,59 @@ static uint64_t vfs_gluster_get_alloc_size(struct vfs_handle_struct *handle,
                                           files_struct *fsp,
                                           const SMB_STRUCT_STAT *sbuf)
 {
-       return sbuf->st_ex_blocks * 512;
+       uint64_t ret;
+
+       START_PROFILE(syscall_get_alloc_size);
+       ret = sbuf->st_ex_blocks * 512;
+       END_PROFILE(syscall_get_alloc_size);
+
+       return ret;
 }
 
 static int vfs_gluster_unlink(struct vfs_handle_struct *handle,
                              const struct smb_filename *smb_fname)
 {
-       return glfs_unlink(handle->data, smb_fname->base_name);
+       int ret;
+
+       START_PROFILE(syscall_unlink);
+       ret = glfs_unlink(handle->data, smb_fname->base_name);
+       END_PROFILE(syscall_unlink);
+
+       return ret;
 }
 
 static int vfs_gluster_chmod(struct vfs_handle_struct *handle,
                                const struct smb_filename *smb_fname,
                                mode_t mode)
 {
-       return glfs_chmod(handle->data, smb_fname->base_name, mode);
+       int ret;
+
+       START_PROFILE(syscall_chmod);
+       ret = glfs_chmod(handle->data, smb_fname->base_name, mode);
+       END_PROFILE(syscall_chmod);
+
+       return ret;
 }
 
 static int vfs_gluster_fchmod(struct vfs_handle_struct *handle,
                              files_struct *fsp, mode_t mode)
 {
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       int ret;
+       glfs_fd_t *glfd = NULL;
 
+       START_PROFILE(syscall_fchmod);
+
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
+               END_PROFILE(syscall_fchmod);
                DBG_ERR("Failed to fetch gluster fd\n");
                return -1;
        }
 
-       return glfs_fchmod(glfd, mode);
+       ret = glfs_fchmod(glfd, mode);
+       END_PROFILE(syscall_fchmod);
+
+       return ret;
 }
 
 static int vfs_gluster_chown(struct vfs_handle_struct *handle,
@@ -1173,19 +1304,34 @@ static int vfs_gluster_chown(struct vfs_handle_struct *handle,
                        uid_t uid,
                        gid_t gid)
 {
-       return glfs_chown(handle->data, smb_fname->base_name, uid, gid);
+       int ret;
+
+       START_PROFILE(syscall_chown);
+       ret = glfs_chown(handle->data, smb_fname->base_name, uid, gid);
+       END_PROFILE(syscall_chown);
+
+       return ret;
 }
 
 static int vfs_gluster_fchown(struct vfs_handle_struct *handle,
                              files_struct *fsp, uid_t uid, gid_t gid)
 {
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       int ret;
+       glfs_fd_t *glfd = NULL;
+
+       START_PROFILE(syscall_fchown);
+
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
+               END_PROFILE(syscall_fchown);
                DBG_ERR("Failed to fetch gluster fd\n");
                return -1;
        }
 
-       return glfs_fchown(glfd, uid, gid);
+       ret = glfs_fchown(glfd, uid, gid);
+       END_PROFILE(syscall_fchown);
+
+       return ret;
 }
 
 static int vfs_gluster_lchown(struct vfs_handle_struct *handle,
@@ -1193,13 +1339,25 @@ static int vfs_gluster_lchown(struct vfs_handle_struct *handle,
                        uid_t uid,
                        gid_t gid)
 {
-       return glfs_lchown(handle->data, smb_fname->base_name, uid, gid);
+       int ret;
+
+       START_PROFILE(syscall_lchown);
+       ret = glfs_lchown(handle->data, smb_fname->base_name, uid, gid);
+       END_PROFILE(syscall_lchown);
+
+       return ret;
 }
 
 static int vfs_gluster_chdir(struct vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname)
 {
-       return glfs_chdir(handle->data, smb_fname->base_name);
+       int ret;
+
+       START_PROFILE(syscall_chdir);
+       ret = glfs_chdir(handle->data, smb_fname->base_name);
+       END_PROFILE(syscall_chdir);
+
+       return ret;
 }
 
 static struct smb_filename *vfs_gluster_getwd(struct vfs_handle_struct *handle,
@@ -1209,12 +1367,17 @@ static struct smb_filename *vfs_gluster_getwd(struct vfs_handle_struct *handle,
        char *ret;
        struct smb_filename *smb_fname = NULL;
 
+       START_PROFILE(syscall_getwd);
+
        cwd = SMB_CALLOC_ARRAY(char, PATH_MAX);
        if (cwd == NULL) {
+               END_PROFILE(syscall_getwd);
                return NULL;
        }
 
        ret = glfs_getcwd(handle->data, cwd, PATH_MAX - 1);
+       END_PROFILE(syscall_getwd);
+
        if (ret == NULL) {
                SAFE_FREE(cwd);
                return NULL;
@@ -1232,8 +1395,11 @@ static int vfs_gluster_ntimes(struct vfs_handle_struct *handle,
                              const struct smb_filename *smb_fname,
                              struct smb_file_time *ft)
 {
+       int ret = -1;
        struct timespec times[2];
 
+       START_PROFILE(syscall_ntimes);
+
        if (null_timespec(ft->atime)) {
                times[0].tv_sec = smb_fname->st.st_ex_atime.tv_sec;
                times[0].tv_nsec = smb_fname->st.st_ex_atime.tv_nsec;
@@ -1254,26 +1420,39 @@ static int vfs_gluster_ntimes(struct vfs_handle_struct *handle,
                              &smb_fname->st.st_ex_atime) == 0) &&
            (timespec_compare(&times[1],
                              &smb_fname->st.st_ex_mtime) == 0)) {
+               END_PROFILE(syscall_ntimes);
                return 0;
        }
 
-       return glfs_utimens(handle->data, smb_fname->base_name, times);
+       ret = glfs_utimens(handle->data, smb_fname->base_name, times);
+       END_PROFILE(syscall_ntimes);
+
+       return ret;
 }
 
 static int vfs_gluster_ftruncate(struct vfs_handle_struct *handle,
                                 files_struct *fsp, off_t offset)
 {
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       int ret;
+       glfs_fd_t *glfd = NULL;
+
+       START_PROFILE(syscall_ftruncate);
+
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
+               END_PROFILE(syscall_ftruncate);
                DBG_ERR("Failed to fetch gluster fd\n");
                return -1;
        }
 
 #ifdef HAVE_GFAPI_VER_7_6
-       return glfs_ftruncate(glfd, offset, NULL, NULL);
+       ret = glfs_ftruncate(glfd, offset, NULL, NULL);
 #else
-       return glfs_ftruncate(glfd, offset);
+       ret = glfs_ftruncate(glfd, offset);
 #endif
+       END_PROFILE(syscall_ftruncate);
+
+       return ret;
 }
 
 static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
@@ -1281,10 +1460,16 @@ static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
                                 uint32_t mode,
                                 off_t offset, off_t len)
 {
+       int ret;
 #ifdef HAVE_GFAPI_VER_6
+       glfs_fd_t *glfd = NULL;
        int keep_size, punch_hole;
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+
+       START_PROFILE(syscall_fallocate);
+
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
+               END_PROFILE(syscall_fallocate);
                DBG_ERR("Failed to fetch gluster fd\n");
                return -1;
        }
@@ -1294,19 +1479,22 @@ static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
 
        mode &= ~(VFS_FALLOCATE_FL_KEEP_SIZE|VFS_FALLOCATE_FL_PUNCH_HOLE);
        if (mode != 0) {
+               END_PROFILE(syscall_fallocate);
                errno = ENOTSUP;
                return -1;
        }
 
        if (punch_hole) {
-               return glfs_discard(glfd, offset, len);
+               ret = glfs_discard(glfd, offset, len);
        }
 
-       return glfs_fallocate(glfd, keep_size, offset, len);
+       ret = glfs_fallocate(glfd, keep_size, offset, len);
+       END_PROFILE(syscall_fallocate);
 #else
        errno = ENOTSUP;
-       return -1;
+       ret = -1;
 #endif
+       return ret;
 }
 
 static struct smb_filename *vfs_gluster_realpath(struct vfs_handle_struct *handle,
@@ -1315,9 +1503,13 @@ static struct smb_filename *vfs_gluster_realpath(struct vfs_handle_struct *handl
 {
        char *result = NULL;
        struct smb_filename *result_fname = NULL;
-       char *resolved_path = SMB_MALLOC_ARRAY(char, PATH_MAX+1);
+       char *resolved_path = NULL;
 
+       START_PROFILE(syscall_realpath);
+
+       resolved_path = SMB_MALLOC_ARRAY(char, PATH_MAX+1);
        if (resolved_path == NULL) {
+               END_PROFILE(syscall_realpath);
                errno = ENOMEM;
                return NULL;
        }
@@ -1330,6 +1522,8 @@ static struct smb_filename *vfs_gluster_realpath(struct vfs_handle_struct *handl
        }
 
        SAFE_FREE(resolved_path);
+       END_PROFILE(syscall_realpath);
+
        return result_fname;
 }
 
@@ -1339,10 +1533,16 @@ static bool vfs_gluster_lock(struct vfs_handle_struct *handle,
 {
        struct flock flock = { 0, };
        int ret;
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       glfs_fd_t *glfd = NULL;
+       bool ok = false;
+
+       START_PROFILE(syscall_fcntl_lock);
+
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
                DBG_ERR("Failed to fetch gluster fd\n");
-               return false;
+               ok = false;
+               goto out;
        }
 
        flock.l_type = type;
@@ -1357,17 +1557,25 @@ static bool vfs_gluster_lock(struct vfs_handle_struct *handle,
                /* lock query, true if someone else has locked */
                if ((ret != -1) &&
                    (flock.l_type != F_UNLCK) &&
-                   (flock.l_pid != 0) && (flock.l_pid != getpid()))
-                       return true;
+                   (flock.l_pid != 0) && (flock.l_pid != getpid())) {
+                       ok = true;
+                       goto out;
+               }
                /* not me */
-               return false;
+               ok = false;
+               goto out;
        }
 
        if (ret == -1) {
-               return false;
+               ok = false;
+               goto out;
        }
 
-       return true;
+       ok = true;
+out:
+       END_PROFILE(syscall_fcntl_lock);
+
+       return ok;
 }
 
 static int vfs_gluster_kernel_flock(struct vfs_handle_struct *handle,
@@ -1391,8 +1599,13 @@ static bool vfs_gluster_getlock(struct vfs_handle_struct *handle,
 {
        struct flock flock = { 0, };
        int ret;
-       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       glfs_fd_t *glfd = NULL;
+
+       START_PROFILE(syscall_fcntl_getlock);
+
+       glfd = vfs_gluster_fetch_glfd(handle, fsp);
        if (glfd == NULL) {
+               END_PROFILE(syscall_fcntl_getlock);
                DBG_ERR("Failed to fetch gluster fd\n");
                return false;
        }
@@ -1406,6 +1619,7 @@ static bool vfs_gluster_getlock(struct vfs_handle_struct *handle,
        ret = glfs_posix_lock(glfd, F_GETLK, &flock);
 
        if (ret == -1) {
+               END_PROFILE(syscall_fcntl_getlock);
                return false;
        }
 
@@ -1413,6 +1627,7 @@ static bool vfs_gluster_getlock(struct vfs_handle_struct *handle,
        *poffset = flock.l_start;
        *pcount = flock.l_len;
        *ppid = flock.l_pid;
+       END_PROFILE(syscall_fcntl_getlock);
 
        return true;
 }
@@ -1421,9 +1636,15 @@ static int vfs_gluster_symlink(struct vfs_handle_struct *handle,
                                const char *link_target,
                                const struct smb_filename *new_smb_fname)
 {
-       return glfs_symlink(handle->data,
+       int ret;
+
+       START_PROFILE(syscall_symlink);
+       ret = glfs_symlink(handle->data,
                        link_target,
                        new_smb_fname->base_name);
+       END_PROFILE(syscall_symlink);
+
+       return ret;
 }
 
 static int vfs_gluster_readlink(struct vfs_handle_struct *handle,
@@ -1431,16 +1652,28 @@ static int vfs_gluster_readlink(struct vfs_handle_struct *handle,
                                char *buf,
                                size_t bufsiz)
 {
-       return glfs_readlink(handle->data, smb_fname->base_name, buf, bufsiz);
+       int ret;
+
+       START_PROFILE(syscall_readlink);
+       ret = glfs_readlink(handle->data, smb_fname->base_name, buf, bufsiz);
+       END_PROFILE(syscall_readlink);
+
+       return ret;
 }
 
 static int vfs_gluster_link(struct vfs_handle_struct *handle,
                                const struct smb_filename *old_smb_fname,
                                const struct smb_filename *new_smb_fname)
 {
-       return glfs_link(handle->data,
+       int ret;
+
+       START_PROFILE(syscall_link);
+       ret = glfs_link(handle->data,
                        old_smb_fname->base_name,
                        new_smb_fname->base_name);
+       END_PROFILE(syscall_link);
+
+       return ret;
 }
 
 static int vfs_gluster_mknod(struct vfs_handle_struct *handle,
@@ -1448,7 +1681,13 @@ static int vfs_gluster_mknod(struct vfs_handle_struct *handle,
                                mode_t mode,
                                SMB_DEV_T dev)
 {
-       return glfs_mknod(handle->data, smb_fname->base_name, mode, dev);
+       int ret;
+
+       START_PROFILE(syscall_mknod);
+       ret = glfs_mknod(handle->data, smb_fname->base_name, mode, dev);
+       END_PROFILE(syscall_mknod);
+
+       return ret;
 }
 
 static int vfs_gluster_chflags(struct vfs_handle_struct *handle,
@@ -1507,7 +1746,7 @@ static ssize_t vfs_gluster_getxattr(struct vfs_handle_struct *handle,
                                size_t size)
 {
        return glfs_getxattr(handle->data, smb_fname->base_name,
-                       name, value, size);
+                            name, value, size);
 }
 
 static ssize_t vfs_gluster_fgetxattr(struct vfs_handle_struct *handle,