From: Jens Axboe <axboe@kernel.dk>
To: io-uring@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 1/3] io_uring/msg_ring: split fd installing into a helper
Date: Fri, 24 May 2024 16:58:46 -0600 [thread overview]
Message-ID: <20240524230501.20178-2-axboe@kernel.dk> (raw)
In-Reply-To: <20240524230501.20178-1-axboe@kernel.dk>
No functional changes in this patch, just in preparation for needing to
complete the fd install with the ctx lock already held.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
io_uring/msg_ring.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c
index 81c4a9d43729..feff2b0822cf 100644
--- a/io_uring/msg_ring.c
+++ b/io_uring/msg_ring.c
@@ -173,25 +173,23 @@ static struct file *io_msg_grab_file(struct io_kiocb *req, unsigned int issue_fl
return file;
}
-static int io_msg_install_complete(struct io_kiocb *req, unsigned int issue_flags)
+static int __io_msg_install_complete(struct io_kiocb *req)
{
struct io_ring_ctx *target_ctx = req->file->private_data;
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
struct file *src_file = msg->src_file;
int ret;
- if (unlikely(io_double_lock_ctx(target_ctx, issue_flags)))
- return -EAGAIN;
-
ret = __io_fixed_fd_install(target_ctx, src_file, msg->dst_fd);
if (ret < 0)
- goto out_unlock;
+ return ret;
msg->src_file = NULL;
req->flags &= ~REQ_F_NEED_CLEANUP;
if (msg->flags & IORING_MSG_RING_CQE_SKIP)
- goto out_unlock;
+ return ret;
+
/*
* If this fails, the target still received the file descriptor but
* wasn't notified of the fact. This means that if this request
@@ -199,8 +197,20 @@ static int io_msg_install_complete(struct io_kiocb *req, unsigned int issue_flag
* later IORING_OP_MSG_RING delivers the message.
*/
if (!io_post_aux_cqe(target_ctx, msg->user_data, ret, 0))
- ret = -EOVERFLOW;
-out_unlock:
+ return -EOVERFLOW;
+
+ return ret;
+}
+
+static int io_msg_install_complete(struct io_kiocb *req, unsigned int issue_flags)
+{
+ struct io_ring_ctx *target_ctx = req->file->private_data;
+ int ret;
+
+ if (unlikely(io_double_lock_ctx(target_ctx, issue_flags)))
+ return -EAGAIN;
+
+ ret = __io_msg_install_complete(req);
io_double_unlock_ctx(target_ctx);
return ret;
}
--
2.43.0
next prev parent reply other threads:[~2024-05-24 23:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-24 22:58 [PATCHSET 0/3] Improve MSG_RING SINGLE_ISSUER performance Jens Axboe
2024-05-24 22:58 ` Jens Axboe [this message]
2024-05-24 22:58 ` [PATCH 2/3] io_uring/msg_ring: avoid double indirection task_work for data messages Jens Axboe
2024-05-28 13:18 ` Pavel Begunkov
2024-05-28 14:23 ` Jens Axboe
2024-05-28 13:32 ` Pavel Begunkov
2024-05-28 14:23 ` Jens Axboe
2024-05-28 16:23 ` Pavel Begunkov
2024-05-28 17:59 ` Jens Axboe
2024-05-29 2:04 ` Pavel Begunkov
2024-05-29 2:43 ` Jens Axboe
2024-05-24 22:58 ` [PATCH 3/3] io_uring/msg_ring: avoid double indirection task_work for fd passing Jens Axboe
2024-05-28 13:31 ` [PATCHSET 0/3] Improve MSG_RING SINGLE_ISSUER performance Pavel Begunkov
2024-05-28 14:34 ` Jens Axboe
2024-05-28 14:39 ` Jens Axboe
2024-05-28 15:27 ` Jens Axboe
2024-05-28 16:50 ` Pavel Begunkov
2024-05-28 18:07 ` Jens Axboe
2024-05-28 18:31 ` Jens Axboe
2024-05-28 23:04 ` Jens Axboe
2024-05-29 1:35 ` Jens Axboe
2024-05-29 2:08 ` Pavel Begunkov
2024-05-29 2:42 ` 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=20240524230501.20178-2-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.