Skip to content

Commit

Permalink
io_uring: move send/recv IOPOLL check into prep
Browse files Browse the repository at this point in the history
Fail recv/send in case of IORING_SETUP_IOPOLL earlier during prep,
so it'd be done only once. Removes duplication as well

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Pavel Begunkov authored and Jens Axboe committed Jun 4, 2020
1 parent ec65fea commit d2b6f48
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -3556,6 +3556,9 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
struct io_async_ctx *io = req->io;
int ret;

if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;

sr->msg_flags = READ_ONCE(sqe->msg_flags);
sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr));
sr->len = READ_ONCE(sqe->len);
Expand Down Expand Up @@ -3585,9 +3588,6 @@ static int io_sendmsg(struct io_kiocb *req, bool force_nonblock)
struct socket *sock;
int ret;

if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;

sock = sock_from_file(req->file, &ret);
if (sock) {
struct io_async_ctx io;
Expand Down Expand Up @@ -3641,9 +3641,6 @@ static int io_send(struct io_kiocb *req, bool force_nonblock)
struct socket *sock;
int ret;

if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;

sock = sock_from_file(req->file, &ret);
if (sock) {
struct io_sr_msg *sr = &req->sr_msg;
Expand Down Expand Up @@ -3796,6 +3793,9 @@ static int io_recvmsg_prep(struct io_kiocb *req,
struct io_async_ctx *io = req->io;
int ret;

if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;

sr->msg_flags = READ_ONCE(sqe->msg_flags);
sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr));
sr->len = READ_ONCE(sqe->len);
Expand Down Expand Up @@ -3824,9 +3824,6 @@ static int io_recvmsg(struct io_kiocb *req, bool force_nonblock)
struct socket *sock;
int ret, cflags = 0;

if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;

sock = sock_from_file(req->file, &ret);
if (sock) {
struct io_buffer *kbuf;
Expand Down Expand Up @@ -3888,9 +3885,6 @@ static int io_recv(struct io_kiocb *req, bool force_nonblock)
struct socket *sock;
int ret, cflags = 0;

if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;

sock = sock_from_file(req->file, &ret);
if (sock) {
struct io_sr_msg *sr = &req->sr_msg;
Expand Down

0 comments on commit d2b6f48

Please sign in to comment.