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 <linux/percpu-refcount.h> 8 9 struct io_uring_task { 10 /* submission side */ 11 struct xarray xa; 12 struct wait_queue_head wait; 13 struct file *last; 14 atomic_long_t req_issue; 15 16 /* completion side */ 17 bool in_idle ____cacheline_aligned_in_smp; 18 atomic_long_t req_complete; 19 }; 20 21 #if defined(CONFIG_IO_URING) 22 struct sock *io_uring_get_socket(struct file *file); 23 void __io_uring_task_cancel(void); 24 void __io_uring_files_cancel(struct files_struct *files); 25 void __io_uring_free(struct task_struct *tsk); 26 27 static inline void io_uring_task_cancel(void) 28 { 29 if (current->io_uring && !xa_empty(¤t->io_uring->xa)) 30 __io_uring_task_cancel(); 31 } 32 static inline void io_uring_files_cancel(struct files_struct *files) 33 { 34 if (current->io_uring && !xa_empty(¤t->io_uring->xa)) 35 __io_uring_files_cancel(files); 36 } 37 static inline void io_uring_free(struct task_struct *tsk) 38 { 39 if (tsk->io_uring) 40 __io_uring_free(tsk); 41 } 42 #else 43 static inline struct sock *io_uring_get_socket(struct file *file) 44 { 45 return NULL; 46 } 47 static inline void io_uring_task_cancel(void) 48 { 49 } 50 static inline void io_uring_files_cancel(struct files_struct *files) 51 { 52 } 53 static inline void io_uring_free(struct task_struct *tsk) 54 { 55 } 56 #endif 57 58 #endif 59