[PATCH v4 4/8] nvme: always issue I/O Command Set specific Identify Namespace

Caleb Sander Mateos posted 8 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH v4 4/8] 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_update_disk_info(), so always try to obtain it in
nvme_update_ns_info_block(). This Identify structure is first defined in
NVMe spec version 2.0, but controllers reporting older versions could
still implement it.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index bff6f26d7bcf..14e52b260f5d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2352,15 +2352,13 @@ 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) {
-		ret = nvme_identify_ns_nvm(ns->ctrl, info->nsid, &nvm);
-		if (ret < 0)
-			goto out;
-	}
+	ret = nvme_identify_ns_nvm(ns->ctrl, info->nsid, &nvm);
+	if (ret < 0)
+		goto out;
 
 	if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
 	    ns->head->ids.csi == NVME_CSI_ZNS) {
 		ret = nvme_query_zone_info(ns, lbaf, &zi);
 		if (ret < 0)
-- 
2.45.2
Re: [PATCH v4 4/8] nvme: always issue I/O Command Set specific Identify Namespace
Posted by Keith Busch 1 month, 1 week ago
On Thu, Feb 26, 2026 at 12:04:11PM -0700, Caleb Sander Mateos wrote:
> -	if (ns->ctrl->ctratt & NVME_CTRL_ATTR_ELBAS) {
> -		ret = nvme_identify_ns_nvm(ns->ctrl, info->nsid, &nvm);
> -		if (ret < 0)
> -			goto out;
> -	}
> +	ret = nvme_identify_ns_nvm(ns->ctrl, info->nsid, &nvm);
> +	if (ret < 0)
> +		goto out;

I don't think we can do this identify unconditionally. The controller
has to at least pass nvme_id_cns_ok().
Re: [PATCH v4 4/8] nvme: always issue I/O Command Set specific Identify Namespace
Posted by Caleb Sander Mateos 1 month, 1 week ago
On Thu, Feb 26, 2026 at 1:02 PM Keith Busch <kbusch@kernel.org> wrote:
>
> On Thu, Feb 26, 2026 at 12:04:11PM -0700, Caleb Sander Mateos wrote:
> > -     if (ns->ctrl->ctratt & NVME_CTRL_ATTR_ELBAS) {
> > -             ret = nvme_identify_ns_nvm(ns->ctrl, info->nsid, &nvm);
> > -             if (ret < 0)
> > -                     goto out;
> > -     }
> > +     ret = nvme_identify_ns_nvm(ns->ctrl, info->nsid, &nvm);
> > +     if (ret < 0)
> > +             goto out;
>
> I don't think we can do this identify unconditionally. The controller
> has to at least pass nvme_id_cns_ok().

Good point.

Thanks,
Caleb