Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef _LINUX_IO_URING_H
0003 #define _LINUX_IO_URING_H
0004 
0005 #include <linux/sched.h>
0006 #include <linux/xarray.h>
0007 
0008 enum io_uring_cmd_flags {
0009     IO_URING_F_COMPLETE_DEFER   = 1,
0010     IO_URING_F_UNLOCKED     = 2,
0011     /* int's last bit, sign checks are usually faster than a bit test */
0012     IO_URING_F_NONBLOCK     = INT_MIN,
0013 
0014     /* ctx state flags, for URING_CMD */
0015     IO_URING_F_SQE128       = 4,
0016     IO_URING_F_CQE32        = 8,
0017     IO_URING_F_IOPOLL       = 16,
0018 };
0019 
0020 struct io_uring_cmd {
0021     struct file *file;
0022     const void  *cmd;
0023     /* callback to defer completions to task context */
0024     void (*task_work_cb)(struct io_uring_cmd *cmd);
0025     u32     cmd_op;
0026     u32     pad;
0027     u8      pdu[32]; /* available inline for free use */
0028 };
0029 
0030 #if defined(CONFIG_IO_URING)
0031 void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t res2);
0032 void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd,
0033             void (*task_work_cb)(struct io_uring_cmd *));
0034 struct sock *io_uring_get_socket(struct file *file);
0035 void __io_uring_cancel(bool cancel_all);
0036 void __io_uring_free(struct task_struct *tsk);
0037 void io_uring_unreg_ringfd(void);
0038 const char *io_uring_get_opcode(u8 opcode);
0039 
0040 static inline void io_uring_files_cancel(void)
0041 {
0042     if (current->io_uring) {
0043         io_uring_unreg_ringfd();
0044         __io_uring_cancel(false);
0045     }
0046 }
0047 static inline void io_uring_task_cancel(void)
0048 {
0049     if (current->io_uring)
0050         __io_uring_cancel(true);
0051 }
0052 static inline void io_uring_free(struct task_struct *tsk)
0053 {
0054     if (tsk->io_uring)
0055         __io_uring_free(tsk);
0056 }
0057 #else
0058 static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret,
0059         ssize_t ret2)
0060 {
0061 }
0062 static inline void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd,
0063             void (*task_work_cb)(struct io_uring_cmd *))
0064 {
0065 }
0066 static inline struct sock *io_uring_get_socket(struct file *file)
0067 {
0068     return NULL;
0069 }
0070 static inline void io_uring_task_cancel(void)
0071 {
0072 }
0073 static inline void io_uring_files_cancel(void)
0074 {
0075 }
0076 static inline void io_uring_free(struct task_struct *tsk)
0077 {
0078 }
0079 static inline const char *io_uring_get_opcode(u8 opcode)
0080 {
0081     return "";
0082 }
0083 #endif
0084 
0085 #endif