[PATCH V10 6/8] nvme-core: check ctrl css before setting up zns

Christoph Hellwig hch at lst.de
Tue Mar 9 15:03:24 GMT 2021


On Tue, Mar 09, 2021 at 12:42:04PM +0100, Christoph Hellwig wrote:
> I'll pick this up for nvme-5.12 as it is an important bug fix that
> might allow not spec conformant devices to slip through.

So while looking into applying this I think we should move the check
earlier.  What do you think of this version?

---
>From 43b82e21c6ae2f7d2d99550cb348fbd08610fa06 Mon Sep 17 00:00:00 2001
From: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
Date: Mon, 8 Mar 2021 20:58:21 -0800
Subject: nvme-core: check ctrl css before setting up zns

Ensure multiple Command Sets are supported before starting to setup a
ZNS namespace.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
[hch: move the check around a bit]
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 63bb1da0861e9d..82ad5eef9d0c30 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4096,6 +4096,12 @@ static void nvme_validate_or_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
 				nsid);
 			break;
 		}
+		if (!nvme_multi_css(ctrl)) {
+			dev_warn(ctrl->device,
+				"command set not reported for nsid: %d\n",
+				ns->head->ns_id);
+			break;
+		}
 		nvme_alloc_ns(ctrl, nsid, &ids);
 		break;
 	default:
-- 
2.30.1




More information about the Linux-nvme mailing list