Skip to content

Commit 25e72d1

Browse files
isilenceaxboe
authored andcommitted
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 3232dd0 commit 25e72d1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

fs/io_uring.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2993,6 +2993,7 @@ static int io_fallocate(struct io_kiocb *req, bool force_nonblock)
29932993
static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
29942994
{
29952995
const char __user *fname;
2996+
u64 flags, mode;
29962997
int ret;
29972998

29982999
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)
30043005
if (req->flags & REQ_F_NEED_CLEANUP)
30053006
return 0;
30063007

3007-
req->open.dfd = READ_ONCE(sqe->fd);
3008-
req->open.how.mode = READ_ONCE(sqe->len);
3009-
fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
3010-
req->open.how.flags = READ_ONCE(sqe->open_flags);
3008+
mode = READ_ONCE(sqe->len);
3009+
flags = READ_ONCE(sqe->open_flags);
30113010
if (force_o_largefile())
3012-
req->open.how.flags |= O_LARGEFILE;
3011+
flags |= O_LARGEFILE;
3012+
req->open.how = build_open_how(flags, mode);
30133013

3014+
req->open.dfd = READ_ONCE(sqe->fd);
3015+
fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
30143016
req->open.filename = getname(fname);
30153017
if (IS_ERR(req->open.filename)) {
30163018
ret = PTR_ERR(req->open.filename);
@@ -3104,7 +3106,6 @@ static int io_openat2(struct io_kiocb *req, bool force_nonblock)
31043106

31053107
static int io_openat(struct io_kiocb *req, bool force_nonblock)
31063108
{
3107-
req->open.how = build_open_how(req->open.how.flags, req->open.how.mode);
31083109
return io_openat2(req, force_nonblock);
31093110
}
31103111

0 commit comments

Comments
 (0)