提交 43770e26 编写于 作者: P Pavel Begunkov 提交者: Xiaoguang Wang

io_uring: move send/recv IOPOLL check into prep

to #28736503

commit d2b6f48b691ed67569786c332f0173b918d3fd1b upstream

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: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 6ead77bf
...@@ -3547,6 +3547,9 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -3547,6 +3547,9 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
struct io_async_ctx *io = req->io; struct io_async_ctx *io = req->io;
int ret; int ret;
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
sr->msg_flags = READ_ONCE(sqe->msg_flags); sr->msg_flags = READ_ONCE(sqe->msg_flags);
sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr)); sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr));
sr->len = READ_ONCE(sqe->len); sr->len = READ_ONCE(sqe->len);
...@@ -3576,9 +3579,6 @@ static int io_sendmsg(struct io_kiocb *req, bool force_nonblock) ...@@ -3576,9 +3579,6 @@ static int io_sendmsg(struct io_kiocb *req, bool force_nonblock)
struct socket *sock; struct socket *sock;
int ret; int ret;
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
sock = sock_from_file(req->file, &ret); sock = sock_from_file(req->file, &ret);
if (sock) { if (sock) {
struct io_async_ctx io; struct io_async_ctx io;
...@@ -3632,9 +3632,6 @@ static int io_send(struct io_kiocb *req, bool force_nonblock) ...@@ -3632,9 +3632,6 @@ static int io_send(struct io_kiocb *req, bool force_nonblock)
struct socket *sock; struct socket *sock;
int ret; int ret;
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
sock = sock_from_file(req->file, &ret); sock = sock_from_file(req->file, &ret);
if (sock) { if (sock) {
struct io_sr_msg *sr = &req->sr_msg; struct io_sr_msg *sr = &req->sr_msg;
...@@ -3787,6 +3784,9 @@ static int io_recvmsg_prep(struct io_kiocb *req, ...@@ -3787,6 +3784,9 @@ static int io_recvmsg_prep(struct io_kiocb *req,
struct io_async_ctx *io = req->io; struct io_async_ctx *io = req->io;
int ret; int ret;
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
sr->msg_flags = READ_ONCE(sqe->msg_flags); sr->msg_flags = READ_ONCE(sqe->msg_flags);
sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr)); sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr));
sr->len = READ_ONCE(sqe->len); sr->len = READ_ONCE(sqe->len);
...@@ -3815,9 +3815,6 @@ static int io_recvmsg(struct io_kiocb *req, bool force_nonblock) ...@@ -3815,9 +3815,6 @@ static int io_recvmsg(struct io_kiocb *req, bool force_nonblock)
struct socket *sock; struct socket *sock;
int ret, cflags = 0; int ret, cflags = 0;
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
sock = sock_from_file(req->file, &ret); sock = sock_from_file(req->file, &ret);
if (sock) { if (sock) {
struct io_buffer *kbuf; struct io_buffer *kbuf;
...@@ -3879,9 +3876,6 @@ static int io_recv(struct io_kiocb *req, bool force_nonblock) ...@@ -3879,9 +3876,6 @@ static int io_recv(struct io_kiocb *req, bool force_nonblock)
struct socket *sock; struct socket *sock;
int ret, cflags = 0; int ret, cflags = 0;
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
sock = sock_from_file(req->file, &ret); sock = sock_from_file(req->file, &ret);
if (sock) { if (sock) {
struct io_sr_msg *sr = &req->sr_msg; struct io_sr_msg *sr = &req->sr_msg;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册