nvme_scan_ns does not remove stale namespaces anymore since kernel 6.0

Christoph Hellwig hch at infradead.org
Tue Feb 21 09:51:03 PST 2023


Hi Nils,

can you try this patch?

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 8b64211411626b..fec247d379cc24 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4418,6 +4418,7 @@ static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid)
 {
 	struct nvme_ns_info info = { .nsid = nsid };
 	struct nvme_ns *ns;
+	int ret;
 
 	if (nvme_identify_ns_descs(ctrl, &info))
 		return;
@@ -4434,12 +4435,15 @@ static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid)
 	 * set up a namespace.  If not fall back to the legacy version.
 	 */
 	if ((ctrl->cap & NVME_CAP_CRMS_CRIMS) ||
-	    (info.ids.csi != NVME_CSI_NVM && info.ids.csi != NVME_CSI_ZNS)) {
-		if (nvme_ns_info_from_id_cs_indep(ctrl, &info))
-			return;
-	} else {
-		if (nvme_ns_info_from_identify(ctrl, &info))
-			return;
+	    (info.ids.csi != NVME_CSI_NVM && info.ids.csi != NVME_CSI_ZNS))
+		ret = nvme_ns_info_from_id_cs_indep(ctrl, &info);
+	else
+		ret = nvme_ns_info_from_identify(ctrl, &info);
+
+	if (ret) {
+		if (ret > 0 && (ret & NVME_SC_DNR))
+			nvme_ns_remove_by_nsid(ctrl, nsid);
+		return;
 	}
 
 	/*



More information about the Linux-nvme mailing list