[PATCH 4/4] nvme: check that EUI/GUID/UUID are globally unique

Keith Busch kbusch at kernel.org
Wed Jun 8 12:04:48 PDT 2022


On Wed, Jun 08, 2022 at 06:11:04PM +0000, Alan Adamson wrote:
> > On Jun 8, 2022, at 12:52 AM, Christoph Hellwig <hch at lst.de> wrote:
> 
> How do we get the clear_ids setting from the connect to the target?

I'm assuming something like this (untested):

---
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 59024af2da2e..3eaf463d0567 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -687,6 +687,7 @@ static void nvme_loop_remove_port(struct nvmet_port *port)
 static const struct nvmet_fabrics_ops nvme_loop_ops = {
 	.owner		= THIS_MODULE,
 	.type		= NVMF_TRTYPE_LOOP,
+	.flags		= NVMF_CLEAR_NS_DESCS,
 	.add_port	= nvme_loop_add_port,
 	.remove_port	= nvme_loop_remove_port,
 	.queue_response = nvme_loop_queue_response,
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 69818752a33a..03ce045af54e 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -300,6 +300,7 @@ struct nvmet_fabrics_ops {
 	unsigned int flags;
 #define NVMF_KEYED_SGLS			(1 << 0)
 #define NVMF_METADATA_SUPPORTED		(1 << 1)
+#define NVMF_CLEAR_NS_DESCS		(1 << 3)
 	void (*queue_response)(struct nvmet_req *req);
 	int (*add_port)(struct nvmet_port *port);
 	void (*remove_port)(struct nvmet_port *port);
diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index b1f7efab3918..9fa5bc0e26d0 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -30,6 +30,19 @@ void nvmet_passthrough_override_cap(struct nvmet_ctrl *ctrl)
 		ctrl->cap &= ~(1ULL << 43);
 }
 
+static u16 nvmet_passthru_override_id_descs(struct nvmet_req *req)
+{
+	struct nvmet_ctrl *ctrl = req->sq->ctrl;
+	u16 ret = NVME_SC_SUCCESS;
+
+	if (ctrl->ops->flags & NVMF_CLEAR_NS_DESCS) {
+		ret = NVME_SC_INVALID_FIELD;
+		nvmet_zero_sgl(req, 0, 0x1000);
+	}
+
+	return ret;
+}
+
 static u16 nvmet_passthru_override_id_ctrl(struct nvmet_req *req)
 {
 	struct nvmet_ctrl *ctrl = req->sq->ctrl;
@@ -176,6 +189,9 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w)
 		case NVME_ID_CNS_NS:
 			nvmet_passthru_override_id_ns(req);
 			break;
+		case NVME_ID_CNS_NS_DESC_LIST:
+			nvmet_passthru_override_id_descs(req);
+			break;
 		}
 	} else if (status < 0)
 		status = NVME_SC_INTERNAL;
--



More information about the Linux-nvme mailing list