Skip to content

Commit 11ba820

Browse files
committed
io_uring: ensure workqueue offload grabs ring mutex for poll list
A previous commit moved the locking for the async sqthread, but didn't take into account that the io-wq workers still need it. We can't use req->in_async for this anymore as both the sqthread and io-wq workers set it, gate the need for locking on io_wq_current_is_worker() instead. Fixes: 8a4955f ("io_uring: sqthread should grab ctx->uring_lock for submissions") Reported-by: Bijan Mottahedeh <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 797f3f5 commit 11ba820

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/io_uring.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,10 +3286,19 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
32863286
return ret;
32873287

32883288
if (ctx->flags & IORING_SETUP_IOPOLL) {
3289+
const bool in_async = io_wq_current_is_worker();
3290+
32893291
if (req->result == -EAGAIN)
32903292
return -EAGAIN;
32913293

3294+
/* workqueue context doesn't hold uring_lock, grab it now */
3295+
if (in_async)
3296+
mutex_lock(&ctx->uring_lock);
3297+
32923298
io_iopoll_req_issued(req);
3299+
3300+
if (in_async)
3301+
mutex_unlock(&ctx->uring_lock);
32933302
}
32943303

32953304
return 0;

0 commit comments

Comments
 (0)