From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 3/3] io_uring: extract io_sendmsg_copy_hdr()
Date: Sun, 12 Jul 2020 20:41:06 +0300 [thread overview]
Message-ID: <b69243e4f5016746f5af932a54dfda0216e8ed0e.1594571075.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Don't repeat send msg initialisation code, it's error prone.
Extract and use a helper function.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index b496aebd6285..d87751f7b5ba 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3889,6 +3889,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;
@@ -3913,10 +3922,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;
@@ -3942,12 +3948,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;
--
2.24.0
next prev parent reply other threads:[~2020-07-12 17:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-12 17:41 [PATCH 5.9 0/3] send/recv msghdr init cleanups Pavel Begunkov
2020-07-12 17:41 ` [PATCH 1/3] io_uring: rename sr->msg into umsg Pavel Begunkov
2020-07-12 17:41 ` [PATCH 2/3] io_uring: use more specific type in rcv/snd msg cp Pavel Begunkov
2020-07-12 17:41 ` Pavel Begunkov [this message]
2020-07-12 20:26 ` [PATCH 5.9 0/3] send/recv msghdr init cleanups Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b69243e4f5016746f5af932a54dfda0216e8ed0e.1594571075.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox