1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <linux/io_uring_types.h> 4 5 #define IO_POLL_ALLOC_CACHE_MAX 32 6 7 enum { 8 IO_APOLL_OK, 9 IO_APOLL_ABORTED, 10 IO_APOLL_READY 11 }; 12 13 struct io_poll { 14 struct file *file; 15 struct wait_queue_head *head; 16 __poll_t events; 17 int retries; 18 struct wait_queue_entry wait; 19 }; 20 21 struct async_poll { 22 struct io_poll poll; 23 struct io_poll *double_poll; 24 }; 25 26 /* 27 * Must only be called inside issue_flags & IO_URING_F_MULTISHOT, or 28 * potentially other cases where we already "own" this poll request. 29 */ 30 static inline void io_poll_multishot_retry(struct io_kiocb *req) 31 { 32 atomic_inc(&req->poll_refs); 33 } 34 35 int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); 36 int io_poll_add(struct io_kiocb *req, unsigned int issue_flags); 37 38 int io_poll_remove_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); 39 int io_poll_remove(struct io_kiocb *req, unsigned int issue_flags); 40 41 struct io_cancel_data; 42 int io_poll_cancel(struct io_ring_ctx *ctx, struct io_cancel_data *cd, 43 unsigned issue_flags); 44 int io_arm_apoll(struct io_kiocb *req, unsigned issue_flags, __poll_t mask); 45 int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags); 46 bool io_poll_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx, 47 bool cancel_all); 48 49 void io_poll_task_func(struct io_kiocb *req, io_tw_token_t tw); 50