Pull io_uring updates from Jens Axboe: "Mostly just come fixes and cleanups, but one feature as well. In detail: - Harden the check for handling IOPOLL based on return (Pavel) - Various minor optimizations (Pavel) - Drop remnants of SCM_RIGHTS fd passing support, now that it's no longer supported since 6.7 (me) - Fix for a case where bytes_done wasn't initialized properly on a failure condition for read/write requests (me) - Move the register related code to a separate file (me) - Add support for returning the provided ring buffer head (me) - Add support for adding a direct descriptor to the normal file table (me, Christian Brauner) - Fix for ensuring pending task_work for a ring with DEFER_TASKRUN is run even if we timeout waiting (me)" * tag 'for-6.8/io_uring-2024-01-08' of git://git.kernel.dk/linux: io_uring: ensure local task_work is run on wait timeout io_uring/kbuf: add method for returning provided buffer ring head io_uring/rw: ensure io->bytes_done is always initialized io_uring: drop any code related to SCM_RIGHTS io_uring/unix: drop usage of io_uring socket io_uring/register: move io_uring_register(2) related code to register.c io_uring/openclose: add support for IORING_OP_FIXED_FD_INSTALL io_uring/cmd: inline io_uring_cmd_get_task io_uring/cmd: inline io_uring_cmd_do_in_task_lazy io_uring: split out cmd api into a separate header io_uring: optimise ltimeout for inline execution io_uring: don't check iopoll if request completes
Showing the changes to include/linux/io_uring (1 of 26 files). Show all
Unified · Split
| @@ -0,0 +1,77 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
| 2 | #ifndef _LINUX_IO_URING_CMD_H | ||
| 3 | #define _LINUX_IO_URING_CMD_H | ||
| 4 | |||
| 5 | #include <uapi/linux/io_uring.h> | ||
| 6 | #include <linux/io_uring_types.h> | ||
| 7 | |||
| 8 | /* only top 8 bits of sqe->uring_cmd_flags for kernel internal use */ | ||
| 9 | #define IORING_URING_CMD_CANCELABLE (1U << 30) | ||
| 10 | |||
| 11 | struct io_uring_cmd { | ||
| 12 | struct file *file; | ||
| 13 | const struct io_uring_sqe *sqe; | ||
| 14 | /* callback to defer completions to task context */ | ||
| 15 | void (*task_work_cb)(struct io_uring_cmd *cmd, unsigned); | ||
| 16 | u32 cmd_op; | ||
| 17 | u32 flags; | ||
| 18 | u8 pdu[32]; /* available inline for free use */ | ||
| 19 | }; | ||
| 20 | |||
| 21 | static inline const void *io_uring_sqe_cmd(const struct io_uring_sqe *sqe) | ||
| 22 | { | ||
| 23 | return sqe->cmd; | ||
| 24 | } | ||
| 25 | |||
| 26 | #if defined(CONFIG_IO_URING) | ||
| 27 | int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, | ||
| 28 | struct iov_iter *iter, void *ioucmd); | ||
| 29 | void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t res2, | ||
| 30 | unsigned issue_flags); | ||
| 31 | void __io_uring_cmd_do_in_task(struct io_uring_cmd *ioucmd, | ||
| 32 | void (*task_work_cb)(struct io_uring_cmd *, unsigned), | ||
| 33 | unsigned flags); | ||
| 34 | |||
| 35 | void io_uring_cmd_mark_cancelable(struct io_uring_cmd *cmd, | ||
| 36 | unsigned int issue_flags); | ||
| 37 | |||
| 38 | #else | ||
| 39 | static inline int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, | ||
| 40 | struct iov_iter *iter, void *ioucmd) | ||
| 41 | { | ||
| 42 | return -EOPNOTSUPP; | ||
| 43 | } | ||
| 44 | static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, | ||
| 45 | ssize_t ret2, unsigned issue_flags) | ||
| 46 | { | ||
| 47 | } | ||
| 48 | static inline void __io_uring_cmd_do_in_task(struct io_uring_cmd *ioucmd, | ||
| 49 | void (*task_work_cb)(struct io_uring_cmd *, unsigned), | ||
| 50 | unsigned flags) | ||
| 51 | { | ||
| 52 | } | ||
| 53 | static inline void io_uring_cmd_mark_cancelable(struct io_uring_cmd *cmd, | ||
| 54 | unsigned int issue_flags) | ||
| 55 | { | ||
| 56 | } | ||
| 57 | #endif | ||
| 58 | |||
| 59 | /* users must follow the IOU_F_TWQ_LAZY_WAKE semantics */ | ||
| 60 | static inline void io_uring_cmd_do_in_task_lazy(struct io_uring_cmd *ioucmd, | ||
| 61 | void (*task_work_cb)(struct io_uring_cmd *, unsigned)) | ||
| 62 | { | ||
| 63 | __io_uring_cmd_do_in_task(ioucmd, task_work_cb, IOU_F_TWQ_LAZY_WAKE); | ||
| 64 | } | ||
| 65 | |||
| 66 | static inline void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd, | ||
| 67 | void (*task_work_cb)(struct io_uring_cmd *, unsigned)) | ||
| 68 | { | ||
| 69 | __io_uring_cmd_do_in_task(ioucmd, task_work_cb, 0); | ||
| 70 | } | ||
| 71 | |||
| 72 | static inline struct task_struct *io_uring_cmd_get_task(struct io_uring_cmd *cmd) | ||
| 73 | { | ||
| 74 | return cmd_to_io_kiocb(cmd)->task; | ||
| 75 | } | ||
| 76 | |||
| 77 | #endif /* _LINUX_IO_URING_CMD_H */ | ||