Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/mock: allow to choose FMODE_NOWAIT

Add an option to choose whether the file supports FMODE_NOWAIT, that
changes the execution path io_uring request takes.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/1e532565b05a05b23589d237c24ee1a3d90c2fd9.1750599274.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
2f71d238 d1aa0346

+12 -1
+5
include/uapi/linux/io_uring/mock_file.h
··· 6 6 enum { 7 7 IORING_MOCK_FEAT_CMD_COPY, 8 8 IORING_MOCK_FEAT_RW_ZERO, 9 + IORING_MOCK_FEAT_RW_NOWAIT, 9 10 10 11 IORING_MOCK_FEAT_END, 11 12 }; ··· 14 13 struct io_uring_mock_probe { 15 14 __u64 features; 16 15 __u64 __resv[9]; 16 + }; 17 + 18 + enum { 19 + IORING_MOCK_CREATE_F_SUPPORT_NOWAIT = 1, 17 20 }; 18 21 19 22 struct io_uring_mock_create {
+7 -1
io_uring/mock_file.c
··· 131 131 .llseek = io_mock_llseek, 132 132 }; 133 133 134 + #define IO_VALID_CREATE_FLAGS (IORING_MOCK_CREATE_F_SUPPORT_NOWAIT) 135 + 134 136 static int io_create_mock_file(struct io_uring_cmd *cmd, unsigned int issue_flags) 135 137 { 136 138 const struct io_uring_sqe *sqe = cmd->sqe; ··· 159 157 memset(&mc, 0, sizeof(mc)); 160 158 if (copy_from_user(&mc, uarg, uarg_size)) 161 159 return -EFAULT; 162 - if (!mem_is_zero(mc.__resv, sizeof(mc.__resv)) || mc.flags) 160 + if (!mem_is_zero(mc.__resv, sizeof(mc.__resv))) 161 + return -EINVAL; 162 + if (mc.flags & ~IO_VALID_CREATE_FLAGS) 163 163 return -EINVAL; 164 164 if (mc.file_size > SZ_1G) 165 165 return -EINVAL; ··· 184 180 file->f_mode |= FMODE_READ | FMODE_CAN_READ | 185 181 FMODE_WRITE | FMODE_CAN_WRITE | 186 182 FMODE_LSEEK; 183 + if (mc.flags & IORING_MOCK_CREATE_F_SUPPORT_NOWAIT) 184 + file->f_mode |= FMODE_NOWAIT; 187 185 188 186 mc.out_fd = fd; 189 187 if (copy_to_user(uarg, &mc, uarg_size)) {