[PATCH 04/17] nvme: don't call nvme_kill_queues from nvme_remove_namespaces
Christoph Hellwig
hch at lst.de
Tue Oct 25 07:40:07 PDT 2022
Only the PCIe driver can mark a controller dead, and it does so in
exactly one spot just before calling nvme_remove_namespaces. Move the
state dependent callto nvme_kill_queues out of nvme_remove_namespaces
and into the one caller where this case can happen.
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
drivers/nvme/host/core.c | 9 ---------
drivers/nvme/host/pci.c | 10 ++++++++++
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index a92d07137cbd8..8eb46ca9f6acf 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4560,15 +4560,6 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
/* prevent racing with ns scanning */
flush_work(&ctrl->scan_work);
- /*
- * The dead states indicates the controller was not gracefully
- * disconnected. In that case, we won't be able to flush any data while
- * removing the namespaces' disks; fail all the queues now to avoid
- * potentially having to clean up the failed sync later.
- */
- if (ctrl->state == NVME_CTRL_DEAD)
- nvme_kill_queues(ctrl);
-
/* this is a no-op when called from the controller reset handler */
nvme_change_ctrl_state(ctrl, NVME_CTRL_DELETING_NOIO);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index ec034d4dd9eff..f971e96ffd3f6 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -3249,6 +3249,16 @@ static void nvme_remove(struct pci_dev *pdev)
flush_work(&dev->ctrl.reset_work);
nvme_stop_ctrl(&dev->ctrl);
+
+ /*
+ * The dead states indicates the controller was not gracefully
+ * disconnected. In that case, we won't be able to flush any data while
+ * removing the namespaces' disks; fail all the queues now to avoid
+ * potentially having to clean up the failed sync later.
+ */
+ if (dev->ctrl.state == NVME_CTRL_DEAD)
+ nvme_kill_queues(&dev->ctrl);
+
nvme_remove_namespaces(&dev->ctrl);
nvme_dev_disable(dev, true);
nvme_remove_attrs(dev);
--
2.30.2
More information about the Linux-nvme
mailing list