blob: b0e3745f5a29b9ab0f8e1901af9abe3906c4e956 [file] [log] [blame]
Jens Axboe329061d2022-05-25 20:31:09 -06001// SPDX-License-Identifier: GPL-2.0
2
Jens Axboeda22bdf2024-03-21 07:53:07 -06003#define IO_POLL_ALLOC_CACHE_MAX 32
4
Jens Axboe329061d2022-05-25 20:31:09 -06005enum {
6 IO_APOLL_OK,
7 IO_APOLL_ABORTED,
8 IO_APOLL_READY
9};
10
11struct io_poll {
12 struct file *file;
13 struct wait_queue_head *head;
14 __poll_t events;
Jens Axboec16bda32023-02-25 12:53:53 -070015 int retries;
Jens Axboe329061d2022-05-25 20:31:09 -060016 struct wait_queue_entry wait;
17};
18
19struct async_poll {
Jens Axboe414d0f42024-03-20 15:19:44 -060020 struct io_poll poll;
Jens Axboe329061d2022-05-25 20:31:09 -060021 struct io_poll *double_poll;
22};
23
Jens Axboec79f52f2024-01-27 13:44:58 -070024/*
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 */
28static inline void io_poll_multishot_retry(struct io_kiocb *req)
29{
30 atomic_inc(&req->poll_refs);
31}
32
Jens Axboe329061d2022-05-25 20:31:09 -060033int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
34int io_poll_add(struct io_kiocb *req, unsigned int issue_flags);
35
36int io_poll_remove_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
37int io_poll_remove(struct io_kiocb *req, unsigned int issue_flags);
38
Jens Axboead163a72022-06-18 19:44:33 -060039struct io_cancel_data;
Pavel Begunkov5d7943d2022-06-16 10:22:11 +010040int io_poll_cancel(struct io_ring_ctx *ctx, struct io_cancel_data *cd,
41 unsigned issue_flags);
Jens Axboe329061d2022-05-25 20:31:09 -060042int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags);
43bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk,
44 bool cancel_all);
Jens Axboe9da74712022-07-07 11:18:33 -060045
Jens Axboec92fcfc2023-06-02 08:41:46 -060046void io_poll_task_func(struct io_kiocb *req, struct io_tw_state *ts);