Skip to content

Commit

Permalink
io_uring: synchronise IOPOLL on task_submit fail
Browse files Browse the repository at this point in the history
io_req_task_submit() might be called for IOPOLL, do the fail path under
uring_lock to comply with IOPOLL synchronisation based solely on it.

Cc: stable@vger.kernel.org # 5.5+
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 Jan 4, 2021
1 parent b1b6b5a commit 81b6d05
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -2126,15 +2126,16 @@ static void io_req_task_cancel(struct callback_head *cb)
static void __io_req_task_submit(struct io_kiocb *req)
{
struct io_ring_ctx *ctx = req->ctx;
bool fail;

if (!__io_sq_thread_acquire_mm(ctx) &&
!__io_sq_thread_acquire_files(ctx)) {
mutex_lock(&ctx->uring_lock);
fail = __io_sq_thread_acquire_mm(ctx) ||
__io_sq_thread_acquire_files(ctx);
mutex_lock(&ctx->uring_lock);
if (!fail)
__io_queue_sqe(req, NULL);
mutex_unlock(&ctx->uring_lock);
} else {
else
__io_req_task_cancel(req, -EFAULT);
}
mutex_unlock(&ctx->uring_lock);
}

static void io_req_task_submit(struct callback_head *cb)
Expand Down

0 comments on commit 81b6d05

Please sign in to comment.