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 <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
ec65fea5a8
commit
d2b6f48b69
@ -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);
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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);
|
||||
@ -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;
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user