From 2588cf0d711147f256bb485f152b8ff91c632478 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 8 May 2020 10:52:52 +0200 Subject: [PATCH] vfs_io_uring: move error handling out of vfs_io_uring_fsync_recv() We should do that as early as possible and that's in vfs_io_uring_fsync_completion(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361 Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison (cherry picked from commit 40be2232a44a86cb5dfdda330801e615826408ba) --- source3/modules/vfs_io_uring.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/source3/modules/vfs_io_uring.c b/source3/modules/vfs_io_uring.c index a8da341e7b7..0f560c95b67 100644 --- a/source3/modules/vfs_io_uring.c +++ b/source3/modules/vfs_io_uring.c @@ -556,7 +556,14 @@ static void vfs_io_uring_fsync_completion(struct vfs_io_uring_request *cur, * or tevent_req_defer_callback() being called * already. */ - _tevent_req_done(cur->req, location); + + if (cur->cqe.res < 0) { + int err = -cur->cqe.res; + _tevent_req_error(cur->req, err, location); + return; + } + + tevent_req_done(cur->req); } static int vfs_io_uring_fsync_recv(struct tevent_req *req, @@ -564,26 +571,20 @@ static int vfs_io_uring_fsync_recv(struct tevent_req *req, { struct vfs_io_uring_fsync_state *state = tevent_req_data( req, struct vfs_io_uring_fsync_state); - int ret; SMBPROFILE_BYTES_ASYNC_END(state->ur.profile_bytes); vfs_aio_state->duration = nsec_time_diff(&state->ur.end_time, &state->ur.start_time); if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) { + tevent_req_received(req); return -1; } - if (state->ur.cqe.res < 0) { - vfs_aio_state->error = -state->ur.cqe.res; - ret = -1; - } else { - vfs_aio_state->error = 0; - ret = state->ur.cqe.res; - } + vfs_aio_state->error = 0; tevent_req_received(req); - return ret; + return 0; } static struct vfs_fn_pointers vfs_io_uring_fns = { -- 2.11.4.GIT