Skip to content

Commit

Permalink
io_uring: use cancelation match helper for poll and timeout requests
Browse files Browse the repository at this point in the history
Get rid of the request vs io_cancel_data checking and just use the
exported helper for this.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jens Axboe committed Jul 17, 2023
1 parent 3a372b6 commit a30badf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
12 changes: 4 additions & 8 deletions io_uring/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,14 +824,10 @@ static struct io_kiocb *io_poll_file_find(struct io_ring_ctx *ctx,

spin_lock(&hb->lock);
hlist_for_each_entry(req, &hb->list, hash_node) {
if (!(cd->flags & IORING_ASYNC_CANCEL_ANY) &&
req->file != cd->file)
continue;
if (cd->seq == req->work.cancel_seq)
continue;
req->work.cancel_seq = cd->seq;
*out_bucket = hb;
return req;
if (io_cancel_req_match(req, cd)) {
*out_bucket = hb;
return req;
}
}
spin_unlock(&hb->lock);
}
Expand Down
12 changes: 3 additions & 9 deletions io_uring/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,10 @@ static struct io_kiocb *io_timeout_extract(struct io_ring_ctx *ctx,
list_for_each_entry(timeout, &ctx->timeout_list, list) {
struct io_kiocb *tmp = cmd_to_io_kiocb(timeout);

if (!(cd->flags & IORING_ASYNC_CANCEL_ANY) &&
cd->data != tmp->cqe.user_data)
continue;
if (cd->flags & (IORING_ASYNC_CANCEL_ALL|IORING_ASYNC_CANCEL_ANY)) {
if (cd->seq == tmp->work.cancel_seq)
continue;
tmp->work.cancel_seq = cd->seq;
if (io_cancel_req_match(tmp, cd)) {
req = tmp;
break;
}
req = tmp;
break;
}
if (!req)
return ERR_PTR(-ENOENT);
Expand Down

0 comments on commit a30badf

Please sign in to comment.