Skip to content

Commit

Permalink
vfs_default: fix async fsync idle/busy time profiling
Browse files Browse the repository at this point in the history
Signed-off-by: Ralph Boehme <[email protected]>
Reviewed-by: Stefan Metzmacher <[email protected]>
  • Loading branch information
slowfranklin authored and metze-samba committed Jul 24, 2018
1 parent 580ff20 commit 27bb2cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion source3/include/smbprofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct tevent_context;
SMBPROFILE_STATS_BYTES(syscall_recvfile) \
SMBPROFILE_STATS_BASIC(syscall_rename) \
SMBPROFILE_STATS_BASIC(syscall_rename_at) \
SMBPROFILE_STATS_BASIC(syscall_asys_fsync) \
SMBPROFILE_STATS_BYTES(syscall_asys_fsync) \
SMBPROFILE_STATS_BASIC(syscall_stat) \
SMBPROFILE_STATS_BASIC(syscall_fstat) \
SMBPROFILE_STATS_BASIC(syscall_lstat) \
Expand Down
13 changes: 9 additions & 4 deletions source3/modules/vfs_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ struct vfswrap_fsync_state {
int fd;

struct vfs_aio_state vfs_aio_state;
SMBPROFILE_BASIC_ASYNC_STATE(profile_basic);
SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes);
};

static void vfs_fsync_do(void *private_data);
Expand All @@ -909,8 +909,9 @@ static struct tevent_req *vfswrap_fsync_send(struct vfs_handle_struct *handle,
state->ret = -1;
state->fd = fsp->fh->fd;

SMBPROFILE_BASIC_ASYNC_START(syscall_asys_fsync, profile_p,
state->profile_basic);
SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync, profile_p,
state->profile_bytes, 0);
SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);

subreq = pthreadpool_tevent_job_send(
state, ev, handle->conn->sconn->pool, vfs_fsync_do, state);
Expand All @@ -931,6 +932,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);

PROFILE_TIMESTAMP(&start_time);

do {
Expand All @@ -944,6 +947,8 @@ static void vfs_fsync_do(void *private_data)
PROFILE_TIMESTAMP(&end_time);

state->vfs_aio_state.duration = nsec_time_diff(&end_time, &start_time);

SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);
}

static int vfs_fsync_state_destructor(struct vfswrap_fsync_state *state)
Expand All @@ -961,7 +966,7 @@ static void vfs_fsync_done(struct tevent_req *subreq)

ret = pthreadpool_tevent_job_recv(subreq);
TALLOC_FREE(subreq);
SMBPROFILE_BASIC_ASYNC_END(state->profile_basic);
SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes);
talloc_set_destructor(state, NULL);
if (tevent_req_error(req, ret)) {
return;
Expand Down

0 comments on commit 27bb2cb

Please sign in to comment.