All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: check at least one ns identification reported
@ 2024-10-31 10:38 Guixin Liu
  2024-10-31 12:55 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Guixin Liu @ 2024-10-31 10:38 UTC (permalink / raw)
  To: kbusch, axboe, hch, sagi; +Cc: linux-nvme

Per 2.1 base NVMe spec:
  At least one Namespace Identification Descriptor identifying the
  namespace (i.e., NIDT field set to 1h, 2h, or 3h).
Check there is at least one reported.

Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
 drivers/nvme/host/core.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 84cb859a911d..6e23d617ad7f 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1426,7 +1426,7 @@ static int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
 }
 
 static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, struct nvme_ns_ids *ids,
-		struct nvme_ns_id_desc *cur, bool *csi_seen)
+		struct nvme_ns_id_desc *cur, bool *csi_seen, bool *has_id)
 {
 	const char *warn_str = "ctrl returned bogus length:";
 	void *data = cur;
@@ -1438,6 +1438,7 @@ static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, struct nvme_ns_ids *ids,
 				 warn_str, cur->nidl);
 			return -1;
 		}
+		*has_id = true;
 		if (ctrl->quirks & NVME_QUIRK_BOGUS_NID)
 			return NVME_NIDT_EUI64_LEN;
 		memcpy(ids->eui64, data + sizeof(*cur), NVME_NIDT_EUI64_LEN);
@@ -1448,6 +1449,7 @@ static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, struct nvme_ns_ids *ids,
 				 warn_str, cur->nidl);
 			return -1;
 		}
+		*has_id = true;
 		if (ctrl->quirks & NVME_QUIRK_BOGUS_NID)
 			return NVME_NIDT_NGUID_LEN;
 		memcpy(ids->nguid, data + sizeof(*cur), NVME_NIDT_NGUID_LEN);
@@ -1458,6 +1460,7 @@ static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, struct nvme_ns_ids *ids,
 				 warn_str, cur->nidl);
 			return -1;
 		}
+		*has_id = true;
 		if (ctrl->quirks & NVME_QUIRK_BOGUS_NID)
 			return NVME_NIDT_UUID_LEN;
 		uuid_copy(&ids->uuid, data + sizeof(*cur));
@@ -1482,6 +1485,7 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl,
 {
 	struct nvme_command c = { };
 	bool csi_seen = false;
+	bool has_id = false;
 	int status, pos, len;
 	void *data;
 
@@ -1513,13 +1517,21 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl,
 		if (cur->nidl == 0)
 			break;
 
-		len = nvme_process_ns_desc(ctrl, &info->ids, cur, &csi_seen);
+		len = nvme_process_ns_desc(ctrl, &info->ids, cur,
+					   &csi_seen, &has_id);
 		if (len < 0)
 			break;
 
 		len += sizeof(*cur);
 	}
 
+	if (!has_id) {
+		dev_warn(ctrl->device,
+			 "No identification reported for nsid:%d\n",
+			 info->nsid);
+		status = -EINVAL;
+	}
+
 	if (nvme_multi_css(ctrl) && !csi_seen) {
 		dev_warn(ctrl->device, "Command set not reported for nsid:%d\n",
 			 info->nsid);
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme: check at least one ns identification reported
  2024-10-31 10:38 [PATCH] nvme: check at least one ns identification reported Guixin Liu
@ 2024-10-31 12:55 ` Christoph Hellwig
  2024-11-01  1:32   ` Guixin Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2024-10-31 12:55 UTC (permalink / raw)
  To: Guixin Liu; +Cc: kbusch, axboe, hch, sagi, linux-nvme

On Thu, Oct 31, 2024 at 06:38:03PM +0800, Guixin Liu wrote:
> Per 2.1 base NVMe spec:
>   At least one Namespace Identification Descriptor identifying the
>   namespace (i.e., NIDT field set to 1h, 2h, or 3h).
> Check there is at least one reported.

NVMe 1.0 didn't have any of these identifier, so it's unfortunate
but perfectly valid if devices don't have any.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme: check at least one ns identification reported
  2024-10-31 12:55 ` Christoph Hellwig
@ 2024-11-01  1:32   ` Guixin Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Guixin Liu @ 2024-11-01  1:32 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: kbusch, axboe, sagi, linux-nvme


在 2024/10/31 20:55, Christoph Hellwig 写道:
> On Thu, Oct 31, 2024 at 06:38:03PM +0800, Guixin Liu wrote:
>> Per 2.1 base NVMe spec:
>>    At least one Namespace Identification Descriptor identifying the
>>    namespace (i.e., NIDT field set to 1h, 2h, or 3h).
>> Check there is at least one reported.
> NVMe 1.0 didn't have any of these identifier, so it's unfortunate
> but perfectly valid if devices don't have any.

Maybe I can add a "NVME_VS > 1.0" check?

Best Regards,

Guixin Liu



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-01  1:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-31 10:38 [PATCH] nvme: check at least one ns identification reported Guixin Liu
2024-10-31 12:55 ` Christoph Hellwig
2024-11-01  1:32   ` Guixin Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.