summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2020-06-03 18:03:23 +0300
committerJens Axboe <axboe@kernel.dk>2020-06-04 11:14:19 -0600
commit25e72d1012b30bdff712b563e6141a4f311d28d6 (patch)
treed517714f3baf50c6f2d734ac025d628cb51f8e80 /fs/io_uring.c
parent3232dd02af65f2d01be641120d2a710176b0c7a7 (diff)
downloadlwn-25e72d1012b30bdff712b563e6141a4f311d28d6.tar.gz
lwn-25e72d1012b30bdff712b563e6141a4f311d28d6.zip
io_uring: do build_open_how() only once
build_open_how() is just adjusting open_flags/mode. Do it once during prep. It looks better than storing raw values for the future. Signed-off-by: Pavel Begunkov <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.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index c627dd9ce096..0c5b48467651 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2993,6 +2993,7 @@ static int io_fallocate(struct io_kiocb *req, bool force_nonblock)
static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
{
const char __user *fname;
+ u64 flags, mode;
int ret;
if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
@@ -3004,13 +3005,14 @@ static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (req->flags & REQ_F_NEED_CLEANUP)
return 0;
- req->open.dfd = READ_ONCE(sqe->fd);
- req->open.how.mode = READ_ONCE(sqe->len);
- fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
- req->open.how.flags = READ_ONCE(sqe->open_flags);
+ mode = READ_ONCE(sqe->len);
+ flags = READ_ONCE(sqe->open_flags);
if (force_o_largefile())
- req->open.how.flags |= O_LARGEFILE;
+ flags |= O_LARGEFILE;
+ req->open.how = build_open_how(flags, mode);
+ req->open.dfd = READ_ONCE(sqe->fd);
+ fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
req->open.filename = getname(fname);
if (IS_ERR(req->open.filename)) {
ret = PTR_ERR(req->open.filename);
@@ -3104,7 +3106,6 @@ err:
static int io_openat(struct io_kiocb *req, bool force_nonblock)
{
- req->open.how = build_open_how(req->open.how.flags, req->open.how.mode);
return io_openat2(req, force_nonblock);
}