1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef _LINUX_IO_URING_H
3 #define _LINUX_IO_URING_H
5 #include <linux/sched.h>
6 #include <linux/xarray.h>
7 #include <uapi/linux/io_uring.h>
9 enum io_uring_cmd_flags {
10 IO_URING_F_COMPLETE_DEFER = 1,
11 IO_URING_F_UNLOCKED = 2,
12 /* the request is executed from poll, it should not be freed */
13 IO_URING_F_MULTISHOT = 4,
14 /* executed by io-wq */
16 /* int's last bit, sign checks are usually faster than a bit test */
17 IO_URING_F_NONBLOCK = INT_MIN,
19 /* ctx state flags, for URING_CMD */
20 IO_URING_F_SQE128 = (1 << 8),
21 IO_URING_F_CQE32 = (1 << 9),
22 IO_URING_F_IOPOLL = (1 << 10),
27 const struct io_uring_sqe *sqe;
29 /* callback to defer completions to task context */
30 void (*task_work_cb)(struct io_uring_cmd *cmd, unsigned);
31 /* used for polled completion */
36 u8 pdu[32]; /* available inline for free use */
39 static inline const void *io_uring_sqe_cmd(const struct io_uring_sqe *sqe)
44 #if defined(CONFIG_IO_URING)
45 int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
46 struct iov_iter *iter, void *ioucmd);
47 void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t res2,
48 unsigned issue_flags);
49 void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd,
50 void (*task_work_cb)(struct io_uring_cmd *, unsigned));
51 struct sock *io_uring_get_socket(struct file *file);
52 void __io_uring_cancel(bool cancel_all);
53 void __io_uring_free(struct task_struct *tsk);
54 void io_uring_unreg_ringfd(void);
55 const char *io_uring_get_opcode(u8 opcode);
57 static inline void io_uring_files_cancel(void)
59 if (current->io_uring) {
60 io_uring_unreg_ringfd();
61 __io_uring_cancel(false);
64 static inline void io_uring_task_cancel(void)
66 if (current->io_uring)
67 __io_uring_cancel(true);
69 static inline void io_uring_free(struct task_struct *tsk)
75 static inline int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
76 struct iov_iter *iter, void *ioucmd)
80 static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret,
81 ssize_t ret2, unsigned issue_flags)
84 static inline void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd,
85 void (*task_work_cb)(struct io_uring_cmd *, unsigned))
88 static inline struct sock *io_uring_get_socket(struct file *file)
92 static inline void io_uring_task_cancel(void)
95 static inline void io_uring_files_cancel(void)
98 static inline void io_uring_free(struct task_struct *tsk)
101 static inline const char *io_uring_get_opcode(u8 opcode)