summaryrefslogtreecommitdiffstats
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2020-07-12 20:41:06 +0300
committerJens Axboe <axboe@kernel.dk>2020-07-24 12:55:44 -0600
commit2ae523ed07f14391d685651f671a7858fe8c368a (patch)
tree8914a2ef0033af4c56501fd57e092829711ca225 /fs/io_uring.c
parent1400e69705baf98d1c9cb73b592a3a68aab1d852 (diff)
downloadlinux-2ae523ed07f14391d685651f671a7858fe8c368a.tar.bz2
io_uring: extract io_sendmsg_copy_hdr()
Don't repeat send msg initialisation code, it's error prone. Extract and use a helper function. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 8acbaddaebb7..a198466544e7 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3893,6 +3893,15 @@ static int io_setup_async_msg(struct io_kiocb *req,
return -EAGAIN;
}
+static int io_sendmsg_copy_hdr(struct io_kiocb *req,
+ struct io_async_msghdr *iomsg)
+{
+ iomsg->iov = iomsg->fast_iov;
+ iomsg->msg.msg_name = &iomsg->addr;
+ return sendmsg_copy_msghdr(&iomsg->msg, req->sr_msg.umsg,
+ req->sr_msg.msg_flags, &iomsg->iov);
+}
+
static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
{
struct io_sr_msg *sr = &req->sr_msg;
@@ -3917,10 +3926,7 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (req->flags & REQ_F_NEED_CLEANUP)
return 0;
- io->msg.msg.msg_name = &io->msg.addr;
- io->msg.iov = io->msg.fast_iov;
- ret = sendmsg_copy_msghdr(&io->msg.msg, sr->umsg, sr->msg_flags,
- &io->msg.iov);
+ ret = io_sendmsg_copy_hdr(req, &io->msg);
if (!ret)
req->flags |= REQ_F_NEED_CLEANUP;
return ret;
@@ -3946,12 +3952,7 @@ static int io_sendmsg(struct io_kiocb *req, bool force_nonblock,
kmsg->iov = kmsg->fast_iov;
kmsg->msg.msg_iter.iov = kmsg->iov;
} else {
- struct io_sr_msg *sr = &req->sr_msg;
-
- iomsg.msg.msg_name = &iomsg.addr;
- iomsg.iov = iomsg.fast_iov;
- ret = sendmsg_copy_msghdr(&iomsg.msg, sr->umsg,
- sr->msg_flags, &iomsg.iov);
+ ret = io_sendmsg_copy_hdr(req, &iomsg);
if (ret)
return ret;
kmsg = &iomsg;