* [PATCH 1/4] nvme/loop: reset queue count to 1 in nvme_loop_destroy_io_queues()
2021-05-26 15:23 [PATCH 0/4] nvme-loop: fixes for concurrent reset and delete Hannes Reinecke
@ 2021-05-26 15:23 ` Hannes Reinecke
2021-06-01 17:39 ` Chaitanya Kulkarni
2021-05-26 15:23 ` [PATCH 2/4] nvme/loop: clear NVME_LOOP_Q_LIVE when nvme_loop_configure_admin_queue() fails Hannes Reinecke
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Hannes Reinecke @ 2021-05-26 15:23 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Sagi Grimberg, Keith Busch, linux-nvme, Hannes Reinecke
The queue count is increased in nvme_loop_init_io_queues(), so we
need to reset it to 1 at the end of nvme_loop_destroy_io_queues().
Otherwise the function is not re-entrant safe, and crash will happen
during concurrent reset and remove calls.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/target/loop.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 74b3b150e1a5..f96ec84db8c2 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -299,6 +299,7 @@ static void nvme_loop_destroy_io_queues(struct nvme_loop_ctrl *ctrl)
clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags);
nvmet_sq_destroy(&ctrl->queues[i].nvme_sq);
}
+ ctrl->ctrl.queue_count = 1;
}
static int nvme_loop_init_io_queues(struct nvme_loop_ctrl *ctrl)
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] nvme/loop: clear NVME_LOOP_Q_LIVE when nvme_loop_configure_admin_queue() fails
2021-05-26 15:23 [PATCH 0/4] nvme-loop: fixes for concurrent reset and delete Hannes Reinecke
2021-05-26 15:23 ` [PATCH 1/4] nvme/loop: reset queue count to 1 in nvme_loop_destroy_io_queues() Hannes Reinecke
@ 2021-05-26 15:23 ` Hannes Reinecke
2021-06-01 17:41 ` Chaitanya Kulkarni
2021-05-26 15:23 ` [PATCH 3/4] nvme/loop: check for NVME_LOOP_Q_LIVE in nvme_loop_destroy_admin_queue() Hannes Reinecke
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Hannes Reinecke @ 2021-05-26 15:23 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Sagi Grimberg, Keith Busch, linux-nvme, Hannes Reinecke
When the call to nvme_enable_ctrl() in nvme_loop_configure_admin_queue()
fails the NVME_LOOP_Q_LIVE flag is not cleared.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/target/loop.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index f96ec84db8c2..8e6d1ea3fd9e 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -406,6 +406,7 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl)
return 0;
out_cleanup_queue:
+ clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags);
blk_cleanup_queue(ctrl->ctrl.admin_q);
out_cleanup_fabrics_q:
blk_cleanup_queue(ctrl->ctrl.fabrics_q);
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/4] nvme/loop: check for NVME_LOOP_Q_LIVE in nvme_loop_destroy_admin_queue()
2021-05-26 15:23 [PATCH 0/4] nvme-loop: fixes for concurrent reset and delete Hannes Reinecke
2021-05-26 15:23 ` [PATCH 1/4] nvme/loop: reset queue count to 1 in nvme_loop_destroy_io_queues() Hannes Reinecke
2021-05-26 15:23 ` [PATCH 2/4] nvme/loop: clear NVME_LOOP_Q_LIVE when nvme_loop_configure_admin_queue() fails Hannes Reinecke
@ 2021-05-26 15:23 ` Hannes Reinecke
2021-06-01 17:43 ` Chaitanya Kulkarni
2021-05-26 15:23 ` [PATCH 4/4] nvme/loop: Do not warn for deleted controllers during reset Hannes Reinecke
2021-06-02 7:07 ` [PATCH 0/4] nvme-loop: fixes for concurrent reset and delete Christoph Hellwig
4 siblings, 1 reply; 9+ messages in thread
From: Hannes Reinecke @ 2021-05-26 15:23 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Sagi Grimberg, Keith Busch, linux-nvme, Hannes Reinecke
We need to check the NVME_LOOP_Q_LIVE flag in
nvme_loop_destroy_admin_queue() to protect against duplicate
invocations eg during concurrent reset and remove calls.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/target/loop.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 8e6d1ea3fd9e..c2f3e0b7c4ea 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -263,7 +263,8 @@ static const struct blk_mq_ops nvme_loop_admin_mq_ops = {
static void nvme_loop_destroy_admin_queue(struct nvme_loop_ctrl *ctrl)
{
- clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags);
+ if (!test_and_clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags))
+ return;
nvmet_sq_destroy(&ctrl->queues[0].nvme_sq);
blk_cleanup_queue(ctrl->ctrl.admin_q);
blk_cleanup_queue(ctrl->ctrl.fabrics_q);
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/4] nvme/loop: Do not warn for deleted controllers during reset
2021-05-26 15:23 [PATCH 0/4] nvme-loop: fixes for concurrent reset and delete Hannes Reinecke
` (2 preceding siblings ...)
2021-05-26 15:23 ` [PATCH 3/4] nvme/loop: check for NVME_LOOP_Q_LIVE in nvme_loop_destroy_admin_queue() Hannes Reinecke
@ 2021-05-26 15:23 ` Hannes Reinecke
2021-06-02 7:07 ` [PATCH 0/4] nvme-loop: fixes for concurrent reset and delete Christoph Hellwig
4 siblings, 0 replies; 9+ messages in thread
From: Hannes Reinecke @ 2021-05-26 15:23 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Sagi Grimberg, Keith Busch, linux-nvme, Hannes Reinecke
During concurrent reset and delete calls the reset workqueue is
flushed, causing nvme_loop_reset_ctrl_work() to be executed when
the controller is in state DELETING or DELETING_NOIO.
But this is expected, so we shouldn't issue a WARN_ON here.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/target/loop.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index c2f3e0b7c4ea..9838a7d27bc1 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -465,8 +465,10 @@ static void nvme_loop_reset_ctrl_work(struct work_struct *work)
nvme_loop_shutdown_ctrl(ctrl);
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) {
- /* state change failure should never happen */
- WARN_ON_ONCE(1);
+ if (ctrl->ctrl.state != NVME_CTRL_DELETING &&
+ ctrl->ctrl.state != NVME_CTRL_DELETING_NOIO)
+ /* state change failure for non-deleted ctrl? */
+ WARN_ON_ONCE(1);
return;
}
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/4] nvme-loop: fixes for concurrent reset and delete
2021-05-26 15:23 [PATCH 0/4] nvme-loop: fixes for concurrent reset and delete Hannes Reinecke
` (3 preceding siblings ...)
2021-05-26 15:23 ` [PATCH 4/4] nvme/loop: Do not warn for deleted controllers during reset Hannes Reinecke
@ 2021-06-02 7:07 ` Christoph Hellwig
4 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2021-06-02 7:07 UTC (permalink / raw)
To: Hannes Reinecke; +Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch, linux-nvme
Thanks,
applied to nvme-5.13.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 9+ messages in thread