Jens Axboe | 329061d | 2022-05-25 20:31:09 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | |
Jens Axboe | da22bdf | 2024-03-21 07:53:07 -0600 | [diff] [blame] | 3 | #define IO_POLL_ALLOC_CACHE_MAX 32 |
| 4 | |
Jens Axboe | 329061d | 2022-05-25 20:31:09 -0600 | [diff] [blame] | 5 | enum { |
| 6 | IO_APOLL_OK, |
| 7 | IO_APOLL_ABORTED, |
| 8 | IO_APOLL_READY |
| 9 | }; |
| 10 | |
| 11 | struct io_poll { |
| 12 | struct file *file; |
| 13 | struct wait_queue_head *head; |
| 14 | __poll_t events; |
Jens Axboe | c16bda3 | 2023-02-25 12:53:53 -0700 | [diff] [blame] | 15 | int retries; |
Jens Axboe | 329061d | 2022-05-25 20:31:09 -0600 | [diff] [blame] | 16 | struct wait_queue_entry wait; |
| 17 | }; |
| 18 | |
| 19 | struct async_poll { |
Jens Axboe | 414d0f4 | 2024-03-20 15:19:44 -0600 | [diff] [blame] | 20 | struct io_poll poll; |
Jens Axboe | 329061d | 2022-05-25 20:31:09 -0600 | [diff] [blame] | 21 | struct io_poll *double_poll; |
| 22 | }; |
| 23 | |
Jens Axboe | c79f52f | 2024-01-27 13:44:58 -0700 | [diff] [blame] | 24 | /* |
| 25 | * Must only be called inside issue_flags & IO_URING_F_MULTISHOT, or |
| 26 | * potentially other cases where we already "own" this poll request. |
| 27 | */ |
| 28 | static inline void io_poll_multishot_retry(struct io_kiocb *req) |
| 29 | { |
| 30 | atomic_inc(&req->poll_refs); |
| 31 | } |
| 32 | |
Jens Axboe | 329061d | 2022-05-25 20:31:09 -0600 | [diff] [blame] | 33 | int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); |
| 34 | int io_poll_add(struct io_kiocb *req, unsigned int issue_flags); |
| 35 | |
| 36 | int io_poll_remove_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); |
| 37 | int io_poll_remove(struct io_kiocb *req, unsigned int issue_flags); |
| 38 | |
Jens Axboe | ad163a7 | 2022-06-18 19:44:33 -0600 | [diff] [blame] | 39 | struct io_cancel_data; |
Pavel Begunkov | 5d7943d | 2022-06-16 10:22:11 +0100 | [diff] [blame] | 40 | int io_poll_cancel(struct io_ring_ctx *ctx, struct io_cancel_data *cd, |
| 41 | unsigned issue_flags); |
Jens Axboe | 329061d | 2022-05-25 20:31:09 -0600 | [diff] [blame] | 42 | int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags); |
| 43 | bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk, |
| 44 | bool cancel_all); |
Jens Axboe | 9da7471 | 2022-07-07 11:18:33 -0600 | [diff] [blame] | 45 | |
Jens Axboe | c92fcfc | 2023-06-02 08:41:46 -0600 | [diff] [blame] | 46 | void io_poll_task_func(struct io_kiocb *req, struct io_tw_state *ts); |