diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-08-09 13:04:16 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-08-23 13:07:59 -0600 |
commit | d3fddf6dddd84432161eb070ed8e34d14c8bf56a (patch) | |
tree | 1040318b56c5d8d31634cf87e76a721f53fbb048 /fs/io_uring.c | |
parent | 543af3a13da308f2cea954644b43c2c9f864c350 (diff) | |
download | lwn-d3fddf6dddd84432161eb070ed8e34d14c8bf56a.tar.gz lwn-d3fddf6dddd84432161eb070ed8e34d14c8bf56a.zip |
io_uring: deduplicate open iopoll check
Move IORING_SETUP_IOPOLL check into __io_openat_prep(), so both openat
and openat2 reuse it.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/9a73ce83e4ee60d011180ef177eecef8e87ff2a2.1628471125.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 576100b23147..26a3ab9b6aed 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3789,6 +3789,8 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe const char __user *fname; int ret; + if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) + return -EINVAL; if (unlikely(sqe->ioprio || sqe->buf_index)) return -EINVAL; if (unlikely(req->flags & REQ_F_FIXED_FILE)) @@ -3813,12 +3815,9 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { - u64 flags, mode; + u64 mode = READ_ONCE(sqe->len); + u64 flags = READ_ONCE(sqe->open_flags); - if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) - return -EINVAL; - mode = READ_ONCE(sqe->len); - flags = READ_ONCE(sqe->open_flags); req->open.how = build_open_how(flags, mode); return __io_openat_prep(req, sqe); } @@ -3829,8 +3828,6 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) size_t len; int ret; - if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) - return -EINVAL; how = u64_to_user_ptr(READ_ONCE(sqe->addr2)); len = READ_ONCE(sqe->len); if (len < OPEN_HOW_SIZE_VER0) |