diff mbox series

[1/3,v2] nvme: make independent ns identify default

Message ID 20241010123951.1226105-2-m@bjorling.me (mailing list archive)
State New, archived
Headers show
Series nvme: add rotational support | expand

Commit Message

Matias Bjørling Oct. 10, 2024, 12:39 p.m. UTC
From: Matias Bjørling <matias.bjorling@wdc.com>

The NVMe 2.0 specification adds an independent identify namespace
data structure that contains generic attributes that apply to all
namespace types. Some attributes carry over from the NVM command set
identify namespace data structure, and others are new.

Currently, the data structure only considered when CRIMS is enabled or
when the namespace type is key-value.

However, the independent namespace data structure
is mandatory for devices that implement features from the 2.0+
specification. Therefore, we can check this data structure first. If
unavailable, retrieve the generic attributes from the NVM command set
identify namespace data structure.

Signed-off-by: Matias Bjørling <matias.bjorling@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
---
 drivers/nvme/host/core.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Christoph Hellwig Oct. 11, 2024, 8:14 a.m. UTC | #1
On Thu, Oct 10, 2024 at 02:39:49PM +0200, Matias Bjørling wrote:
> From: Matias Bjørling <matias.bjorling@wdc.com>
> 
> The NVMe 2.0 specification adds an independent identify namespace
> data structure that contains generic attributes that apply to all
> namespace types. Some attributes carry over from the NVM command set
> identify namespace data structure, and others are new.
> 
> Currently, the data structure only considered when CRIMS is enabled or
> when the namespace type is key-value.
> 
> However, the independent namespace data structure
> is mandatory for devices that implement features from the 2.0+
> specification. Therefore, we can check this data structure first. If
> unavailable, retrieve the generic attributes from the NVM command set
> identify namespace data structure.

FYI, I still disagree with this for the same reason as before.
Assuming we're not really going to see hard drivers I'd be fine
with using it by default for 2.0 (or better even 2.1) by default.
Matias Bjørling Oct. 11, 2024, 5:32 p.m. UTC | #2
On Fri, Oct 11, 2024, at 11:14, Christoph Hellwig wrote:
> On Thu, Oct 10, 2024 at 02:39:49PM +0200, Matias Bjørling wrote:
>> From: Matias Bjørling <matias.bjorling@wdc.com>
>> 
>> The NVMe 2.0 specification adds an independent identify namespace
>> data structure that contains generic attributes that apply to all
>> namespace types. Some attributes carry over from the NVM command set
>> identify namespace data structure, and others are new.
>> 
>> Currently, the data structure only considered when CRIMS is enabled or
>> when the namespace type is key-value.
>> 
>> However, the independent namespace data structure
>> is mandatory for devices that implement features from the 2.0+
>> specification. Therefore, we can check this data structure first. If
>> unavailable, retrieve the generic attributes from the NVM command set
>> identify namespace data structure.
>
> FYI, I still disagree with this for the same reason as before.
> Assuming we're not really going to see hard drivers I'd be fine
> with using it by default for 2.0 (or better even 2.1) by default.

Sounds good. When I am back after next week, I'll update the patch set with the version check and add the missing logic for hdd support. 

(Apologies for double e-mail. My phone client formatted the mail in html)
Keith Busch Nov. 1, 2024, 10:45 p.m. UTC | #3
On Fri, Oct 11, 2024 at 10:14:52AM +0200, Christoph Hellwig wrote:
> On Thu, Oct 10, 2024 at 02:39:49PM +0200, Matias Bjørling wrote:
> > From: Matias Bjørling <matias.bjorling@wdc.com>
> > 
> > The NVMe 2.0 specification adds an independent identify namespace
> > data structure that contains generic attributes that apply to all
> > namespace types. Some attributes carry over from the NVM command set
> > identify namespace data structure, and others are new.
> > 
> > Currently, the data structure only considered when CRIMS is enabled or
> > when the namespace type is key-value.
> > 
> > However, the independent namespace data structure
> > is mandatory for devices that implement features from the 2.0+
> > specification. Therefore, we can check this data structure first. If
> > unavailable, retrieve the generic attributes from the NVM command set
> > identify namespace data structure.
> 
> FYI, I still disagree with this for the same reason as before.
> Assuming we're not really going to see hard drivers I'd be fine
> with using it by default for 2.0 (or better even 2.1) by default.

I've got the rest of the required logs and identifications implemented
in nvmet to support this. There's one more issue, though, if we do
restrict the identify to >= 2.0 or 2.1. nvmet reports 1.3, and I suspect
there's a bit more work than just changing the value of NVMET_DEFAULT_VS
in order to comply with claiming that version.
Matias Bjørling Nov. 4, 2024, 1:24 p.m. UTC | #4
>> FYI, I still disagree with this for the same reason as before.
>> Assuming we're not really going to see hard drivers I'd be fine
>> with using it by default for 2.0 (or better even 2.1) by default.
> 
> I've got the rest of the required logs and identifications implemented
> in nvmet to support this. There's one more issue, though, if we do
> restrict the identify to >= 2.0 or 2.1. nvmet reports 1.3, and I suspect
> there's a bit more work than just changing the value of NVMET_DEFAULT_VS
> in order to comply with claiming that version.
> 

Awesome. I'll hold off the implementation. Would you like me to take 
your patches for a spin?
Christoph Hellwig Nov. 5, 2024, 11:04 a.m. UTC | #5
On Fri, Nov 01, 2024 at 04:45:17PM -0600, Keith Busch wrote:
> I've got the rest of the required logs and identifications implemented
> in nvmet to support this.

Cool!

> There's one more issue, though, if we do
> restrict the identify to >= 2.0 or 2.1. nvmet reports 1.3, and I suspect
> there's a bit more work than just changing the value of NVMET_DEFAULT_VS
> in order to comply with claiming that version.

I don't think there were a lot of new mandatory requirements added that
we didn't already do, or already we already ignored anyway, but it is
worth a double check.
diff mbox series

Patch

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 0dc8bcc664f2..9cbef6342c39 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3999,7 +3999,7 @@  static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid)
 {
 	struct nvme_ns_info info = { .nsid = nsid };
 	struct nvme_ns *ns;
-	int ret;
+	int ret = 1;
 
 	if (nvme_identify_ns_descs(ctrl, &info))
 		return;
@@ -4015,10 +4015,9 @@  static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid)
 	 * data structure to find all the generic information that is needed to
 	 * set up a namespace.  If not fall back to the legacy version.
 	 */
-	if ((ctrl->cap & NVME_CAP_CRMS_CRIMS) ||
-	    (info.ids.csi != NVME_CSI_NVM && info.ids.csi != NVME_CSI_ZNS))
+	if (!nvme_ctrl_limited_cns(ctrl))
 		ret = nvme_ns_info_from_id_cs_indep(ctrl, &info);
-	else
+	if (ret > 0)
 		ret = nvme_ns_info_from_identify(ctrl, &info);
 
 	if (info.is_removed)