vfs_io_uring: move error handling out of vfs_io_uring_fsync_recv()
authorStefan Metzmacher <metze@samba.org>
Fri, 8 May 2020 08:52:52 +0000 (10:52 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 12 May 2020 19:53:45 +0000 (19:53 +0000)
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 <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_io_uring.c

index a8da341e7b7c5d4ead37a4877361d035abe608ee..0f560c95b67de236d2d501fb171b1e1842ad017c 100644 (file)
@@ -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 = {