diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-10-01 18:07:02 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-10-19 05:49:54 -0600 |
commit | fc0ae0244bbbedf309a835afb278e39a3fc9bb94 (patch) | |
tree | 2db4fd025626b7363f032311312889d8d90447c8 /fs/io_uring.c | |
parent | e0eb71dcfc4b862261d99f7f90169142867beb0a (diff) | |
download | lwn-fc0ae0244bbbedf309a835afb278e39a3fc9bb94.tar.gz lwn-fc0ae0244bbbedf309a835afb278e39a3fc9bb94.zip |
io_uring: init opcode in io_init_req()
Move io_req_prep() call inside of io_init_req(), it simplifies a bit
error handling for callers.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/a0f59291fd52da4672c323542fd56fd899e23f8f.1633107393.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 | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index b0b4c5b00f37..81292041378f 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6992,7 +6992,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, { struct io_submit_state *state; unsigned int sqe_flags; - int personality, ret = 0; + int personality; /* req is partially pre-initialised, see io_preinit_req() */ req->opcode = READ_ONCE(sqe->opcode); @@ -7053,9 +7053,10 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, req->file = io_file_get(ctx, req, READ_ONCE(sqe->fd), (sqe_flags & IOSQE_FIXED_FILE)); if (unlikely(!req->file)) - ret = -EBADF; + return -EBADF; } - return ret; + + return io_req_prep(req, sqe); } static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req, @@ -7067,7 +7068,6 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req, ret = io_init_req(ctx, req, sqe); if (unlikely(ret)) { -fail_req: trace_io_uring_req_failed(sqe, ret); /* fail even hard links since we don't submit */ @@ -7092,10 +7092,6 @@ fail_req: return ret; } req_fail_link_node(req, ret); - } else { - ret = io_req_prep(req, sqe); - if (unlikely(ret)) - goto fail_req; } /* don't need @sqe from now on */ |