io-wq: fix ref leak for req in case of exit cancelations
authoryangerkun <yangerkun@huawei.com>
Tue, 9 Mar 2021 03:04:10 +0000 (11:04 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 10 Mar 2021 14:28:42 +0000 (07:28 -0700)
do_work such as io_wq_submit_work that cancel the work may leave a ref of
req as 1 if we have links. Fix it by call io_run_cancel.

Fixes: 4fb6ac326204 ("io-wq: improve manager/worker handling over exec")
Signed-off-by: yangerkun <yangerkun@huawei.com>
Link: https://lore.kernel.org/r/20210309030410.3294078-1-yangerkun@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io-wq.c

index c2e7031..3d7060b 100644 (file)
@@ -799,8 +799,7 @@ static void io_wqe_enqueue(struct io_wqe *wqe, struct io_wq_work *work)
        /* Can only happen if manager creation fails after exec */
        if (io_wq_fork_manager(wqe->wq) ||
            test_bit(IO_WQ_BIT_EXIT, &wqe->wq->state)) {
-               work->flags |= IO_WQ_WORK_CANCEL;
-               wqe->wq->do_work(work);
+               io_run_cancel(work, wqe);
                return;
        }