[PATCH] nvme-core: check id->mc before setting NVME_NS_METADATA_SUPPORTED
Max Gurtovoy
mgurtovoy at nvidia.com
Tue Jun 27 09:02:26 PDT 2023
On 24/06/2023 13:35, Irvin Cote wrote:
> The NVM Command set Identify Namespace Data Structure defines
> the metadata capabilities field (mc) that determines support for
> metadata. Check for the value of this field before enabling the
> NVME_NS_METADATA_SUPPORTED in the nvme_ns data structure.
>
> Signed-off-by: Irvin Cote <irvincoteg at gmail.com>
> ---
> drivers/nvme/host/core.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 3ec38e2b9173..465206b5cf6f 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1841,7 +1841,8 @@ static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
> * Note, this check will need to be modified if any drivers
> * gain the ability to use other metadata formats.
> */
> - if (ctrl->max_integrity_segments && nvme_ns_has_pi(ns))
> + if (ctrl->max_integrity_segments && nvme_ns_has_pi(ns)
> + && (id->mc & NVME_MC_EXTENDED_LBA))
> ns->features |= NVME_NS_METADATA_SUPPORTED;
this probably should go into the WARN_ON_ONCE above since it violate the
spec.
> } else {
> /*
> @@ -1852,7 +1853,7 @@ static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
> */
> if (id->flbas & NVME_NS_FLBAS_META_EXT)
> ns->features |= NVME_NS_EXT_LBAS;
we can check the NVME_MC_EXTENDED_LBA here and WARN_ON_ONCE if there is
a spec violation.
> - else
> + else if (id->mc & NVME_MC_METADATA_PTR)
> ns->features |= NVME_NS_METADATA_SUPPORTED;
same here.
> }
> }
More information about the Linux-nvme
mailing list