Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a4955f

Browse files
committed
io_uring: sqthread should grab ctx->uring_lock for submissions
We use the mutex to guard against registered file updates, for instance. Ensure we're safe in accessing that state against concurrent updates. Signed-off-by: Jens Axboe <[email protected]>
1 parent e995d51 commit 8a4955f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

fs/io_uring.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,12 +2996,7 @@ static int io_issue_sqe(struct io_kiocb *req, struct io_kiocb **nxt,
29962996
if (req->result == -EAGAIN)
29972997
return -EAGAIN;
29982998

2999-
/* workqueue context doesn't hold uring_lock, grab it now */
3000-
if (req->in_async)
3001-
mutex_lock(&ctx->uring_lock);
30022999
io_iopoll_req_issued(req);
3003-
if (req->in_async)
3004-
mutex_unlock(&ctx->uring_lock);
30053000
}
30063001

30073002
return 0;
@@ -3655,7 +3650,9 @@ static int io_sq_thread(void *data)
36553650
}
36563651

36573652
to_submit = min(to_submit, ctx->sq_entries);
3653+
mutex_lock(&ctx->uring_lock);
36583654
ret = io_submit_sqes(ctx, to_submit, NULL, -1, &cur_mm, true);
3655+
mutex_unlock(&ctx->uring_lock);
36593656
if (ret > 0)
36603657
inflight += ret;
36613658
}

0 commit comments

Comments
 (0)