Skip to content

Commit

Permalink
io_uring: clarify io_req_task_cancel() locking
Browse files Browse the repository at this point in the history
It's too easy to forget and misjudge about synchronisation in
io_req_task_cancel(), add a comment clarifying it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/71099083835f983a1fd73d5a3da6391924da8300.1629920396.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Pavel Begunkov authored and Jens Axboe committed Aug 27, 2021
1 parent 9a10867 commit b18a1a4
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 @@ -2168,7 +2168,7 @@ static void io_req_task_cancel(struct io_kiocb *req, bool *locked)
{
struct io_ring_ctx *ctx = req->ctx;

/* ctx is guaranteed to stay alive while we hold uring_lock */
/* not needed for normal modes, but SQPOLL depends on it */
io_tw_lock(ctx, locked);
io_req_complete_failed(req, req->result);
}
Expand All @@ -2177,7 +2177,6 @@ static void io_req_task_submit(struct io_kiocb *req, bool *locked)
{
struct io_ring_ctx *ctx = req->ctx;

/* ctx stays valid until unlock, even if we drop all ours ctx->refs */
io_tw_lock(ctx, locked);
/* req->task == current here, checking PF_EXITING is safe */
if (likely(!(req->task->flags & PF_EXITING)))
Expand Down

0 comments on commit b18a1a4

Please sign in to comment.