Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | #ifndef _LINUX_IO_URING_H |
| 3 | #define _LINUX_IO_URING_H |
| 4 | |
| 5 | #include <linux/sched.h> |
| 6 | #include <linux/xarray.h> |
Jens Axboe | 98447d6 | 2020-10-14 10:48:51 -0600 | [diff] [blame] | 7 | |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 8 | #if defined(CONFIG_IO_URING) |
Jens Axboe | a3ec600 | 2020-09-18 20:41:00 -0600 | [diff] [blame] | 9 | struct sock *io_uring_get_socket(struct file *file); |
Hao Xu | f552a27 | 2021-08-12 12:14:35 +0800 | [diff] [blame] | 10 | void __io_uring_cancel(bool cancel_all); |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 11 | void __io_uring_free(struct task_struct *tsk); |
Jens Axboe | e7a6c00 | 2022-03-04 08:22:22 -0700 | [diff] [blame] | 12 | void io_uring_unreg_ringfd(void); |
Dylan Yudaken | 33337d0 | 2022-04-26 01:29:05 -0700 | [diff] [blame^] | 13 | const char *io_uring_get_opcode(u8 opcode); |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 14 | |
Hao Xu | f552a27 | 2021-08-12 12:14:35 +0800 | [diff] [blame] | 15 | static inline void io_uring_files_cancel(void) |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 16 | { |
Jens Axboe | e7a6c00 | 2022-03-04 08:22:22 -0700 | [diff] [blame] | 17 | if (current->io_uring) { |
| 18 | io_uring_unreg_ringfd(); |
Hao Xu | f552a27 | 2021-08-12 12:14:35 +0800 | [diff] [blame] | 19 | __io_uring_cancel(false); |
Jens Axboe | e7a6c00 | 2022-03-04 08:22:22 -0700 | [diff] [blame] | 20 | } |
Pavel Begunkov | 3f48cf1 | 2021-04-11 01:46:27 +0100 | [diff] [blame] | 21 | } |
| 22 | static inline void io_uring_task_cancel(void) |
| 23 | { |
Hao Xu | a4aadd1 | 2021-08-12 12:14:34 +0800 | [diff] [blame] | 24 | if (current->io_uring) |
Hao Xu | f552a27 | 2021-08-12 12:14:35 +0800 | [diff] [blame] | 25 | __io_uring_cancel(true); |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 26 | } |
| 27 | static inline void io_uring_free(struct task_struct *tsk) |
| 28 | { |
| 29 | if (tsk->io_uring) |
| 30 | __io_uring_free(tsk); |
| 31 | } |
| 32 | #else |
Jens Axboe | a3ec600 | 2020-09-18 20:41:00 -0600 | [diff] [blame] | 33 | static inline struct sock *io_uring_get_socket(struct file *file) |
| 34 | { |
| 35 | return NULL; |
| 36 | } |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 37 | static inline void io_uring_task_cancel(void) |
| 38 | { |
| 39 | } |
Hao Xu | f552a27 | 2021-08-12 12:14:35 +0800 | [diff] [blame] | 40 | static inline void io_uring_files_cancel(void) |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 41 | { |
| 42 | } |
| 43 | static inline void io_uring_free(struct task_struct *tsk) |
| 44 | { |
| 45 | } |
Dylan Yudaken | 33337d0 | 2022-04-26 01:29:05 -0700 | [diff] [blame^] | 46 | static inline const char *io_uring_get_opcode(u8 opcode) |
| 47 | { |
| 48 | return ""; |
| 49 | } |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 50 | #endif |
| 51 | |
| 52 | #endif |