| 1 | |
| 2 | #ifndef IORING_CANCEL_H
|
| 3 | #define IORING_CANCEL_H
|
| 4 |
|
| 5 | #include <linux/io_uring_types.h>
|
| 6 |
|
| 7 | struct io_cancel_data {
|
| 8 | struct io_ring_ctx *ctx;
|
| 9 | u64 data;
|
| 10 | struct file *file;
|
| 11 | u8 opcode;
|
| 12 | u32 flags;
|
| 13 | int seq;
|
| 14 | };
|
| 15 |
|
| 16 | int io_async_cancel_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
|
| 17 | int io_async_cancel(struct io_kiocb *req, unsigned int issue_flags);
|
| 18 |
|
| 19 | int io_try_cancel(struct io_uring_task *tctx, struct io_cancel_data *cd,
|
| 20 | unsigned int issue_flags);
|
| 21 |
|
| 22 | int io_sync_cancel(struct io_ring_ctx *ctx, void __user *arg);
|
| 23 | bool io_cancel_req_match(struct io_kiocb *req, struct io_cancel_data *cd);
|
| 24 | bool io_match_task_safe(struct io_kiocb *head, struct io_uring_task *tctx,
|
| 25 | bool cancel_all);
|
| 26 |
|
| 27 | bool io_cancel_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx,
|
| 28 | struct hlist_head *list, bool cancel_all,
|
| 29 | bool (*cancel)(struct io_kiocb *));
|
| 30 | int io_cancel_remove(struct io_ring_ctx *ctx, struct io_cancel_data *cd,
|
| 31 | unsigned int issue_flags, struct hlist_head *list,
|
| 32 | bool (*cancel)(struct io_kiocb *));
|
| 33 | __cold bool io_uring_try_cancel_requests(struct io_ring_ctx *ctx,
|
| 34 | struct io_uring_task *tctx,
|
| 35 | bool cancel_all, bool is_sqpoll_thread);
|
| 36 | __cold void io_uring_cancel_generic(bool cancel_all, struct io_sq_data *sqd);
|
| 37 | __cold bool io_cancel_ctx_cb(struct io_wq_work *work, void *data);
|
| 38 |
|
| 39 | static inline bool io_cancel_match_sequence(struct io_kiocb *req, int sequence)
|
| 40 | {
|
| 41 | if (req->cancel_seq_set && sequence == req->work.cancel_seq)
|
| 42 | return true;
|
| 43 |
|
| 44 | req->cancel_seq_set = true;
|
| 45 | req->work.cancel_seq = sequence;
|
| 46 | return false;
|
| 47 | }
|
| 48 |
|
| 49 | #endif
|