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>
8 enum io_uring_cmd_flags {
9 IO_URING_F_COMPLETE_DEFER = 1,
10 IO_URING_F_UNLOCKED = 2,
11 /* int's last bit, sign checks are usually faster than a bit test */
12 IO_URING_F_NONBLOCK = INT_MIN,
14 /* ctx state flags, for URING_CMD */
15 IO_URING_F_SQE128 = 4,
17 IO_URING_F_IOPOLL = 16,
23 /* callback to defer completions to task context */
24 void (*task_work_cb)(struct io_uring_cmd *cmd);
27 u8 pdu[32]; /* available inline for free use */
30 #if defined(CONFIG_IO_URING)
31 void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t res2);
32 void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd,
33 void (*task_work_cb)(struct io_uring_cmd *));
34 struct sock *io_uring_get_socket(struct file *file);
35 void __io_uring_cancel(bool cancel_all);
36 void __io_uring_free(struct task_struct *tsk);
37 void io_uring_unreg_ringfd(void);
38 const char *io_uring_get_opcode(u8 opcode);
40 static inline void io_uring_files_cancel(void)
42 if (current->io_uring) {
43 io_uring_unreg_ringfd();
44 __io_uring_cancel(false);
47 static inline void io_uring_task_cancel(void)
49 if (current->io_uring)
50 __io_uring_cancel(true);
52 static inline void io_uring_free(struct task_struct *tsk)
58 static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret,
62 static inline void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd,
63 void (*task_work_cb)(struct io_uring_cmd *))
66 static inline struct sock *io_uring_get_socket(struct file *file)
70 static inline void io_uring_task_cancel(void)
73 static inline void io_uring_files_cancel(void)
76 static inline void io_uring_free(struct task_struct *tsk)
79 static inline const char *io_uring_get_opcode(u8 opcode)