Skip to contentSkip to conversation

nvme: fix two kinds of IO hang from removing NSs

PATCH In review Ming Lei 3 participants 11 messages Jun 13, 2023 – Jun 14, 2023

Subsystems (2)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

cover nvme: fix two kinds of IO hang from removing NSs

Hello,

The 1st patch fixes io hang when controller removal interrupts error recovery, then queue is left as quiesced.

The 2nd patch fixes io hang when controller is left as frozen.

Ming Lei (2):
nvme: core: unquiesce io queues when removing namespaces
nvme: don't freeze/unfreeze queues from different contexts

 drivers/nvme/host/core.c | 10 +++++++---
 drivers/nvme/host/pci.c  |  8 +++++---
 drivers/nvme/host/rdma.c |  3 ++-
 drivers/nvme/host/tcp.c  |  3 ++-
 4 files changed, 16 insertions(+), 8 deletions(-)
Signature · 1 line
2.40.1
author
#1 lore raw

PATCH 1/2 nvme: core: unquiesce io queues when removing namespaces

When error recovery is interrupted by controller removal, the controller is left as quiesced, then IO hang can be caused.

Fix the issue by unquiescing controller unconditionally when removing namespaces.

---
 drivers/nvme/host/core.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvme/host/core.c +6 -0
index 3ec38e2b9173..4ef5eaecaa75 100644
@@ -4692,6 +4692,12 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
 	 */
 	nvme_mpath_clear_ctrl_paths(ctrl);
 
+	/*
+	 * Unquiesce io queues so any pending IO won't hang, especially
+	 * those submitted from scan work
+	 */
+	nvme_unquiesce_io_queues(ctrl);
+
 	/* prevent racing with ns scanning */
 	flush_work(&ctrl->scan_work);
 
Signature · 1 line
2.40.1
maintainer
#2 lore raw

Re: [PATCH 1/2] nvme: core: unquiesce io queues when removing namespaces

Quoted 19 lines

When error recovery is interrupted by controller removal, the controller is left as quiesced, then IO hang can be caused.

Fix the issue by unquiescing controller unconditionally when removing namespaces.

---
  drivers/nvme/host/core.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/nvme/host/core.c +0 -0
index 3ec38e2b9173..4ef5eaecaa75 100644

drivers/nvme/host/core.c void nvme_remove_namespaces(struct nvme_ctrl *ctrl) · line 4700

Quoted 9 lines
drivers/nvme/host/core.c +6 -0
@@ -4692,6 +4692,12 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
  	 */
  	nvme_mpath_clear_ctrl_paths(ctrl);
 
+	/*
+	 * Unquiesce io queues so any pending IO won't hang, especially
+	 * those submitted from scan work
+	 */
+	nvme_unquiesce_io_queues(ctrl);
+

Looks fine, but I think that the removal of the unquiesce from the condition below (CTRL_DEAD) should be done in this patch.

Quoted 3 lines
drivers/nvme/host/core.c +0 -0
  	/* prevent racing with ns scanning */
  	flush_work(&ctrl->scan_work);
 
author
#3 lore raw

PATCH 2/2 nvme: don't freeze/unfreeze queues from different contexts

In reply to Ming Lei

For block layer freeze/unfreeze APIs, the caller is required to call the two in strict pair, so most of users simply call them from same context, and everything works just fine.

For NVMe, the two are done from different contexts, this way has caused all kinds of IO hang issue, such as:

1) When io queue connect fails, this controller is deleted without being marked as DEAD. Upper layer may wait forever in __bio_queue_enter(), because in del_gendisk(), disk won't be marked as DEAD unless bdev sync & invalidate returns. If any writeback IO waits in __bio_queue_enter(), IO deadlock is caused. Reported from Yi Zhang.

2) error recovering vs. namespace deletiong, if any IO originated from scan work is waited in __bio_queue_enter(), flushing scan work hangs for ever in nvme_remove_namespaces() because controller is left as frozen when error recovery is interrupted by controller removal. Reported from Chunguang.

