Skip to contentSkip to conversation

nvme-core: avoid identify with CNS 06h to discovery controller

PATCH In review Martin George 2 participants 3 messages Mar 11, 2023 – Mar 16, 2023 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-core: avoid identify with CNS 06h to discovery controller

nvme_init_non_mdts_limits() currenty invokes an identify command with CNS 06h to both discovery and i/o controllers. But as per the NVMe-oF specification, this is not supported on discovery controllers:

"The Discovery controller shall support the Identify command with a CNS value of 01h (Identify Controller data structure); all other CNS values are reserved."

So ensure this identify command with CNS 06h is sent to i/o controllers alone and not to discovery controllers.

---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
index d4be525f8100..62d1048c6506 100644
@@ -3063,7 +3063,7 @@ static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl)
 	else
 		ctrl->max_zeroes_sectors = 0;
 
-	if (nvme_ctrl_limited_cns(ctrl))
+	if (nvme_ctrl_limited_cns(ctrl) || nvme_discovery_ctrl(ctrl))
 		return 0;
 
 	id = kzalloc(sizeof(*id), GFP_KERNEL);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 10 lines · Martin George

nvme_init_non_mdts_limits() currenty invokes an identify command with CNS 06h to both discovery and i/o controllers. But as per the NVMe-oF specification, this is not supported on discovery controllers:

"The Discovery controller shall support the Identify command with a CNS value of 01h (Identify Controller data structure); all other CNS values are reserved."

So ensure this identify command with CNS 06h is sent to i/o controllers alone and not to discovery controllers.

This looks correct, but can we go a step further and also skip it for administrative controllers, i.e

drivers/nvme/host/core.c static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl) · line 3066

Quoted 2 lines
drivers/nvme/host/core.c +1 -1
-	if (nvme_ctrl_limited_cns(ctrl))
+	if (nvme_ctrl_limited_cns(ctrl) || nvme_discovery_ctrl(ctrl))
	if (ctrl->subsys->subtype != NVME_NQN_NVME ||
	    nvme_ctrl_limited_cns(ctrl))

?

#2 lore raw
Quoted 19 lines · Christoph Hellwig
Quoted 6 lines · Martin George

nvme_init_non_mdts_limits() currenty invokes an identify command with
CNS 06h to both discovery and i/o controllers. But as per the NVMe- oF
specification, this is not supported on discovery controllers:

Quoted 8 lines

"The Discovery controller shall support the Identify command with a CNS value of 01h (Identify Controller data structure); all other CNS
values are reserved."

So ensure this identify command with CNS 06h is sent to i/o controllers
alone and not to discovery controllers.

This looks correct, but can we go a step further and also skip it for administrative controllers, i.e

Quoted 8 lines
Quoted 3 lines

-       if (nvme_ctrl_limited_cns(ctrl))
+       if (nvme_ctrl_limited_cns(ctrl) ||
nvme_discovery_ctrl(ctrl))

        if (ctrl->subsys->subtype != NVME_NQN_NVME || nvme_ctrl_limited_cns(ctrl))

?

Sure. Will send a new patch for the same.

-Martin