提交 3faa7027 编写于 作者: J Jens Axboe 提交者: Joseph Qi

io_uring: read 'count' for IORING_OP_TIMEOUT in prep handler

to #26323578

commit 26a61679f10c6f041726411964b172565021c2eb upstream.

Add the count field to struct io_timeout, and ensure the prep handler
has read it. Timeout also needs an async context always, set it up
in the prep handler if we don't have one.
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 d1b66a4f
...@@ -330,6 +330,7 @@ struct io_timeout { ...@@ -330,6 +330,7 @@ struct io_timeout {
struct file *file; struct file *file;
u64 addr; u64 addr;
int flags; int flags;
unsigned count;
}; };
struct io_rw { struct io_rw {
...@@ -2898,7 +2899,12 @@ static int io_timeout_prep(struct io_kiocb *req, struct io_async_ctx *io, ...@@ -2898,7 +2899,12 @@ static int io_timeout_prep(struct io_kiocb *req, struct io_async_ctx *io,
if (flags & ~IORING_TIMEOUT_ABS) if (flags & ~IORING_TIMEOUT_ABS)
return -EINVAL; return -EINVAL;
data = &io->timeout; req->timeout.count = READ_ONCE(sqe->off);
if (!io && io_alloc_async_ctx(req))
return -ENOMEM;
data = &req->io->timeout;
data->req = req; data->req = req;
req->flags |= REQ_F_TIMEOUT; req->flags |= REQ_F_TIMEOUT;
...@@ -2916,7 +2922,6 @@ static int io_timeout_prep(struct io_kiocb *req, struct io_async_ctx *io, ...@@ -2916,7 +2922,6 @@ static int io_timeout_prep(struct io_kiocb *req, struct io_async_ctx *io,
static int io_timeout(struct io_kiocb *req) static int io_timeout(struct io_kiocb *req)
{ {
const struct io_uring_sqe *sqe = req->sqe;
unsigned count; unsigned count;
struct io_ring_ctx *ctx = req->ctx; struct io_ring_ctx *ctx = req->ctx;
struct io_timeout_data *data; struct io_timeout_data *data;
...@@ -2938,7 +2943,7 @@ static int io_timeout(struct io_kiocb *req) ...@@ -2938,7 +2943,7 @@ static int io_timeout(struct io_kiocb *req)
* timeout event to be satisfied. If it isn't set, then this is * timeout event to be satisfied. If it isn't set, then this is
* a pure timeout request, sequence isn't used. * a pure timeout request, sequence isn't used.
*/ */
count = READ_ONCE(sqe->off); count = req->timeout.count;
if (!count) { if (!count) {
req->flags |= REQ_F_TIMEOUT_NOSEQ; req->flags |= REQ_F_TIMEOUT_NOSEQ;
spin_lock_irq(&ctx->completion_lock); spin_lock_irq(&ctx->completion_lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册