[PATCH] nvme: Remove namespace when nvme_identify_ns_descs() failed
Hannes Reinecke
hare at kernel.org
Fri Nov 29 06:06:08 PST 2024
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 at 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
More information about the Linux-nvme
mailing list