Not using an alloc cache, probably not that needed here. Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> --- 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