提交 d81e76a7 编写于 作者: P Pavel Begunkov 提交者: Xiaoguang Wang

io_uring: do build_open_how() only once

to #28736503

commit 25e72d1012b30bdff712b563e6141a4f311d28d6 upstream

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: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 a17a35d5
...@@ -2984,6 +2984,7 @@ static int io_fallocate(struct io_kiocb *req, bool force_nonblock) ...@@ -2984,6 +2984,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) static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
{ {
const char __user *fname; const char __user *fname;
u64 flags, mode;
int ret; int ret;
if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL))) if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
...@@ -2995,13 +2996,14 @@ static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2995,13 +2996,14 @@ static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (req->flags & REQ_F_NEED_CLEANUP) if (req->flags & REQ_F_NEED_CLEANUP)
return 0; return 0;
req->open.dfd = READ_ONCE(sqe->fd); mode = READ_ONCE(sqe->len);
req->open.how.mode = READ_ONCE(sqe->len); flags = READ_ONCE(sqe->open_flags);
fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
req->open.how.flags = READ_ONCE(sqe->open_flags);
if (force_o_largefile()) 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); req->open.filename = getname(fname);
if (IS_ERR(req->open.filename)) { if (IS_ERR(req->open.filename)) {
ret = PTR_ERR(req->open.filename); ret = PTR_ERR(req->open.filename);
...@@ -3095,7 +3097,6 @@ static int io_openat2(struct io_kiocb *req, bool force_nonblock) ...@@ -3095,7 +3097,6 @@ static int io_openat2(struct io_kiocb *req, bool force_nonblock)
static int io_openat(struct io_kiocb *req, bool force_nonblock) 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); return io_openat2(req, force_nonblock);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册