All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Keith Busch <kbusch@kernel.org>,
	Sagi Grimberg <sagi@grimberg.me>, Chao Leng <lengchao@huawei.com>
Cc: Ming Lei <ming.lei@redhat.com>,
	linux-nvme@lists.infradead.org, linux-block@vger.kernel.org
Subject: [PATCH 09/17] nvme: don't unquiesce the I/O queues in nvme_kill_queues
Date: Tue, 25 Oct 2022 07:40:12 -0700	[thread overview]
Message-ID: <20221025144020.260458-10-hch@lst.de> (raw)
In-Reply-To: <20221025144020.260458-1-hch@lst.de>

nvme_kill_queues does two things:

 1) mark the gendisk of all namespaces dead
 2) unquiesce all I/O queues

These used to be be intertwined due to block layer issues, but aren't
any more.  So move the unquiscing of the I/O queues into the callers,
and rename the rest of the function to the now more descriptive
nvme_mark_namespaces_dead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/apple.c |  3 ++-
 drivers/nvme/host/core.c  | 31 ++++---------------------------
 drivers/nvme/host/nvme.h  |  3 +--
 drivers/nvme/host/pci.c   | 12 ++++++++----
 4 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c
index ff8b083dc5c6d..14bee207316a0 100644
--- a/drivers/nvme/host/apple.c
+++ b/drivers/nvme/host/apple.c
@@ -1153,7 +1153,8 @@ static void apple_nvme_reset_work(struct work_struct *work)
 	nvme_change_ctrl_state(&anv->ctrl, NVME_CTRL_DELETING);
 	nvme_get_ctrl(&anv->ctrl);
 	apple_nvme_disable(anv, false);
-	nvme_kill_queues(&anv->ctrl);
+	nvme_mark_namespaces_dead(&anv->ctrl);
+	nvme_start_queues(&anv->ctrl);
 	if (!queue_work(nvme_wq, &anv->remove_work))
 		nvme_put_ctrl(&anv->ctrl);
 }
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index d4d25f1dd6dba..00612e6857295 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -5093,40 +5093,17 @@ static void nvme_stop_ns_queue(struct nvme_ns *ns)
 		blk_mq_wait_quiesce_done(ns->queue);
 }
 
-/*
- * Prepare a queue for teardown.
- *
- * This must forcibly unquiesce queues to avoid blocking dispatch.
- */
-static void nvme_set_queue_dying(struct nvme_ns *ns)
-{
-	if (test_and_set_bit(NVME_NS_DEAD, &ns->flags))
-		return;
-
-	blk_mark_disk_dead(ns->disk);
-	nvme_start_ns_queue(ns);
-}
-
-/**
- * nvme_kill_queues(): Ends all namespace queues
- * @ctrl: the dead controller that needs to end
- *
- * Call this function when the driver determines it is unable to get the
- * controller in a state capable of servicing IO.
- */
-void nvme_kill_queues(struct nvme_ctrl *ctrl)
+/* let I/O to all namespaces fail in preparation for surprise removal */
+void nvme_mark_namespaces_dead(struct nvme_ctrl *ctrl)
 {
 	struct nvme_ns *ns;
 
 	down_read(&ctrl->namespaces_rwsem);
-
-	/* Forcibly unquiesce queues to avoid blocking dispatch */
 	list_for_each_entry(ns, &ctrl->namespaces, list)
-		nvme_set_queue_dying(ns);
-
+		blk_mark_disk_dead(ns->disk);
 	up_read(&ctrl->namespaces_rwsem);
 }
-EXPORT_SYMBOL_GPL(nvme_kill_queues);
+EXPORT_SYMBOL_GPL(nvme_mark_namespaces_dead);
 
 void nvme_unfreeze(struct nvme_ctrl *ctrl)
 {
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index a29877217ee65..1cd7168002438 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -483,7 +483,6 @@ struct nvme_ns {
 	unsigned long features;
 	unsigned long flags;
 #define NVME_NS_REMOVING	0
-#define NVME_NS_DEAD     	1
 #define NVME_NS_ANA_PENDING	2
 #define NVME_NS_FORCE_RO	3
 #define NVME_NS_READY		4
@@ -758,7 +757,7 @@ void nvme_stop_queues(struct nvme_ctrl *ctrl);
 void nvme_start_queues(struct nvme_ctrl *ctrl);
 void nvme_stop_admin_queue(struct nvme_ctrl *ctrl);
 void nvme_start_admin_queue(struct nvme_ctrl *ctrl);
-void nvme_kill_queues(struct nvme_ctrl *ctrl);
+void nvme_mark_namespaces_dead(struct nvme_ctrl *ctrl);
 void nvme_sync_queues(struct nvme_ctrl *ctrl);
 void nvme_sync_io_queues(struct nvme_ctrl *ctrl);
 void nvme_unfreeze(struct nvme_ctrl *ctrl);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index f971e96ffd3f6..8ab54857cfd50 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2793,7 +2793,8 @@ static void nvme_remove_dead_ctrl(struct nvme_dev *dev)
 	nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
 	nvme_get_ctrl(&dev->ctrl);
 	nvme_dev_disable(dev, false);
-	nvme_kill_queues(&dev->ctrl);
+	nvme_mark_namespaces_dead(&dev->ctrl);
+	nvme_start_queues(&dev->ctrl);
 	if (!queue_work(nvme_wq, &dev->remove_work))
 		nvme_put_ctrl(&dev->ctrl);
 }
@@ -2919,7 +2920,8 @@ static void nvme_reset_work(struct work_struct *work)
 		} else {
 			if (dev->ctrl.cntrltype != NVME_CTRL_ADMIN)
 				dev_warn(dev->ctrl.device, "IO queues lost\n");
-			nvme_kill_queues(&dev->ctrl);
+			nvme_mark_namespaces_dead(&dev->ctrl);
+			nvme_start_queues(&dev->ctrl);
 			nvme_remove_namespaces(&dev->ctrl);
 			nvme_free_tagset(dev);
 		}
