From: Dylan Yudaken <[email protected]>
To: Jens Axboe <[email protected]>, Pavel Begunkov <[email protected]>
Cc: <[email protected]>, <[email protected]>,
Dylan Yudaken <[email protected]>
Subject: [PATCH for-next 08/12] io_uring: recv/recvmsg retarget_rsrc support
Date: Mon, 31 Oct 2022 06:41:22 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Add can_retarget_rsrc handler for recv/recvmsg
Signed-off-by: Dylan Yudaken <[email protected]>
---
io_uring/net.c | 22 +++++++++++++++++++++-
io_uring/net.h | 1 +
io_uring/opdef.c | 2 ++
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/io_uring/net.c b/io_uring/net.c
index f4638e79a022..0fa05ef52dd3 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -70,6 +70,11 @@ struct io_send_zc_msg {
struct io_kiocb *notif;
};
+struct io_recv_msg {
+ struct io_sr_msg sr;
+ int retarget_fd;
+};
+
#define IO_APOLL_MULTI_POLLED (REQ_F_APOLL_MULTISHOT | REQ_F_POLLED)
@@ -547,7 +552,8 @@ int io_recvmsg_prep_async(struct io_kiocb *req)
int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
{
- struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
+ struct io_recv_msg *rcv = io_kiocb_to_cmd(req, struct io_recv_msg);
+ struct io_sr_msg *sr = &rcv->sr;
if (unlikely(sqe->file_index || sqe->addr2))
return -EINVAL;
@@ -572,6 +578,11 @@ int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
req->flags |= REQ_F_APOLL_MULTISHOT;
}
+ if (req->flags & REQ_F_FIXED_FILE)
+ rcv->retarget_fd = req->cqe.fd;
+ else
+ rcv->retarget_fd = -1;
+
#ifdef CONFIG_COMPAT
if (req->ctx->compat)
sr->msg_flags |= MSG_CMSG_COMPAT;
@@ -709,6 +720,15 @@ static int io_recvmsg_multishot(struct socket *sock, struct io_sr_msg *io,
kmsg->controllen + err;
}
+bool io_recv_can_retarget_rsrc(struct io_kiocb *req)
+{
+ struct io_recv_msg *rcv = io_kiocb_to_cmd(req, struct io_recv_msg);
+
+ if (rcv->retarget_fd < 0)
+ return false;
+ return io_file_peek_fixed(req, rcv->retarget_fd) == req->file;
+}
+
int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
diff --git a/io_uring/net.h b/io_uring/net.h
index 5ffa11bf5d2e..6b5719084494 100644
--- a/io_uring/net.h
+++ b/io_uring/net.h
@@ -43,6 +43,7 @@ int io_recvmsg_prep_async(struct io_kiocb *req);
int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags);
int io_recv(struct io_kiocb *req, unsigned int issue_flags);
+bool io_recv_can_retarget_rsrc(struct io_kiocb *req);
void io_sendrecv_fail(struct io_kiocb *req);
diff --git a/io_uring/opdef.c b/io_uring/opdef.c
index 83dc0f9ad3b2..1a0be5681c7b 100644
--- a/io_uring/opdef.c
+++ b/io_uring/opdef.c
@@ -178,6 +178,7 @@ const struct io_op_def io_op_defs[] = {
.prep_async = io_recvmsg_prep_async,
.cleanup = io_sendmsg_recvmsg_cleanup,
.fail = io_sendrecv_fail,
+ .can_retarget_rsrc = io_recv_can_retarget_rsrc,
#else
.prep = io_eopnotsupp_prep,
#endif
@@ -340,6 +341,7 @@ const struct io_op_def io_op_defs[] = {
.prep = io_recvmsg_prep,
.issue = io_recv,
.fail = io_sendrecv_fail,
+ .can_retarget_rsrc = io_recv_can_retarget_rsrc,
#else
.prep = io_eopnotsupp_prep,
#endif
--
2.30.2
next prev parent reply other threads:[~2022-10-31 13:41 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-31 13:41 [PATCH for-next 00/12] io_uring: retarget rsrc nodes periodically Dylan Yudaken
2022-10-31 13:41 ` [PATCH for-next 01/12] io_uring: infrastructure for retargeting rsrc nodes Dylan Yudaken
2022-10-31 16:02 ` Jens Axboe
2022-10-31 16:45 ` Dylan Yudaken
2022-11-02 11:20 ` Pavel Begunkov
2022-10-31 13:41 ` [PATCH for-next 02/12] io_uring: io-wq helper to iterate all work Dylan Yudaken
2022-10-31 13:41 ` [PATCH for-next 03/12] io_uring: support retargeting rsrc on requests in the io-wq Dylan Yudaken
2022-10-31 18:19 ` Jens Axboe
2022-10-31 13:41 ` [PATCH for-next 04/12] io_uring: reschedule retargeting at shutdown of ring Dylan Yudaken
2022-10-31 16:02 ` Jens Axboe
2022-10-31 16:44 ` Dylan Yudaken
2022-10-31 19:13 ` Jens Axboe
2022-11-01 12:09 ` Dylan Yudaken
2022-10-31 13:41 ` [PATCH for-next 05/12] io_uring: add tracing for io_uring_rsrc_retarget Dylan Yudaken
2022-10-31 13:41 ` [PATCH for-next 06/12] io_uring: add fixed file peeking function Dylan Yudaken
2022-10-31 16:04 ` Jens Axboe
2022-10-31 16:47 ` Dylan Yudaken
2022-11-02 11:23 ` Pavel Begunkov
2022-10-31 13:41 ` [PATCH for-next 07/12] io_uring: split send_zc specific struct out of io_sr_msg Dylan Yudaken
2022-11-02 11:32 ` Pavel Begunkov
2022-11-02 13:45 ` Jens Axboe
2022-11-02 14:09 ` Pavel Begunkov
2022-11-02 14:12 ` Jens Axboe
2022-10-31 13:41 ` Dylan Yudaken [this message]
2022-10-31 13:41 ` [PATCH for-next 09/12] io_uring: accept retarget_rsrc support Dylan Yudaken
2022-10-31 13:41 ` [PATCH for-next 10/12] io_uring: read " Dylan Yudaken
2022-10-31 13:41 ` [PATCH for-next 11/12] io_uring: read_fixed " Dylan Yudaken
2022-10-31 13:41 ` [PATCH for-next 12/12] io_uring: poll_add " Dylan Yudaken
2022-11-02 11:44 ` [PATCH for-next 00/12] io_uring: retarget rsrc nodes periodically Pavel Begunkov
2022-11-02 13:08 ` Dylan Yudaken
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 \
[email protected] \
[email protected] \
[email protected] \
[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