From: Christoph Hellwig <hch@lst.de>
Date: Thu, 29 Aug 2024 05:54:56 +0000 (+0300)
Subject: HACK: force nvme namepace to be shared
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9aa14404d3d57b45ac49c991795d0467da06813c;p=users%2Fhch%2Fblock.git

HACK: force nvme namepace to be shared

Quick hack to run the multipath code on ZNS without a real
multi-controller subsystem.
---

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 75ab62cb4aa4..73968130f509 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1582,7 +1582,7 @@ static int nvme_ns_info_from_identify(struct nvme_ctrl *ctrl,
 	}
 
 	info->anagrpid = id->anagrpid;
-	info->is_shared = id->nmic & NVME_NS_NMIC_SHARED;
+	info->is_shared = true; // id->nmic & NVME_NS_NMIC_SHARED;
 	info->is_readonly = id->nsattr & NVME_NS_ATTR_RO;
 	info->is_ready = true;
 	if (ctrl->quirks & NVME_QUIRK_BOGUS_NID) {
@@ -1620,7 +1620,7 @@ static int nvme_ns_info_from_id_cs_indep(struct nvme_ctrl *ctrl,
 	ret = nvme_submit_sync_cmd(ctrl->admin_q, &c, id, sizeof(*id));
 	if (!ret) {
 		info->anagrpid = id->anagrpid;
-		info->is_shared = id->nmic & NVME_NS_NMIC_SHARED;
+		info->is_shared = true; // id->nmic & NVME_NS_NMIC_SHARED;
 		info->is_readonly = id->nsattr & NVME_NS_ATTR_RO;
 		info->is_ready = id->nstat & NVME_NSTAT_NRDY;
 	}
@@ -2943,7 +2943,7 @@ static bool nvme_validate_cntlid(struct nvme_subsystem *subsys,
 				subsys->subnqn);
 			return false;
 		}
-
+#if 0
 		if ((id->cmic & NVME_CTRL_CMIC_MULTI_CTRL) ||
 		    nvme_discovery_ctrl(ctrl))
 			continue;
@@ -2951,6 +2951,7 @@ static bool nvme_validate_cntlid(struct nvme_subsystem *subsys,
 		dev_err(ctrl->device,
 			"Subsystem does not support multiple controllers\n");
 		return false;
+#endif
 	}
 
 	return true;
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 91d9eb3c22ef..25761fb7d88f 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -609,10 +609,11 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
 	 * We also do this for private namespaces as the namespace sharing flag
 	 * could change after a rescan.
 	 */
+#if 0
 	if (!(ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) ||
 	    !nvme_is_unique_nsid(ctrl, head) || !multipath)
 		return 0;
-
+#endif
 	blk_set_stacking_limits(&lim);
 	lim.dma_alignment = 3;
 	lim.features |= BLK_FEAT_IO_STAT | BLK_FEAT_NOWAIT | BLK_FEAT_POLL;