LCOV - code coverage report
Current view: top level - include/linux - io_uring.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 4 9 44.4 %
Date: 2023-03-27 20:00:47 Functions: 1 1 100.0 %

          Line data    Source code
       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             : #include <uapi/linux/io_uring.h>
       8             : 
       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 */
      15             :         IO_URING_F_IOWQ                 = 8,
      16             :         /* int's last bit, sign checks are usually faster than a bit test */
      17             :         IO_URING_F_NONBLOCK             = INT_MIN,
      18             : 
      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),
      23             : };
      24             : 
      25             : struct io_uring_cmd {
      26             :         struct file     *file;
      27             :         const void      *cmd;
      28             :         union {
      29             :                 /* callback to defer completions to task context */
      30             :                 void (*task_work_cb)(struct io_uring_cmd *cmd);
      31             :                 /* used for polled completion */
      32             :                 void *cookie;
      33             :         };
      34             :         u32             cmd_op;
      35             :         u32             flags;
      36             :         u8              pdu[32]; /* available inline for free use */
      37             : };
      38             : 
      39             : #if defined(CONFIG_IO_URING)
      40             : int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
      41             :                               struct iov_iter *iter, void *ioucmd);
      42             : void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t res2);
      43             : void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd,
      44             :                         void (*task_work_cb)(struct io_uring_cmd *));
      45             : struct sock *io_uring_get_socket(struct file *file);
      46             : void __io_uring_cancel(bool cancel_all);
      47             : void __io_uring_free(struct task_struct *tsk);
      48             : void io_uring_unreg_ringfd(void);
      49             : const char *io_uring_get_opcode(u8 opcode);
      50             : 
      51         325 : static inline void io_uring_files_cancel(void)
      52             : {
      53         325 :         if (current->io_uring) {
      54           0 :                 io_uring_unreg_ringfd();
      55           0 :                 __io_uring_cancel(false);
      56             :         }
      57         325 : }
      58             : static inline void io_uring_task_cancel(void)
      59             : {
      60           0 :         if (current->io_uring)
      61           0 :                 __io_uring_cancel(true);
      62             : }
      63             : static inline void io_uring_free(struct task_struct *tsk)
      64             : {
      65         324 :         if (tsk->io_uring)
      66           0 :                 __io_uring_free(tsk);
      67             : }
      68             : #else
      69             : static inline int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
      70             :                               struct iov_iter *iter, void *ioucmd)
      71             : {
      72             :         return -EOPNOTSUPP;
      73             : }
      74             : static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret,
      75             :                 ssize_t ret2)
      76             : {
      77             : }
      78             : static inline void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd,
      79             :                         void (*task_work_cb)(struct io_uring_cmd *))
      80             : {
      81             : }
      82             : static inline struct sock *io_uring_get_socket(struct file *file)
      83             : {
      84             :         return NULL;
      85             : }
      86             : static inline void io_uring_task_cancel(void)
      87             : {
      88             : }
      89             : static inline void io_uring_files_cancel(void)
      90             : {
      91             : }
      92             : static inline void io_uring_free(struct task_struct *tsk)
      93             : {
      94             : }
      95             : static inline const char *io_uring_get_opcode(u8 opcode)
      96             : {
      97             :         return "";
      98             : }
      99             : #endif
     100             : 
     101             : #endif

Generated by: LCOV version 1.14