Skip to content

Commit d2b6f48

Browse files
isilenceaxboe
authored andcommitted
io_uring: move send/recv IOPOLL check into prep
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent ec65fea commit d2b6f48

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

fs/io_uring.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3556,6 +3556,9 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
35563556
struct io_async_ctx *io = req->io;
35573557
int ret;
35583558

3559+
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
3560+
return -EINVAL;
3561+
35593562
sr->msg_flags = READ_ONCE(sqe->msg_flags);
35603563
sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr));
35613564
sr->len = READ_ONCE(sqe->len);
@@ -3585,9 +3588,6 @@ static int io_sendmsg(struct io_kiocb *req, bool force_nonblock)
35853588
struct socket *sock;
35863589
int ret;
35873590

3588-
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
3589-
return -EINVAL;
3590-
35913591
sock = sock_from_file(req->file, &ret);
35923592
if (sock) {
35933593
struct io_async_ctx io;
@@ -3641,9 +3641,6 @@ static int io_send(struct io_kiocb *req, bool force_nonblock)
36413641
struct socket *sock;
36423642
int ret;
36433643

3644-
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
3645-
return -EINVAL;
3646-
36473644
sock = sock_from_file(req->file, &ret);
36483645
if (sock) {
36493646
struct io_sr_msg *sr = &req->sr_msg;
@@ -3796,6 +3793,9 @@ static int io_recvmsg_prep(struct io_kiocb *req,
37963793
struct io_async_ctx *io = req->io;
37973794
int ret;
37983795

3796+
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
3797+
return -EINVAL;
3798+
37993799
sr->msg_flags = READ_ONCE(sqe->msg_flags);
38003800
sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr));
38013801
sr->len = READ_ONCE(sqe->len);
@@ -3824,9 +3824,6 @@ static int io_recvmsg(struct io_kiocb *req, bool force_nonblock)
38243824
struct socket *sock;
38253825
int ret, cflags = 0;
38263826

3827-
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
3828-
return -EINVAL;
3829-
38303827
sock = sock_from_file(req->file, &ret);
38313828
if (sock) {
38323829
struct io_buffer *kbuf;
@@ -3888,9 +3885,6 @@ static int io_recv(struct io_kiocb *req, bool force_nonblock)
38883885
struct socket *sock;
38893886
int ret, cflags = 0;
38903887

3891-
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
3892-
return -EINVAL;
3893-
38943888
sock = sock_from_file(req->file, &ret);
38953889
if (sock) {
38963890
struct io_sr_msg *sr = &req->sr_msg;

0 commit comments

Comments
 (0)