1 | // SPDX-License-Identifier: GPL-2.0 |
---|---|
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 | union { |
10 | u64 data; |
11 | struct file *file; |
12 | }; |
13 | u8 opcode; |
14 | u32 flags; |
15 | int seq; |
16 | }; |
17 | |
18 | int io_async_cancel_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); |
19 | int io_async_cancel(struct io_kiocb *req, unsigned int issue_flags); |
20 | |
21 | int io_try_cancel(struct io_uring_task *tctx, struct io_cancel_data *cd, |
22 | unsigned int issue_flags); |
23 | |
24 | int io_sync_cancel(struct io_ring_ctx *ctx, void __user *arg); |
25 | bool io_cancel_req_match(struct io_kiocb *req, struct io_cancel_data *cd); |
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 | |
31 | int io_cancel_remove(struct io_ring_ctx *ctx, struct io_cancel_data *cd, |
32 | unsigned int issue_flags, struct hlist_head *list, |
33 | bool (*cancel)(struct io_kiocb *)); |
34 | |
35 | static inline bool io_cancel_match_sequence(struct io_kiocb *req, int sequence) |
36 | { |
37 | if (req->cancel_seq_set && sequence == req->work.cancel_seq) |
38 | return true; |
39 | |
40 | req->cancel_seq_set = true; |
41 | req->work.cancel_seq = sequence; |
42 | return false; |
43 | } |
44 | |
45 | #endif |
46 |