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 struct sock *io_uring_get_socket(struct file *file); 11 void __io_uring_cancel(bool cancel_all); 12 void __io_uring_free(struct task_struct *tsk); 13 void io_uring_unreg_ringfd(void); 14 const char *io_uring_get_opcode(u8 opcode); 15 int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags); 16 17 static inline void io_uring_files_cancel(void) 18 { 19 if (current->io_uring) { 20 io_uring_unreg_ringfd(); 21 __io_uring_cancel(false); 22 } 23 } 24 static inline void io_uring_task_cancel(void) 25 { 26 if (current->io_uring) 27 __io_uring_cancel(true); 28 } 29 static inline void io_uring_free(struct task_struct *tsk) 30 { 31 if (tsk->io_uring) 32 __io_uring_free(tsk); 33 } 34 #else 35 static inline struct sock *io_uring_get_socket(struct file *file) 36 { 37 return NULL; 38 } 39 static inline void io_uring_task_cancel(void) 40 { 41 } 42 static inline void io_uring_files_cancel(void) 43 { 44 } 45 static inline void io_uring_free(struct task_struct *tsk) 46 { 47 } 48 static inline const char *io_uring_get_opcode(u8 opcode) 49 { 50 return ""; 51 } 52 static inline int io_uring_cmd_sock(struct io_uring_cmd *cmd, 53 unsigned int issue_flags) 54 { 55 return -EOPNOTSUPP; 56 } 57 #endif 58 59 #endif 60