@@ -3256,8 +3258,10 @@ static void nvme_remove(struct pci_dev *pdev)
 	 * 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);
+	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);
-- 
2.30.2


  parent reply	other threads:[~2022-10-25 14:40 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 14:40 per-tagset SRCU struct and quiesce v2 Christoph Hellwig
2022-10-25 14:40 ` [PATCH 01/17] block: set the disk capacity to 0 in blk_mark_disk_dead Christoph Hellwig
2022-10-26 12:39   ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 02/17] nvme-pci: refactor the tagset handling in nvme_reset_work Christoph Hellwig
2022-10-26 12:46   ` Sagi Grimberg
2022-10-30  9:17     ` Christoph Hellwig
2022-10-25 14:40 ` [PATCH 03/17] nvme-pci: don't warn about the lack of I/O queues for admin controllers Christoph Hellwig
2022-10-26 12:49   ` Sagi Grimberg
2022-10-30  9:18     ` Christoph Hellwig
2022-10-25 14:40 ` [PATCH 04/17] nvme: don't call nvme_kill_queues from nvme_remove_namespaces Christoph Hellwig
2022-10-25 17:43   ` Keith Busch
2022-10-25 20:17     ` Sagi Grimberg
2022-10-30  9:22     ` Christoph Hellwig
2022-10-25 14:40 ` [PATCH 05/17] nvme: don't remove namespaces in nvme_passthru_end Christoph Hellwig
2022-10-26 12:50   ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 06/17] nvme: remove the NVME_NS_DEAD check in nvme_remove_invalid_namespaces Christoph Hellwig
2022-10-26 12:50   ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 07/17] nvme: remove the NVME_NS_DEAD check in nvme_validate_ns Christoph Hellwig
2022-10-26 12:52   ` Sagi Grimberg
2022-10-30  9:28     ` Christoph Hellwig
2022-10-25 14:40 ` [PATCH 08/17] nvme: don't unquiesce the admin queue in nvme_kill_queues Christoph Hellwig
2022-10-26 12:53   ` Sagi Grimberg
2022-10-25 14:40 ` Christoph Hellwig [this message]
2022-10-26 12:54   ` [PATCH 09/17] nvme: don't unquiesce the I/O queues " Sagi Grimberg
2022-10-25 14:40 ` [PATCH 10/17] nvme-pci: mark the namespaces dead earlier in nvme_remove Christoph Hellwig
2022-10-25 18:53   ` Keith Busch
2022-10-26 12:55   ` Sagi Grimberg
2022-10-26 12:57     ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 11/17] nvme-pci: don't unquiesce the I/O queues in nvme_remove_dead_ctrl Christoph Hellwig
2022-10-26  8:34   ` Chao Leng
2022-10-26 12:58     ` Sagi Grimberg
2022-10-27  2:46       ` Chao Leng
2022-10-25 14:40 ` [PATCH 12/17] nvme-pci: don't unquiesce the I/O queues in apple_nvme_reset_work Christoph Hellwig
2022-10-26  8:37   ` Chao Leng
2022-10-26 12:58   ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 13/17] blk-mq: skip non-mq queues in blk_mq_quiesce_queue Christoph Hellwig
2022-10-25 14:40 ` [PATCH 14/17] blk-mq: move the srcu_struct used for quiescing to the tagset Christoph Hellwig
2022-10-26  8:48   ` Chao Leng
2022-10-26 13:01     ` Sagi Grimberg
2022-10-27  2:49       ` Chao Leng
2022-10-27 10:02         ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 15/17] blk-mq: pass a tagset to blk_mq_wait_quiesce_done Christoph Hellwig
2022-10-25 14:40 ` [PATCH 16/17] blk-mq: add tagset quiesce interface Christoph Hellwig
2022-10-26  8:51   ` Chao Leng
2022-10-26 13:02     ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 17/17] nvme: use blk_mq_[un]quiesce_tagset Christoph Hellwig
2022-10-26 13:03   ` Sagi Grimberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221025144020.260458-10-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=kbusch@kernel.org \
    --cc=lengchao@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=ming.lei@redhat.com \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.