]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ublk: move ublk_cancel_dev() out of ub->mutex
authorMing Lei <ming.lei@redhat.com>
Mon, 9 Oct 2023 09:33:18 +0000 (17:33 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Jan 2024 12:39:06 +0000 (12:39 +0000)
commita8555c86f508e0e246a2729fe0f40bdf9fc51da0
treecc8b66b3baf04a20f170f1c501be3a956114edaf
parent1c250f2c5fa5406fb7c5f7eb40218b7d5bb8cfa8
ublk: move ublk_cancel_dev() out of ub->mutex

[ Upstream commit 85248d670b71d9edda9459ee14fdc85c8e9632c0 ]

ublk_cancel_dev() just calls ublk_cancel_queue() to cancel all pending
io commands after ublk request queue is idle. The only protection is just
the read & write of ubq->nr_io_ready and avoid duplicated command cancel,
so add one per-queue lock with cancel flag for providing this protection,
meantime move ublk_cancel_dev() out of ub->mutex.

Then we needn't to call io_uring_cmd_complete_in_task() to cancel
pending command. And the same cancel logic will be re-used for
cancelable uring command.

This patch basically reverts commit ac5902f84bb5 ("ublk: fix AB-BA lockdep warning").

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20231009093324.957829-4-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/block/ublk_drv.c