All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] nvme-fc: fix race with connectivity loss and nvme_fc_create_association
@ 2024-10-29 18:40 Daniel Wagner
  2024-10-29 18:40 ` [PATCH v2 1/2] nvme-fc: go straight to connecting state when initializing Daniel Wagner
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Wagner @ 2024-10-29 18:40 UTC (permalink / raw)
  To: James Smart, Keith Busch, Christoph Hellwig, Sagi Grimberg,
	Hannes Reinecke, Paul Ely
  Cc: linux-nvme, linux-kernel, Daniel Wagner

We got a bug report that a controller was stuck in the connected state
after an association dropped.

It turns out that nvme_fc_create_association can succeed even though some
operation do fail. This is on purpose to handle the degraded controller
case, where the admin queue is up and running but not the io queues. In
this case the controller will still reach the LIVE state.

Unfortunatly, this will also ignore full connectivity loss for fabric
controllers. Let's address this by not filtering out all errors in
nvme_set_queue_count.

I haven't tested this version yet, as it needs a bit of tinker in my
setup. So the question is this a better approach? I think it would also
be great to hear from Paul if this works.

In theory the nvme_set_queue_count call still could pass and later
connectivity loss could happen, just before entering the LIVE state. In
this case the only thing to observe the connectivity loss is the keep
alive handler which currently does nothing. I think we should also
trigger a reset in this case. What do you think?

---
Changes in v2:
  - handle connection lost in nvme_set_queue_count directly
  - collected reviewed tags
  - Link to v1: https://lore.kernel.org/r/20240611190647.11856-1-dwagner@suse.de

---
Daniel Wagner (2):
      nvme-fc: go straight to connecting state when initializing
      nvme: handle connectivity loss in nvme_set_queue_count

 drivers/nvme/host/core.c | 7 ++++++-
 drivers/nvme/host/fc.c   | 3 +--
 2 files changed, 7 insertions(+), 3 deletions(-)
---
base-commit: 5e52f71f858eaff252a47530a5ad5e79309bd415
change-id: 20241029-nvme-fc-handle-com-lost-9b241936809a

Best regards,
-- 
Daniel Wagner <wagi@kernel.org>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] nvme-fc: go straight to connecting state when initializing
  2024-10-29 18:40 [PATCH v2 0/2] nvme-fc: fix race with connectivity loss and nvme_fc_create_association Daniel Wagner
@ 2024-10-29 18:40 ` Daniel Wagner
  2024-10-29 18:40 ` [PATCH v2 2/2] nvme: handle connectivity loss in nvme_set_queue_count Daniel Wagner
  2024-10-30  4:38 ` [PATCH v2 0/2] nvme-fc: fix race with connectivity loss and nvme_fc_create_association Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Wagner @ 2024-10-29 18:40 UTC (permalink / raw)
  To: James Smart, Keith Busch, Christoph Hellwig, Sagi Grimberg,
	Hannes Reinecke, Paul Ely
  Cc: linux-nvme, linux-kernel, Daniel Wagner

The initial controller initialization mimiks the reconnect loop
behavior by switching from NEW to RESETTING and then to CONNECTING.

The transition from NEW to CONNECTING is a valid transition, so there is
no point entering the RESETTING state. TCP and RDMA also transition
directly to CONNECTING state.

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Daniel Wagner <wagi@kernel.org>
---
 drivers/nvme/host/fc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index b81af7919e94c421387033bf8361a9cf8a867486..d45ab530ff9b7bd03bc311474278fc840f8786d5 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -3579,8 +3579,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
 	list_add_tail(&ctrl->ctrl_list, &rport->ctrl_list);
 	spin_unlock_irqrestore(&rport->lock, flags);
 
