vfs_io_uring: split out a vfs_io_uring_pwrite_submit() function
authorStefan Metzmacher <metze@samba.org>
Fri, 8 May 2020 09:17:51 +0000 (11:17 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 12 May 2020 19:53:45 +0000 (19:53 +0000)
This can be reused when we add handling for short writes.

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 19e268e63db47a0e4e86260869cc9f91b849aee1..3e004f48aa0c4090a29444f9b711728dcd68792a 100644 (file)
@@ -514,10 +514,13 @@ static ssize_t vfs_io_uring_pread_recv(struct tevent_req *req,
 
 struct vfs_io_uring_pwrite_state {
        struct vfs_io_uring_request ur;
+       struct files_struct *fsp;
+       off_t offset;
        struct iovec iov;
        size_t nwritten;
 };
 
+static void vfs_io_uring_pwrite_submit(struct vfs_io_uring_pwrite_state *state);
 static void vfs_io_uring_pwrite_completion(struct vfs_io_uring_request *cur,
                                           const char *location);
 
@@ -556,13 +559,11 @@ static struct tevent_req *vfs_io_uring_pwrite_send(struct vfs_handle_struct *han
                return tevent_req_post(req, ev);
        }
 
+       state->fsp = fsp;
+       state->offset = offset;
        state->iov.iov_base = discard_const(data);
        state->iov.iov_len = n;
-       io_uring_prep_writev(&state->ur.sqe,
-                            fsp->fh->fd,
-                            &state->iov, 1,
-                            offset);
-       vfs_io_uring_request_submit(&state->ur);
+       vfs_io_uring_pwrite_submit(state);
 
        if (!tevent_req_is_in_progress(req)) {
                return tevent_req_post(req, ev);
@@ -572,6 +573,15 @@ static struct tevent_req *vfs_io_uring_pwrite_send(struct vfs_handle_struct *han
        return req;
 }
 
+static void vfs_io_uring_pwrite_submit(struct vfs_io_uring_pwrite_state *state)
+{
+       io_uring_prep_writev(&state->ur.sqe,
+                            state->fsp->fh->fd,
+                            &state->iov, 1,
+                            state->offset);
+       vfs_io_uring_request_submit(&state->ur);
+}
+
 static void vfs_io_uring_pwrite_completion(struct vfs_io_uring_request *cur,
                                           const char *location)
 {