Fix the issue by calling the two in same context just when reset is done and not starting freeze from beginning of error recovery. Not only IO hang is solved, correctness of freeze & unfreeze is respected.

And this way is correct because quiesce is enough for driver to handle error recovery. The only difference is where to wait during error recovery. With this way, IO is just queued in block layer queue instead of __bio_queue_enter(), finally waiting for completion is done in upper layer. Either way, IO can't move on during error recovery.

---
 drivers/nvme/host/core.c | 4 +---
 drivers/nvme/host/pci.c  | 8 +++++---
 drivers/nvme/host/rdma.c | 3 ++-
 drivers/nvme/host/tcp.c  | 3 ++-
 4 files changed, 10 insertions(+), 8 deletions(-)
drivers/nvme/host/core.c +1 -3
index 4ef5eaecaa75..d5d9b6f6ec74 100644
@@ -4707,10 +4707,8 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
 	 * 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) {
+	if (ctrl->state == NVME_CTRL_DEAD)
 		nvme_mark_namespaces_dead(ctrl);
-		nvme_unquiesce_io_queues(ctrl);
-	}
 
 	/* this is a no-op when called from the controller reset handler */
 	nvme_change_ctrl_state(ctrl, NVME_CTRL_DELETING_NOIO);
drivers/nvme/host/pci.c +5 -3
index 492f319ebdf3..5d775b76baca 100644
@@ -2578,14 +2578,15 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
 	dead = nvme_pci_ctrl_is_dead(dev);
 	if (dev->ctrl.state == NVME_CTRL_LIVE ||
 	    dev->ctrl.state == NVME_CTRL_RESETTING) {
-		if (pci_is_enabled(pdev))
-			nvme_start_freeze(&dev->ctrl);
 		/*
 		 * Give the controller a chance to complete all entered requests
 		 * if doing a safe shutdown.
 		 */
-		if (!dead && shutdown)
+		if (!dead && shutdown & pci_is_enabled(pdev)) {
+			nvme_start_freeze(&dev->ctrl);
 			nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
+			nvme_unfreeze(&dev->ctrl);
+		}
 	}
 
 	nvme_quiesce_io_queues(&dev->ctrl);