-	if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING) ||
-	    !nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) {
+	if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) {
 		dev_err(ctrl->ctrl.device,
 			"NVME-FC{%d}: failed to init ctrl state\n", ctrl->cnum);
 		goto fail_ctrl;

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] nvme: handle connectivity loss in nvme_set_queue_count
  2024-10-29 18:40 [PATCH v2 0/2] nvme-fc: fix race with connectivity loss and nvme_fc_create_association Daniel Wagner
  2024-10-29 18:40 ` [PATCH v2 1/2] nvme-fc: go straight to connecting state when initializing Daniel Wagner
@ 2024-10-29 18:40 ` Daniel Wagner
  2024-10-30  4:38 ` [PATCH v2 0/2] nvme-fc: fix race with connectivity loss and nvme_fc_create_association Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Wagner @ 2024-10-29 18:40 UTC (permalink / raw)
  To: James Smart, Keith Busch, Christoph Hellwig, Sagi Grimberg,
	Hannes Reinecke, Paul Ely
  Cc: linux-nvme, linux-kernel, Daniel Wagner

nvme_set_queue_count is called when setting up the IO queues. When
updating of the queue number fails, the function will ignore all NVME
errors. The assumption is that the controller is in degraded state, the
admin queue is up and running but not the IO queues.

In this state it's still possible to issues admin commands to the
controller to mitigate the problem, that's whay the controller
is allowed to enter the LIVE state.

Though by filtering out all error, it filters out a connectivity loss
event for fabric controllers:

     1) nvme nvme10: NVME-FC{10}: create association : ...
     2) nvme nvme10: NVME-FC{10}: controller connectivity lost. Awaiting Reconnect
        nvme nvme10: queue_size 128 > ctrl maxcmd 32, reducing to maxcmd
     3) nvme nvme10: Could not set queue count (880)
        nvme nvme10: Failed to configure AEN (cfg 900)
     4) nvme nvme10: NVME-FC{10}: controller connect complete
     5) nvme nvme10: failed nvme_keep_alive_end_io error=4

A new connection attempt is started 1) and while connecting the host
receives a connectivity loss event 2). 3) is the point where the connect
code observes a problem but ignores it and enters LIVE state at 4). The
keep alive command eventually times out 5) but again, this type of error
is ignored.

Note the status in nvme_keep_alive_end_io is EINTR, the real reason got
lost at this point (connectivity loss).

Thus catch the error early where we still have the exact reason why the
nvme_set_features has failed and bail out from there.

Fixes: 9a0be7abb62f ("nvme: refactor set_queue_count")
Signed-off-by: Daniel Wagner <wagi@kernel.org>
---
 drivers/nvme/host/core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 84cb859a911d09dbe71b2f1ac473ae687c4dc687..cc5ed6daf61f6cbc6fdf7b48687e25225bfd9f17 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1664,7 +1664,12 @@ int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count)
 
 	status = nvme_set_features(ctrl, NVME_FEAT_NUM_QUEUES, q_count, NULL, 0,
 			&result);
-	if (status < 0)
+	/*
+	 * It's either a kernel error or the host observed a connection
+	 * lost. In either case it's not possible communicate with the
+	 * controller and thus enter the error code path.
+	 */
+	if (status < 0 || status == NVME_SC_HOST_PATH_ERROR)
 		return status;
 
 	/*

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] nvme-fc: fix race with connectivity loss and nvme_fc_create_association
  2024-10-29 18:40 [PATCH v2 0/2] nvme-fc: fix race with connectivity loss and nvme_fc_create_association Daniel Wagner
  2024-10-29 18:40 ` [PATCH v2 1/2] nvme-fc: go straight to connecting state when initializing Daniel Wagner
  2024-10-29 18:40 ` [PATCH v2 2/2] nvme: handle connectivity loss in nvme_set_queue_count Daniel Wagner
@ 2024-10-30  4:38 ` Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-10-30  4:38 UTC (permalink / raw)
  To: Daniel Wagner
  Cc: James Smart, Keith Busch, Christoph Hellwig, Sagi Grimberg,
	Hannes Reinecke, Paul Ely, linux-nvme, linux-kernel

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-30  4:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29 18:40 [PATCH v2 0/2] nvme-fc: fix race with connectivity loss and nvme_fc_create_association Daniel Wagner
2024-10-29 18:40 ` [PATCH v2 1/2] nvme-fc: go straight to connecting state when initializing Daniel Wagner
2024-10-29 18:40 ` [PATCH v2 2/2] nvme: handle connectivity loss in nvme_set_queue_count Daniel Wagner
2024-10-30  4:38 ` [PATCH v2 0/2] nvme-fc: fix race with connectivity loss and nvme_fc_create_association Christoph Hellwig

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.