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 | |
| 8 | struct io_identity { |
| 9 | struct files_struct *files; |
| 10 | struct mm_struct *mm; |
| 11 | #ifdef CONFIG_BLK_CGROUP |
| 12 | struct cgroup_subsys_state *blkcg_css; |
| 13 | #endif |
| 14 | const struct cred *creds; |
| 15 | struct nsproxy *nsproxy; |
| 16 | struct fs_struct *fs; |
| 17 | unsigned long fsize; |
Jens Axboe | 4ea33a9 | 2020-10-15 13:46:44 -0600 | [diff] [blame] | 18 | #ifdef CONFIG_AUDIT |
| 19 | kuid_t loginuid; |
| 20 | unsigned int sessionid; |
| 21 | #endif |
Jens Axboe | 1e6fa52 | 2020-10-15 08:46:24 -0600 | [diff] [blame] | 22 | refcount_t count; |
Jens Axboe | 98447d6 | 2020-10-14 10:48:51 -0600 | [diff] [blame] | 23 | }; |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 24 | |
| 25 | struct io_uring_task { |
| 26 | /* submission side */ |
| 27 | struct xarray xa; |
| 28 | struct wait_queue_head wait; |
| 29 | struct file *last; |
Jens Axboe | d8a6df1 | 2020-10-15 16:24:45 -0600 | [diff] [blame] | 30 | struct percpu_counter inflight; |
Jens Axboe | 500a373 | 2020-10-15 17:38:03 -0600 | [diff] [blame] | 31 | struct io_identity __identity; |
| 32 | struct io_identity *identity; |
Jens Axboe | fdaf083 | 2020-10-30 09:37:30 -0600 | [diff] [blame] | 33 | atomic_t in_idle; |
| 34 | bool sqpoll; |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | #if defined(CONFIG_IO_URING) |
Jens Axboe | a3ec600 | 2020-09-18 20:41:00 -0600 | [diff] [blame] | 38 | struct sock *io_uring_get_socket(struct file *file); |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 39 | void __io_uring_task_cancel(void); |
| 40 | void __io_uring_files_cancel(struct files_struct *files); |
| 41 | void __io_uring_free(struct task_struct *tsk); |
| 42 | |
| 43 | static inline void io_uring_task_cancel(void) |
| 44 | { |
| 45 | if (current->io_uring && !xa_empty(¤t->io_uring->xa)) |
| 46 | __io_uring_task_cancel(); |
| 47 | } |
| 48 | static inline void io_uring_files_cancel(struct files_struct *files) |
| 49 | { |
| 50 | if (current->io_uring && !xa_empty(¤t->io_uring->xa)) |
| 51 | __io_uring_files_cancel(files); |
| 52 | } |
| 53 | static inline void io_uring_free(struct task_struct *tsk) |
| 54 | { |
| 55 | if (tsk->io_uring) |
| 56 | __io_uring_free(tsk); |
| 57 | } |
| 58 | #else |
Jens Axboe | a3ec600 | 2020-09-18 20:41:00 -0600 | [diff] [blame] | 59 | static inline struct sock *io_uring_get_socket(struct file *file) |
| 60 | { |
| 61 | return NULL; |
| 62 | } |
Jens Axboe | 0f21220 | 2020-09-13 13:09:39 -0600 | [diff] [blame] | 63 | static inline void io_uring_task_cancel(void) |
| 64 | { |
| 65 | } |
| 66 | static inline void io_uring_files_cancel(struct files_struct *files) |
| 67 | { |
| 68 | } |
| 69 | static inline void io_uring_free(struct task_struct *tsk) |
| 70 | { |
| 71 | } |
| 72 | #endif |
| 73 | |
| 74 | #endif |