Skip to content

Commit 1b95e81

Browse files
Ming Leikeithbusch
authored andcommitted
nvme: fix possible hang when removing a controller during error recovery
Error recovery can be interrupted by controller removal, then the controller is left as quiesced, and IO hang can be caused. Fix the issue by unquiescing controller unconditionally when removing namespaces. This way is reasonable and safe given forward progress can be made when removing namespaces. Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reported-by: Chunguang Xu <brookxu.cn@gmail.com> Closes: https://lore.kernel.org/linux-nvme/cover.1685350577.git.chunguang.xu@shopee.com/ Cc: stable@vger.kernel.org Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent b8f6446 commit 1b95e81

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/nvme/host/core.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3933,6 +3933,12 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
39333933
*/
39343934
nvme_mpath_clear_ctrl_paths(ctrl);
39353935

3936+
/*
3937+
* Unquiesce io queues so any pending IO won't hang, especially
3938+
* those submitted from scan work
3939+
*/
3940+
nvme_unquiesce_io_queues(ctrl);
3941+
39363942
/* prevent racing with ns scanning */
39373943
flush_work(&ctrl->scan_work);
39383944

@@ -3942,10 +3948,8 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
39423948
* removing the namespaces' disks; fail all the queues now to avoid
39433949
* potentially having to clean up the failed sync later.
39443950
*/
3945-
if (ctrl->state == NVME_CTRL_DEAD) {
3951+
if (ctrl->state == NVME_CTRL_DEAD)
39463952
nvme_mark_namespaces_dead(ctrl);
3947-
nvme_unquiesce_io_queues(ctrl);
3948-
}
39493953

39503954
/* this is a no-op when called from the controller reset handler */
39513955
nvme_change_ctrl_state(ctrl, NVME_CTRL_DELETING_NOIO);

0 commit comments

Comments
 (0)