mirror of
https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10.git
synced 2026-09-09 00:07:04 +08:00
io_uring/cancel: add generic cancel helper
JIRA: https://issues.redhat.com/browse/RHEL-106845 commit 8fa374f90b721ae5f56605ff67fc94a8b583e10c Author: Jens Axboe <axboe@kernel.dk> Date: Wed Feb 5 13:13:58 2025 -0700 io_uring/cancel: add generic cancel helper Any opcode that is cancelable ends up defining its own cancel helper for finding and canceling a specific request. Add a generic helper that can be used for this purpose. Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
This commit is contained in:
@@ -362,3 +362,24 @@ bool io_cancel_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx,
|
|||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int io_cancel_remove(struct io_ring_ctx *ctx, struct io_cancel_data *cd,
|
||||||
|
unsigned int issue_flags, struct hlist_head *list,
|
||||||
|
bool (*cancel)(struct io_kiocb *))
|
||||||
|
{
|
||||||
|
struct hlist_node *tmp;
|
||||||
|
struct io_kiocb *req;
|
||||||
|
int nr = 0;
|
||||||
|
|
||||||
|
io_ring_submit_lock(ctx, issue_flags);
|
||||||
|
hlist_for_each_entry_safe(req, tmp, list, hash_node) {
|
||||||
|
if (!io_cancel_req_match(req, cd))
|
||||||
|
continue;
|
||||||
|
if (cancel(req))
|
||||||
|
nr++;
|
||||||
|
if (!(cd->flags & IORING_ASYNC_CANCEL_ALL))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
io_ring_submit_unlock(ctx, issue_flags);
|
||||||
|
return nr ?: -ENOENT;
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ bool io_cancel_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx,
|
|||||||
struct hlist_head *list, bool cancel_all,
|
struct hlist_head *list, bool cancel_all,
|
||||||
bool (*cancel)(struct io_kiocb *));
|
bool (*cancel)(struct io_kiocb *));
|
||||||
|
|
||||||
|
int io_cancel_remove(struct io_ring_ctx *ctx, struct io_cancel_data *cd,
|
||||||
|
unsigned int issue_flags, struct hlist_head *list,
|
||||||
|
bool (*cancel)(struct io_kiocb *));
|
||||||
|
|
||||||
static inline bool io_cancel_match_sequence(struct io_kiocb *req, int sequence)
|
static inline bool io_cancel_match_sequence(struct io_kiocb *req, int sequence)
|
||||||
{
|
{
|
||||||
if (req->cancel_seq_set && sequence == req->work.cancel_seq)
|
if (req->cancel_seq_set && sequence == req->work.cancel_seq)
|
||||||
|
|||||||
Reference in New Issue
Block a user