Commit d01905db authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: clean iowq submit work cancellation

If we've got IO_WQ_WORK_CANCEL in io_wq_submit_work(), handle the error
on the same lines as the check instead of having a weird code flow. The
main loop doesn't change but goes one indention left.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/ff4a09cf41f7a22bbb294b6f1faea721e21fe615.1634987320.git.asml.silence@gmail.comReviewed-by: default avatarHao Xu <haoxu@linux.alibaba.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 255657d2
......@@ -6721,6 +6721,8 @@ static struct io_wq_work *io_wq_free_work(struct io_wq_work *work)
static void io_wq_submit_work(struct io_wq_work *work)
{
struct io_kiocb *req = container_of(work, struct io_kiocb, work);
unsigned int issue_flags = IO_URING_F_UNLOCKED;
bool needs_poll = false;
struct io_kiocb *timeout;
int ret = 0;
......@@ -6735,12 +6737,10 @@ static void io_wq_submit_work(struct io_wq_work *work)
io_queue_linked_timeout(timeout);
/* either cancelled or io-wq is dying, so don't touch tctx->iowq */
if (work->flags & IO_WQ_WORK_CANCEL)
ret = -ECANCELED;
if (!ret) {
bool needs_poll = false;
unsigned int issue_flags = IO_URING_F_UNLOCKED;
if (work->flags & IO_WQ_WORK_CANCEL) {
io_req_task_queue_fail(req, -ECANCELED);
return;
}
if (req->flags & REQ_F_FORCE_ASYNC) {
needs_poll = req->file && file_can_poll(req->file);
......@@ -6768,7 +6768,6 @@ static void io_wq_submit_work(struct io_wq_work *work)
needs_poll = false;
issue_flags &= ~IO_URING_F_NONBLOCK;
} while (1);
}
/* avoid locking problems by failing it from a clean context */
if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment