xref: /linux-6.15/include/linux/io_uring.h (revision 33337d03)
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>
7 
8 #if defined(CONFIG_IO_URING)
9 struct sock *io_uring_get_socket(struct file *file);
10 void __io_uring_cancel(bool cancel_all);
11 void __io_uring_free(struct task_struct *tsk);
12 void io_uring_unreg_ringfd(void);
13 const char *io_uring_get_opcode(u8 opcode);
14 
15 static inline void io_uring_files_cancel(void)
16 {
17 	if (current->io_uring) {
18 		io_uring_unreg_ringfd();
19 		__io_uring_cancel(false);
20 	}
21 }
22 static inline void io_uring_task_cancel(void)
23 {
24 	if (current->io_uring)
25 		__io_uring_cancel(true);
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
33 static inline struct sock *io_uring_get_socket(struct file *file)
34 {
35 	return NULL;
36 }
37 static inline void io_uring_task_cancel(void)
38 {
39 }
40 static inline void io_uring_files_cancel(void)
41 {
42 }
43 static inline void io_uring_free(struct task_struct *tsk)
44 {
45 }
46 static inline const char *io_uring_get_opcode(u8 opcode)
47 {
48 	return "";
49 }
50 #endif
51 
52 #endif
53