Merge tag 'mm-stable-2024-05-24-11-49' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / include / linux / io_uring.h
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 #include <uapi/linux/io_uring.h>
8
9 #if defined(CONFIG_IO_URING)
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 bool io_is_uring_fops(struct file *file);
15
16 static inline void io_uring_files_cancel(void)
17 {
18         if (current->io_uring) {
19                 io_uring_unreg_ringfd();
20                 __io_uring_cancel(false);
21         }
22 }
23 static inline void io_uring_task_cancel(void)
24 {
25         if (current->io_uring)
26                 __io_uring_cancel(true);
27 }
28 static inline void io_uring_free(struct task_struct *tsk)
29 {
30         if (tsk->io_uring)
31                 __io_uring_free(tsk);
32 }
33 #else
34 static inline void io_uring_task_cancel(void)
35 {
36 }
37 static inline void io_uring_files_cancel(void)
38 {
39 }
40 static inline void io_uring_free(struct task_struct *tsk)
41 {
42 }
43 static inline const char *io_uring_get_opcode(u8 opcode)
44 {
45         return "";
46 }
47 static inline bool io_is_uring_fops(struct file *file)
48 {
49         return false;
50 }
51 #endif
52
53 #endif