Skip to content

Commit

Permalink
io_uring: simplify io_timeout locking
Browse files Browse the repository at this point in the history
Move spin_lock_irq() earlier to have only 1 call site of it in
io_timeout(). It makes the flow easier.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Pavel Begunkov authored and Jens Axboe committed May 26, 2020
1 parent 4518a3c commit 733f5c9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -4845,6 +4845,7 @@ static int io_timeout(struct io_kiocb *req)
u32 seq = req->sequence;

data = &req->io->timeout;
spin_lock_irq(&ctx->completion_lock);

/*
* sqe->off holds how many events that need to occur for this
Expand All @@ -4853,7 +4854,6 @@ static int io_timeout(struct io_kiocb *req)
*/
if (!count) {
req->flags |= REQ_F_TIMEOUT_NOSEQ;
spin_lock_irq(&ctx->completion_lock);
entry = ctx->timeout_list.prev;
goto add;
}
Expand All @@ -4864,7 +4864,6 @@ static int io_timeout(struct io_kiocb *req)
* Insertion sort, ensuring the first entry in the list is always
* the one we need first.
*/
spin_lock_irq(&ctx->completion_lock);
list_for_each_prev(entry, &ctx->timeout_list) {
struct io_kiocb *nxt = list_entry(entry, struct io_kiocb, list);
unsigned nxt_seq;
Expand Down

0 comments on commit 733f5c9

Please sign in to comment.