mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
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>
This commit is contained in:
parent
d1aa034657
commit
2f71d2386f
@ -6,6 +6,7 @@
|
|||||||
enum {
|
enum {
|
||||||
IORING_MOCK_FEAT_CMD_COPY,
|
IORING_MOCK_FEAT_CMD_COPY,
|
||||||
IORING_MOCK_FEAT_RW_ZERO,
|
IORING_MOCK_FEAT_RW_ZERO,
|
||||||
|
IORING_MOCK_FEAT_RW_NOWAIT,
|
||||||
|
|
||||||
IORING_MOCK_FEAT_END,
|
IORING_MOCK_FEAT_END,
|
||||||
};
|
};
|
||||||
@ -15,6 +16,10 @@ struct io_uring_mock_probe {
|
|||||||
__u64 __resv[9];
|
__u64 __resv[9];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
IORING_MOCK_CREATE_F_SUPPORT_NOWAIT = 1,
|
||||||
|
};
|
||||||
|
|
||||||
struct io_uring_mock_create {
|
struct io_uring_mock_create {
|
||||||
__u32 out_fd;
|
__u32 out_fd;
|
||||||
__u32 flags;
|
__u32 flags;
|
||||||
|
@ -131,6 +131,8 @@ static const struct file_operations io_mock_fops = {
|
|||||||
.llseek = io_mock_llseek,
|
.llseek = io_mock_llseek,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define IO_VALID_CREATE_FLAGS (IORING_MOCK_CREATE_F_SUPPORT_NOWAIT)
|
||||||
|
|
||||||
static int io_create_mock_file(struct io_uring_cmd *cmd, unsigned int issue_flags)
|
static int io_create_mock_file(struct io_uring_cmd *cmd, unsigned int issue_flags)
|
||||||
{
|
{
|
||||||
const struct io_uring_sqe *sqe = cmd->sqe;
|
const struct io_uring_sqe *sqe = cmd->sqe;
|
||||||
@ -157,7 +159,9 @@ static int io_create_mock_file(struct io_uring_cmd *cmd, unsigned int issue_flag
|
|||||||
memset(&mc, 0, sizeof(mc));
|
memset(&mc, 0, sizeof(mc));
|
||||||
if (copy_from_user(&mc, uarg, uarg_size))
|
if (copy_from_user(&mc, uarg, uarg_size))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
if (!mem_is_zero(mc.__resv, sizeof(mc.__resv)) || mc.flags)
|
if (!mem_is_zero(mc.__resv, sizeof(mc.__resv)))
|
||||||
|
return -EINVAL;
|
||||||
|
if (mc.flags & ~IO_VALID_CREATE_FLAGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (mc.file_size > SZ_1G)
|
if (mc.file_size > SZ_1G)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -180,6 +184,8 @@ static int io_create_mock_file(struct io_uring_cmd *cmd, unsigned int issue_flag
|
|||||||
file->f_mode |= FMODE_READ | FMODE_CAN_READ |
|
file->f_mode |= FMODE_READ | FMODE_CAN_READ |
|
||||||
FMODE_WRITE | FMODE_CAN_WRITE |
|
FMODE_WRITE | FMODE_CAN_WRITE |
|
||||||
FMODE_LSEEK;
|
FMODE_LSEEK;
|
||||||
|
if (mc.flags & IORING_MOCK_CREATE_F_SUPPORT_NOWAIT)
|
||||||
|
file->f_mode |= FMODE_NOWAIT;
|
||||||
|
|
||||||
mc.out_fd = fd;
|
mc.out_fd = fd;
|
||||||
if (copy_to_user(uarg, &mc, uarg_size)) {
|
if (copy_to_user(uarg, &mc, uarg_size)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user