@@ -2740,6 +2741,7 @@ static void nvme_reset_work(struct work_struct *work)
 	 * controller around but remove all namespaces.
 	 */
 	if (dev->online_queues > 1) {
+		nvme_start_freeze(&dev->ctrl);
 		nvme_unquiesce_io_queues(&dev->ctrl);
 		nvme_wait_freeze(&dev->ctrl);
 		nvme_pci_update_nr_queues(dev);
drivers/nvme/host/rdma.c +2 -1
index 0eb79696fb73..354cce8853c1 100644
@@ -918,6 +918,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
 		goto out_cleanup_tagset;
 
 	if (!new) {
+		nvme_start_freeze(&ctrl->ctrl);
 		nvme_unquiesce_io_queues(&ctrl->ctrl);
 		if (!nvme_wait_freeze_timeout(&ctrl->ctrl, NVME_IO_TIMEOUT)) {
 			/*
@@ -926,6 +927,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
 			 * to be safe.
 			 */
 			ret = -ENODEV;
+			nvme_unfreeze(&ctrl->ctrl);
 			goto out_wait_freeze_timed_out;
 		}
 		blk_mq_update_nr_hw_queues(ctrl->ctrl.tagset,
@@ -975,7 +977,6 @@ static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl,
 		bool remove)
 {
 	if (ctrl->ctrl.queue_count > 1) {
-		nvme_start_freeze(&ctrl->ctrl);
 		nvme_quiesce_io_queues(&ctrl->ctrl);
 		nvme_sync_io_queues(&ctrl->ctrl);
 		nvme_rdma_stop_io_queues(ctrl);
drivers/nvme/host/tcp.c +2 -1
index bf0230442d57..5ae08e9cb16d 100644
@@ -1909,6 +1909,7 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
 		goto out_cleanup_connect_q;
 
 	if (!new) {
+		nvme_start_freeze(ctrl);
 		nvme_unquiesce_io_queues(ctrl);
 		if (!nvme_wait_freeze_timeout(ctrl, NVME_IO_TIMEOUT)) {
 			/*
@@ -1917,6 +1918,7 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
 			 * to be safe.
 			 */
 			ret = -ENODEV;
+			nvme_unfreeze(ctrl);
 			goto out_wait_freeze_timed_out;
 		}
 		blk_mq_update_nr_hw_queues(ctrl->tagset,
@@ -2021,7 +2023,6 @@ static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl,
 	if (ctrl->queue_count <= 1)
 		return;
 	nvme_quiesce_admin_queue(ctrl);
-	nvme_start_freeze(ctrl);
 	nvme_quiesce_io_queues(ctrl);
 	nvme_sync_io_queues(ctrl);
 	nvme_tcp_stop_io_queues(ctrl);
Signature · 1 line
2.40.1
maintainer
#4 lore raw

Re: [PATCH 2/2] nvme: don't freeze/unfreeze queues from different contexts

Quoted 46 lines

For block layer freeze/unfreeze APIs, the caller is required to call the two in strict pair, so most of users simply call them from same context, and everything works just fine.

For NVMe, the two are done from different contexts, this way has caused all kinds of IO hang issue, such as:

1) When io queue connect fails, this controller is deleted without being marked as DEAD. Upper layer may wait forever in __bio_queue_enter(), because in del_gendisk(), disk won't be marked as DEAD unless bdev sync & invalidate returns. If any writeback IO waits in __bio_queue_enter(), IO deadlock is caused. Reported from Yi Zhang.

2) error recovering vs. namespace deletiong, if any IO originated from scan work is waited in __bio_queue_enter(), flushing scan work hangs for ever in nvme_remove_namespaces() because controller is left as frozen when error recovery is interrupted by controller removal. Reported from Chunguang.

Fix the issue by calling the two in same context just when reset is done and not starting freeze from beginning of error recovery. Not only IO hang is solved, correctness of freeze & unfreeze is respected.

And this way is correct because quiesce is enough for driver to handle error recovery. The only difference is where to wait during error recovery. With this way, IO is just queued in block layer queue instead of __bio_queue_enter(), finally waiting for completion is done in upper layer. Either way, IO can't move on during error recovery.

---
  drivers/nvme/host/core.c | 4 +---
  drivers/nvme/host/pci.c  | 8 +++++---
  drivers/nvme/host/rdma.c | 3 ++-
  drivers/nvme/host/tcp.c  | 3 ++-
  4 files changed, 10 insertions(+), 8 deletions(-)
drivers/nvme/host/core.c +0 -0
index 4ef5eaecaa75..d5d9b6f6ec74 100644

drivers/nvme/host/core.c void nvme_remove_namespaces(struct nvme_ctrl *ctrl) · line 4713

Quoted 8 lines
drivers/nvme/host/core.c +1 -3
@@ -4707,10 +4707,8 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
  	 * 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) {
+	if (ctrl->state == NVME_CTRL_DEAD)
  		nvme_mark_namespaces_dead(ctrl);
-		nvme_unquiesce_io_queues(ctrl);
-	}

Shouldn't this be in the next patch? Not sure what this helps in this patch? It is not clearly documented in the commit msg.

Quoted 13 lines
drivers/nvme/host/core.c +0 -0
  	/* this is a no-op when called from the controller reset handler */
  	nvme_change_ctrl_state(ctrl, NVME_CTRL_DELETING_NOIO);
drivers/nvme/host/pci.c +0 -2
index 492f319ebdf3..5d775b76baca 100644
@@ -2578,14 +2578,15 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
  	dead = nvme_pci_ctrl_is_dead(dev);
  	if (dev->ctrl.state == NVME_CTRL_LIVE ||
  	    dev->ctrl.state == NVME_CTRL_RESETTING) {
-		if (pci_is_enabled(pdev))
-			nvme_start_freeze(&dev->ctrl);

drivers/nvme/host/pci.c static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) · line 2589

Quoted 10 lines
drivers/nvme/host/pci.c +4 -1
  		/*
  		 * Give the controller a chance to complete all entered requests
  		 * if doing a safe shutdown.
  		 */
-		if (!dead && shutdown)
+		if (!dead && shutdown & pci_is_enabled(pdev)) {
+			nvme_start_freeze(&dev->ctrl);
  			nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
+			nvme_unfreeze(&dev->ctrl);
+		}

I'd split out the pci portion, it is not related to the reported issue, and it is structured differently than the fabrics transports (as for now at least).

Quoted 24 lines
drivers/nvme/host/pci.c +1 -0
  	}
 
  	nvme_quiesce_io_queues(&dev->ctrl);
@@ -2740,6 +2741,7 @@ static void nvme_reset_work(struct work_struct *work)
  	 * controller around but remove all namespaces.
  	 */
  	if (dev->online_queues > 1) {
+		nvme_start_freeze(&dev->ctrl);
  		nvme_unquiesce_io_queues(&dev->ctrl);
  		nvme_wait_freeze(&dev->ctrl);
  		nvme_pci_update_nr_queues(dev);
drivers/nvme/host/rdma.c +1 -0
index 0eb79696fb73..354cce8853c1 100644
@@ -918,6 +918,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
  		goto out_cleanup_tagset;
 
  	if (!new) {
+		nvme_start_freeze(&ctrl->ctrl);
  		nvme_unquiesce_io_queues(&ctrl->ctrl);
  		if (!nvme_wait_freeze_timeout(&ctrl->ctrl, NVME_IO_TIMEOUT)) {
  			/*

drivers/nvme/host/rdma.c static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) · line 930

Quoted 4 lines
drivers/nvme/host/rdma.c +1 -0
@@ -926,6 +927,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
  			 * to be safe.
  			 */
  			ret = -ENODEV;
+			nvme_unfreeze(&ctrl->ctrl);

What does this unfreeze designed to do?

author
#5 lore raw

Re: [PATCH 2/2] nvme: don't freeze/unfreeze queues from different contexts

Quoted 50 lines · Sagi Grimberg
Quoted 50 lines

For block layer freeze/unfreeze APIs, the caller is required to call the two in strict pair, so most of users simply call them from same context, and everything works just fine.

For NVMe, the two are done from different contexts, this way has caused all kinds of IO hang issue, such as:

1) When io queue connect fails, this controller is deleted without being marked as DEAD. Upper layer may wait forever in __bio_queue_enter(), because in del_gendisk(), disk won't be marked as DEAD unless bdev sync & invalidate returns. If any writeback IO waits in __bio_queue_enter(), IO deadlock is caused. Reported from Yi Zhang.

2) error recovering vs. namespace deletiong, if any IO originated from scan work is waited in __bio_queue_enter(), flushing scan work hangs for ever in nvme_remove_namespaces() because controller is left as frozen when error recovery is interrupted by controller removal. Reported from Chunguang.

Fix the issue by calling the two in same context just when reset is done and not starting freeze from beginning of error recovery. Not only IO hang is solved, correctness of freeze & unfreeze is respected.

And this way is correct because quiesce is enough for driver to handle error recovery. The only difference is where to wait during error recovery. With this way, IO is just queued in block layer queue instead of __bio_queue_enter(), finally waiting for completion is done in upper layer. Either way, IO can't move on during error recovery.

---
  drivers/nvme/host/core.c | 4 +---
  drivers/nvme/host/pci.c  | 8 +++++---
  drivers/nvme/host/rdma.c | 3 ++-
  drivers/nvme/host/tcp.c  | 3 ++-
  4 files changed, 10 insertions(+), 8 deletions(-)
drivers/nvme/host/core.c +0 -1
index 4ef5eaecaa75..d5d9b6f6ec74 100644
@@ -4707,10 +4707,8 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
  	 * 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) {
Quoted 8 lines

drivers/nvme/host/core.c void nvme_remove_namespaces(struct nvme_ctrl *ctrl) · line 4713

Quoted 4 lines
drivers/nvme/host/core.c +1 -2
+	if (ctrl->state == NVME_CTRL_DEAD)
  		nvme_mark_namespaces_dead(ctrl);
-		nvme_unquiesce_io_queues(ctrl);
-	}

Shouldn't this be in the next patch? Not sure what this helps in this patch? It is not clearly documented in the commit msg.

oops, good catch, will fix it in V2.

Quoted 17 lines
Quoted 17 lines
drivers/nvme/host/core.c +0 -0
  	/* this is a no-op when called from the controller reset handler */
  	nvme_change_ctrl_state(ctrl, NVME_CTRL_DELETING_NOIO);
drivers/nvme/host/pci.c +0 -2
index 492f319ebdf3..5d775b76baca 100644
@@ -2578,14 +2578,15 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
  	dead = nvme_pci_ctrl_is_dead(dev);
  	if (dev->ctrl.state == NVME_CTRL_LIVE ||
  	    dev->ctrl.state == NVME_CTRL_RESETTING) {
-		if (pci_is_enabled(pdev))
-			nvme_start_freeze(&dev->ctrl);
  		/*
  		 * Give the controller a chance to complete all entered requests
  		 * if doing a safe shutdown.
  		 */
Quoted 8 lines

drivers/nvme/host/pci.c static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) · line 2589

Quoted 6 lines
drivers/nvme/host/pci.c +4 -1
-		if (!dead && shutdown)
+		if (!dead && shutdown & pci_is_enabled(pdev)) {
+			nvme_start_freeze(&dev->ctrl);
  			nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
+			nvme_unfreeze(&dev->ctrl);
+		}

I'd split out the pci portion, it is not related to the reported issue,

Yes.

Quoted 2 lines

and it is structured differently than the fabrics transports (as for now at least).

The above change needs to be done in this patch given the same pattern needs to remove the above 'if (pci_is_enabled(pdev)) nvme_start_freeze()'.

Quoted 21 lines
Quoted 21 lines
drivers/nvme/host/pci.c +1 -0
  	}
  	nvme_quiesce_io_queues(&dev->ctrl);
@@ -2740,6 +2741,7 @@ static void nvme_reset_work(struct work_struct *work)
  	 * controller around but remove all namespaces.
  	 */
  	if (dev->online_queues > 1) {
+		nvme_start_freeze(&dev->ctrl);
  		nvme_unquiesce_io_queues(&dev->ctrl);
  		nvme_wait_freeze(&dev->ctrl);
  		nvme_pci_update_nr_queues(dev);
drivers/nvme/host/rdma.c +1 -0
index 0eb79696fb73..354cce8853c1 100644
@@ -918,6 +918,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
  		goto out_cleanup_tagset;
  	if (!new) {
+		nvme_start_freeze(&ctrl->ctrl);
  		nvme_unquiesce_io_queues(&ctrl->ctrl);
  		if (!nvme_wait_freeze_timeout(&ctrl->ctrl, NVME_IO_TIMEOUT)) {
Quoted 8 lines

drivers/nvme/host/rdma.c static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) · line 930

Quoted 6 lines
drivers/nvme/host/rdma.c +1 -0
  			/*
@@ -926,6 +927,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
  			 * to be safe.
  			 */
  			ret = -ENODEV;
+			nvme_unfreeze(&ctrl->ctrl);

What does this unfreeze designed to do?

It is for undoing the previous nvme_start_freeze.

Thanks,
Ming

maintainer
#6 lore raw

Re: [PATCH 2/2] nvme: don't freeze/unfreeze queues from different contexts

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
drivers/nvme/host/rdma.c +1 -0
index 0eb79696fb73..354cce8853c1 100644
@@ -918,6 +918,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
  		goto out_cleanup_tagset;
  	if (!new) {
+		nvme_start_freeze(&ctrl->ctrl);
  		nvme_unquiesce_io_queues(&ctrl->ctrl);
  		if (!nvme_wait_freeze_timeout(&ctrl->ctrl, NVME_IO_TIMEOUT)) {
Quoted 8 lines

drivers/nvme/host/rdma.c static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) · line 930

Quoted 6 lines
drivers/nvme/host/rdma.c +1 -0
  			/*
@@ -926,6 +927,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
  			 * to be safe.
  			 */
  			ret = -ENODEV;
+			nvme_unfreeze(&ctrl->ctrl);

What does this unfreeze designed to do?

Quoted 1 line

It is for undoing the previous nvme_start_freeze.

ok.

maintainer
#7 lore raw

Re: [PATCH 2/2] nvme: don't freeze/unfreeze queues from different contexts

In reply to Ming Lei
Quoted 5 lines · Ming Lei

And this way is correct because quiesce is enough for driver to handle error recovery. The only difference is where to wait during error recovery. With this way, IO is just queued in block layer queue instead of __bio_queue_enter(), finally waiting for completion is done in upper layer. Either way, IO can't move on during error recovery.

The point was to contain the fallout from modifying the hctx mappings. If you allow IO to queue in the blk-mq layer while a reset is in progress, they may be entering a context that won't be as expected on the other side of the reset.

maintainer
#8 lore raw

Re: [PATCH 2/2] nvme: don't freeze/unfreeze queues from different contexts

Quoted 11 lines
Quoted 6 lines

And this way is correct because quiesce is enough for driver to handle error recovery. The only difference is where to wait during error recovery. With this way, IO is just queued in block layer queue instead of __bio_queue_enter(), finally waiting for completion is done in upper layer. Either way, IO can't move on during error recovery.

The point was to contain the fallout from modifying the hctx mappings. If you allow IO to queue in the blk-mq layer while a reset is in progress, they may be entering a context that won't be as expected on the other side of the reset.

That still happens to *some* commands though right?

maintainer
#9 lore raw

Re: [PATCH 2/2] nvme: don't freeze/unfreeze queues from different contexts

Quoted 7 lines · Sagi Grimberg
Quoted 7 lines
Quoted 6 lines

And this way is correct because quiesce is enough for driver to handle error recovery. The only difference is where to wait during error recovery. With this way, IO is just queued in block layer queue instead of __bio_queue_enter(), finally waiting for completion is done in upper layer. Either way, IO can't move on during error recovery.

Quoted 6 lines
Quoted 4 lines

The point was to contain the fallout from modifying the hctx mappings. If you allow IO to queue in the blk-mq layer while a reset is in progress, they may be entering a context that won't be as expected on the other side of the reset.

That still happens to *some* commands though right?

That is possible only for commands that were already dispatched and subsequently failed with retry disposition. At the point of reset today, nothing new enters a queue till we know what the mapping looks like.

author
#10 lore raw

Re: [PATCH 2/2] nvme: don't freeze/unfreeze queues from different contexts

In reply to Keith Busch
Quoted 8 lines · Keith Busch
Quoted 5 lines · Ming Lei

And this way is correct because quiesce is enough for driver to handle error recovery. The only difference is where to wait during error recovery. With this way, IO is just queued in block layer queue instead of __bio_queue_enter(), finally waiting for completion is done in upper layer. Either way, IO can't move on during error recovery.

The point was to contain the fallout from modifying the hctx mappings.

blk_mq_update_nr_hw_queues() is called after nvme_wait_freeze returns, nothing changes here, so correctness wrt. updating hctx mapping is provided.

Quoted 3 lines

If you allow IO to queue in the blk-mq layer while a reset is in progress, they may be entering a context that won't be as expected on the other side of the reset.

The only difference is that in-tree code starts to freeze at the beginning of error recovery, which way can just prevent new IO, and old ones still are queued, but can't be dispatched to driver because of quiescing in both ways. With this patch, new IOs queued after error recovery are just like old ones canceled before resetting.

So not see problems from driver side with this change, and nvme driver has to cover new IOs queued after error happens.

Thanks.
Ming