Re: [PATCH 10/17] nvme-pci: mark the namespaces dead earlier in nvme_remove

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




When we have a non-present controller there is no reason to wait in
marking the namespaces dead, so do it ASAP.  Also remove the superflous
call to nvme_start_queues as nvme_dev_disable already did that for us.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
  drivers/nvme/host/pci.c | 18 ++++++------------
  1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 8ab54857cfd50..bef98f6e1396c 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -3244,25 +3244,19 @@ static void nvme_remove(struct pci_dev *pdev)
  	nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
  	pci_set_drvdata(pdev, NULL);
+ /*
+	 * Mark the namespaces dead as we can't flush the data, and disable the
+	 * controller ASAP as we can't shut it down properly if it was surprise
+	 * removed.
+	 */
  	if (!pci_device_is_present(pdev)) {
  		nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DEAD);
+		nvme_mark_namespaces_dead(&dev->ctrl);

Don't you need to start the queues as well here?

  		nvme_dev_disable(dev, true);
  	}
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_mark_namespaces_dead(&dev->ctrl);
-		nvme_start_queues(&dev->ctrl);
-	}
-
  	nvme_remove_namespaces(&dev->ctrl);
  	nvme_dev_disable(dev, true);
  	nvme_remove_attrs(dev);



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux