public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] nvme: Remove namespace when nvme_identify_ns_descs() failed
@ 2024-11-29 14:06 Hannes Reinecke
  2024-12-03 19:15 ` Keith Busch
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Hannes Reinecke @ 2024-11-29 14:06 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Keith Busch, Sagi Grimberg, linux-nvme, Hannes Reinecke

When a namespace gets unmapped on the target during scanning
nvme_identify_ns_descs() returns with a non-retryable error.
With the currrent code we will ignore that error on the grounds
that we failed to get information, and hence cannot make any
decisions whether to keep or remove that namespace.
But a non-retryable error implies that the namespace is _not_
present as we cannot retry that command and will never get
information about that namespace.
And we need to remove the namespace during scanning, as otherwise
the AEN informing us about a namespace change will find the NSID
present, but nvme_validate_ns() will fail, and the namespace
will never be updated with the correct information.

Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
 drivers/nvme/host/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 9e7e63e10e5a..396520cb3ce6 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3999,8 +3999,11 @@ static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid)
 	struct nvme_ns *ns;
 	int ret;
 
-	if (nvme_identify_ns_descs(ctrl, &info))
+	ret = nvme_identify_ns_descs(ctrl, &info);
+	if (ret > 0 && (ret & NVME_STATUS_DNR)) {
+		nvme_ns_remove_by_nsid(ctrl, nsid);
 		return;
+	}
 
 	if (info.ids.csi != NVME_CSI_NVM && !nvme_multi_css(ctrl)) {
 		dev_warn(ctrl->device,
-- 
2.35.3



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

end of thread, other threads:[~2025-01-15  8:22 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-29 14:06 [PATCH] nvme: Remove namespace when nvme_identify_ns_descs() failed Hannes Reinecke
2024-12-03 19:15 ` Keith Busch
2024-12-04  7:14   ` Hannes Reinecke
2024-12-04 16:39     ` Keith Busch
2024-12-05 12:30       ` Hannes Reinecke
2024-12-05 16:15         ` Keith Busch
2024-12-06 12:41           ` Hannes Reinecke
2025-01-07 16:01             ` Keith Busch
2025-01-11 14:01             ` Nilay Shroff
2025-01-13  7:43               ` Hannes Reinecke
2025-01-13 14:12                 ` Nilay Shroff
2025-01-13 14:29                   ` Hannes Reinecke
2025-01-15  7:48                     ` Nilay Shroff
2025-01-15  8:02                       ` Hannes Reinecke
2025-01-15  8:18                         ` Nilay Shroff
2025-01-15  8:22                           ` Hannes Reinecke
2024-12-24 11:35 ` Sagi Grimberg
2024-12-25  9:58 ` Sagi Grimberg
2025-01-07  8:11   ` Hannes Reinecke
2025-01-08 10:49     ` Sagi Grimberg
2025-01-08 15:45       ` Hannes Reinecke
2025-01-10 23:16         ` Sagi Grimberg
2025-01-13  7:50           ` Hannes Reinecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox