public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>
Subject: [PATCH 13/15] io_uring/net: move connect to always using async data
Date: Tue, 19 Mar 2024 19:17:41 -0600	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Not using an alloc cache, probably not that needed here.

Signed-off-by: Jens Axboe <[email protected]>
---
 io_uring/net.c   | 38 ++++++++++----------------------------
 io_uring/net.h   |  1 -
 io_uring/opdef.c |  1 -
 3 files changed, 10 insertions(+), 30 deletions(-)

diff --git a/io_uring/net.c b/io_uring/net.c
index 82f314da1326..60b8c7f58fd7 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1422,17 +1422,10 @@ int io_socket(struct io_kiocb *req, unsigned int issue_flags)
 	return IOU_OK;
 }
 
-int io_connect_prep_async(struct io_kiocb *req)
-{
-	struct io_async_connect *io = req->async_data;
-	struct io_connect *conn = io_kiocb_to_cmd(req, struct io_connect);
-
-	return move_addr_to_kernel(conn->addr, conn->addr_len, &io->address);
-}
-
 int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
 	struct io_connect *conn = io_kiocb_to_cmd(req, struct io_connect);
+	struct io_async_connect *io;
 
 	if (sqe->len || sqe->buf_index || sqe->rw_flags || sqe->splice_fd_in)
 		return -EINVAL;
@@ -1440,28 +1433,22 @@ int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 	conn->addr = u64_to_user_ptr(READ_ONCE(sqe->addr));
 	conn->addr_len =  READ_ONCE(sqe->addr2);
 	conn->in_progress = conn->seen_econnaborted = false;
-	return 0;
+
+	if (io_alloc_async_data(req))
+		return -ENOMEM;
+
+	io = req->async_data;
+	return move_addr_to_kernel(conn->addr, conn->addr_len, &io->address);
 }
 
 int io_connect(struct io_kiocb *req, unsigned int issue_flags)
 {
 	struct io_connect *connect = io_kiocb_to_cmd(req, struct io_connect);
-	struct io_async_connect __io, *io;
+	struct io_async_connect *io = req->async_data;
 	unsigned file_flags;
 	int ret;
 	bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
 
-	if (req_has_async_data(req)) {
-		io = req->async_data;
-	} else {
-		ret = move_addr_to_kernel(connect->addr,
-						connect->addr_len,
-						&__io.address);
-		if (ret)
-			goto out;
-		io = &__io;
-	}
-
 	file_flags = force_nonblock ? O_NONBLOCK : 0;
 
 	ret = __sys_connect_file(req->file, &io->address,
@@ -1475,13 +1462,6 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
 				goto out;
 			connect->seen_econnaborted = true;
 		}
-		if (req_has_async_data(req))
-			return -EAGAIN;
-		if (io_alloc_async_data(req)) {
-			ret = -ENOMEM;
-			goto out;
-		}
-		memcpy(req->async_data, &__io, sizeof(__io));
 		return -EAGAIN;
 	}
 	if (connect->in_progress) {
@@ -1497,6 +1477,8 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
 	if (ret == -ERESTARTSYS)
 		ret = -EINTR;
 out:
+	kfree(req->async_data);
+	req->flags &= ~REQ_F_ASYNC_DATA;
 	if (ret < 0)
 		req_set_fail(req);
 	io_req_set_res(req, ret, 0);
diff --git a/io_uring/net.h b/io_uring/net.h
index 783dd601a432..9b47d61a9cf3 100644
--- a/io_uring/net.h
+++ b/io_uring/net.h
@@ -55,7 +55,6 @@ int io_accept(struct io_kiocb *req, unsigned int issue_flags);
 int io_socket_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
 int io_socket(struct io_kiocb *req, unsigned int issue_flags);
 
-int io_connect_prep_async(struct io_kiocb *req);
 int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
 int io_connect(struct io_kiocb *req, unsigned int issue_flags);
 
diff --git a/io_uring/opdef.c b/io_uring/opdef.c
index fcae75a08f2c..065c92c57878 100644
--- a/io_uring/opdef.c
+++ b/io_uring/opdef.c
@@ -558,7 +558,6 @@ const struct io_cold_def io_cold_defs[] = {
 		.name			= "CONNECT",
 #if defined(CONFIG_NET)
 		.async_size		= sizeof(struct io_async_connect),
-		.prep_async		= io_connect_prep_async,
 #endif
 	},
 	[IORING_OP_FALLOCATE] = {
-- 
2.43.0


  parent reply	other threads:[~2024-03-20  1:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20  1:17 [PATCHSET 0/15] Get rid of ->prep_async() Jens Axboe
2024-03-20  1:17 ` [PATCH 01/15] io_uring/net: switch io_send() and io_send_zc() to using io_async_msghdr Jens Axboe
2024-03-20  1:17 ` [PATCH 02/15] io_uring/net: switch io_recv() " Jens Axboe
2024-03-20  1:17 ` [PATCH 03/15] io_uring/net: unify cleanup handling Jens Axboe
2024-03-20  1:17 ` [PATCH 04/15] io_uring/net: always setup an io_async_msghdr Jens Axboe
2024-03-20  1:17 ` [PATCH 05/15] io_uring/net: get rid of ->prep_async() for receive side Jens Axboe
2024-03-20  1:17 ` [PATCH 06/15] io_uring/net: get rid of ->prep_async() for send side Jens Axboe
2024-03-20  1:17 ` [PATCH 07/15] io_uring: kill io_msg_alloc_async_prep() Jens Axboe
2024-03-20  1:17 ` [PATCH 08/15] io_uring/net: add iovec recycling Jens Axboe
2024-03-20  1:17 ` [PATCH 09/15] io_uring/net: drop 'kmsg' parameter from io_req_msg_cleanup() Jens Axboe
2024-03-20  1:17 ` [PATCH 10/15] io_uring/rw: always setup io_async_rw for read/write requests Jens Axboe
2024-03-20  1:17 ` [PATCH 11/15] io_uring: get rid of struct io_rw_state Jens Axboe
2024-03-20  1:17 ` [PATCH 12/15] io_uring/rw: add iovec recycling Jens Axboe
2024-03-20  1:17 ` Jens Axboe [this message]
2024-03-20  1:17 ` [PATCH 14/15] io_uring/uring_cmd: switch to always allocating async data Jens Axboe
2024-03-20  1:17 ` [PATCH 15/15] io_uring: drop ->prep_async() 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 \
    [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