提交 30ab13bc 编写于 作者: J Jens Axboe 提交者: Shile Zhang

io_uring: abstract out io_async_cancel_one() helper

commit e977d6d34f0c08e3c3b132c9e73b98d0db50abc1 upstream.

We're going to need this helper in a future patch, so move it out
of io_async_cancel() and into its own separate function.

No functional changes in this patch.
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 007dcf2e
...@@ -2152,21 +2152,11 @@ static bool io_cancel_cb(struct io_wq_work *work, void *data) ...@@ -2152,21 +2152,11 @@ static bool io_cancel_cb(struct io_wq_work *work, void *data)
return req->user_data == (unsigned long) data; return req->user_data == (unsigned long) data;
} }
static int io_async_cancel(struct io_kiocb *req, const struct io_uring_sqe *sqe, static int io_async_cancel_one(struct io_ring_ctx *ctx, void *sqe_addr)
struct io_kiocb **nxt)
{ {
struct io_ring_ctx *ctx = req->ctx;
enum io_wq_cancel cancel_ret; enum io_wq_cancel cancel_ret;
void *sqe_addr;
int ret = 0; int ret = 0;
if (unlikely(ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
if (sqe->flags || sqe->ioprio || sqe->off || sqe->len ||
sqe->cancel_flags)
return -EINVAL;
sqe_addr = (void *) (unsigned long) READ_ONCE(sqe->addr);
cancel_ret = io_wq_cancel_cb(ctx->io_wq, io_cancel_cb, sqe_addr); cancel_ret = io_wq_cancel_cb(ctx->io_wq, io_cancel_cb, sqe_addr);
switch (cancel_ret) { switch (cancel_ret) {
case IO_WQ_CANCEL_OK: case IO_WQ_CANCEL_OK:
...@@ -2180,6 +2170,25 @@ static int io_async_cancel(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -2180,6 +2170,25 @@ static int io_async_cancel(struct io_kiocb *req, const struct io_uring_sqe *sqe,
break; break;
} }
return ret;
}
static int io_async_cancel(struct io_kiocb *req, const struct io_uring_sqe *sqe,
struct io_kiocb **nxt)
{
struct io_ring_ctx *ctx = req->ctx;
void *sqe_addr;
int ret;
if (unlikely(ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
if (sqe->flags || sqe->ioprio || sqe->off || sqe->len ||
sqe->cancel_flags)
return -EINVAL;
sqe_addr = (void *) (unsigned long) READ_ONCE(sqe->addr);
ret = io_async_cancel_one(ctx, sqe_addr);
if (ret < 0 && (req->flags & REQ_F_LINK)) if (ret < 0 && (req->flags & REQ_F_LINK))
req->flags |= REQ_F_FAIL_LINK; req->flags |= REQ_F_FAIL_LINK;
io_cqring_add_event(req->ctx, sqe->user_data, ret); io_cqring_add_event(req->ctx, sqe->user_data, ret);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册