[PATCH 3/6] nvme: always issue I/O Command Set specific Identify Namespace

Caleb Sander Mateos posted 6 patches 1 month, 1 week ago
[PATCH 3/6] nvme: always issue I/O Command Set specific Identify Namespace
Posted by Caleb Sander Mateos 1 month, 1 week ago
Currently, the I/O Command Set specific Identify Namespace structure is
only fetched for controllers that support extended LBA formats. This is
because struct nvme_id_ns_nvm is only used by nvme_configure_pi_elbas(),
which is only called when the ELBAS bit is set in the CTRATT field of
the Identify Controller structure.

However, the I/O Command Set specific Identify Namespace structure will
soon be used in nvme_config_discard(), so always try to obtain it in
nvme_update_ns_info_block() if the controller supports NVMe version 2.0
or later.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 674dd823b209..70ff14a56a01 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2351,11 +2351,11 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
 		ret = -ENXIO;
 		goto out;
 	}
 	lbaf = nvme_lbaf_index(id->flbas);
 
-	if (ns->ctrl->ctratt & NVME_CTRL_ATTR_ELBAS) {
+	if (ns->ctrl->vs >= NVME_VS(2, 0, 0)) {
 		ret = nvme_identify_ns_nvm(ns->ctrl, info->nsid, &nvm);
 		if (ret < 0)
 			goto out;
 	}
 
-- 
2.45.2
Re: [PATCH 3/6] nvme: always issue I/O Command Set specific Identify Namespace
Posted by Christoph Hellwig 1 month, 1 week ago
On Thu, Feb 19, 2026 at 08:28:06PM -0700, Caleb Sander Mateos wrote:
> Currently, the I/O Command Set specific Identify Namespace structure is
> only fetched for controllers that support extended LBA formats. This is
> because struct nvme_id_ns_nvm is only used by nvme_configure_pi_elbas(),
> which is only called when the ELBAS bit is set in the CTRATT field of
> the Identify Controller structure.
> 
> However, the I/O Command Set specific Identify Namespace structure will
> soon be used in nvme_config_discard(), so always try to obtain it in
> nvme_update_ns_info_block() if the controller supports NVMe version 2.0
> or later.

This was done kinda intentionally to avoid extra roundtrips and
tripping over buggy implementations.  But I think you have a good
use case to extent this, so:

Reviewed-by: Christoph Hellwig <hch@lst.de>

>  			goto out;
>  	}
>  
> -- 
> 2.45.2
---end quoted text---