diff options
author | Jens Axboe <axboe@kernel.dk> | 2023-11-06 07:41:17 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-11-06 07:41:17 -0700 |
commit | 0e984ec88da9747549227900e5215c5e6a1b65ae (patch) | |
tree | 73150143deffae7fe41655baee54d5f9d03b7a96 /io_uring/rw.c | |
parent | f8f9ab2d98116e79d220f1d089df7464ad4e026d (diff) | |
download | linux-stable-0e984ec88da9747549227900e5215c5e6a1b65ae.tar.gz linux-stable-0e984ec88da9747549227900e5215c5e6a1b65ae.tar.bz2 linux-stable-0e984ec88da9747549227900e5215c5e6a1b65ae.zip |
io_uring/rw: add separate prep handler for readv/writev
Rather than sprinkle opcode checks in the generic read/write prep handler,
have a separate prep handler for the vectored readv/writev operation.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rw.c')
-rw-r--r-- | io_uring/rw.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/io_uring/rw.c b/io_uring/rw.c index 1c76de483ef6..63d343bae762 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -110,15 +110,23 @@ int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe) rw->addr = READ_ONCE(sqe->addr); rw->len = READ_ONCE(sqe->len); rw->flags = READ_ONCE(sqe->rw_flags); + return 0; +} - /* Have to do this validation here, as this is in io_read() rw->len might - * have chanaged due to buffer selection +int io_prep_rwv(struct io_kiocb *req, const struct io_uring_sqe *sqe) +{ + int ret; + + ret = io_prep_rw(req, sqe); + if (unlikely(ret)) + return ret; + + /* + * Have to do this validation here, as this is in io_read() rw->len + * might have chanaged due to buffer selection */ - if (req->opcode == IORING_OP_READV && req->flags & REQ_F_BUFFER_SELECT) { - ret = io_iov_buffer_select_prep(req); - if (ret) - return ret; - } + if (req->flags & REQ_F_BUFFER_SELECT) + return io_iov_buffer_select_prep(req); return 0; } |