Skip to content

Commit 0d63c14

Browse files
isilenceaxboe
authored andcommitted
io_uring: simplify __io_queue_sqe()
Restructure __io_queue_sqe() so it follows simple if/else if/else control flow. It's more readable and removes extra goto/labels. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9aaf354 commit 0d63c14

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

fs/io_uring.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6162,7 +6162,6 @@ static struct io_kiocb *io_prep_linked_timeout(struct io_kiocb *req)
61626162
static void __io_queue_sqe(struct io_kiocb *req, struct io_comp_state *cs)
61636163
{
61646164
struct io_kiocb *linked_timeout;
6165-
struct io_kiocb *nxt;
61666165
const struct cred *old_creds = NULL;
61676166
int ret;
61686167

@@ -6197,30 +6196,25 @@ static void __io_queue_sqe(struct io_kiocb *req, struct io_comp_state *cs)
61976196

61986197
if (linked_timeout)
61996198
io_queue_linked_timeout(linked_timeout);
6200-
goto exit;
6201-
}
6199+
} else if (likely(!ret)) {
6200+
/* drop submission reference */
6201+
req = io_put_req_find_next(req);
6202+
if (linked_timeout)
6203+
io_queue_linked_timeout(linked_timeout);
62026204

6203-
if (unlikely(ret)) {
6205+
if (req) {
6206+
if (!(req->flags & REQ_F_FORCE_ASYNC))
6207+
goto again;
6208+
io_queue_async_work(req);
6209+
}
6210+
} else {
62046211
/* un-prep timeout, so it'll be killed as any other linked */
62056212
req->flags &= ~REQ_F_LINK_TIMEOUT;
62066213
req_set_fail_links(req);
62076214
io_put_req(req);
62086215
io_req_complete(req, ret);
6209-
goto exit;
62106216
}
62116217

6212-
/* drop submission reference */
6213-
nxt = io_put_req_find_next(req);
6214-
if (linked_timeout)
6215-
io_queue_linked_timeout(linked_timeout);
6216-
6217-
if (nxt) {
6218-
req = nxt;
6219-
if (!(req->flags & REQ_F_FORCE_ASYNC))
6220-
goto again;
6221-
io_queue_async_work(req);
6222-
}
6223-
exit:
62246218
if (old_creds)
62256219
revert_creds(old_creds);
62266220
}

0 commit comments

Comments
 (0)