io_uring: COW io_identity on mismatch
[linux-2.6-microblaze.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
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;
18         refcount_t                      count;
19 };
20
21 struct io_uring_task {
22         /* submission side */
23         struct xarray           xa;
24         struct wait_queue_head  wait;
25         struct file             *last;
26         atomic_long_t           req_issue;
27
28         /* completion side */
29         bool                    in_idle ____cacheline_aligned_in_smp;
30         atomic_long_t           req_complete;
31 };
32
33 #if defined(CONFIG_IO_URING)
34 struct sock *io_uring_get_socket(struct file *file);
35 void __io_uring_task_cancel(void);
36 void __io_uring_files_cancel(struct files_struct *files);
37 void __io_uring_free(struct task_struct *tsk);
38
39 static inline void io_uring_task_cancel(void)
40 {
41         if (current->io_uring && !xa_empty(&current->io_uring->xa))
42                 __io_uring_task_cancel();
43 }
44 static inline void io_uring_files_cancel(struct files_struct *files)
45 {
46         if (current->io_uring && !xa_empty(&current->io_uring->xa))
47                 __io_uring_files_cancel(files);
48 }
49 static inline void io_uring_free(struct task_struct *tsk)
50 {
51         if (tsk->io_uring)
52                 __io_uring_free(tsk);
53 }
54 #else
55 static inline struct sock *io_uring_get_socket(struct file *file)
56 {
57         return NULL;
58 }
59 static inline void io_uring_task_cancel(void)
60 {
61 }
62 static inline void io_uring_files_cancel(struct files_struct *files)
63 {
64 }
65 static inline void io_uring_free(struct task_struct *tsk)
66 {
67 }
68 #endif
69
70 #endif