[PATCH 1/7] nvme-pci: don't try to use SGLs for metadata on the admin queue
Leon Romanovsky
leon at kernel.org
Tue May 13 00:28:42 PDT 2025
On Tue, May 13, 2025 at 09:00:17AM +0200, Christoph Hellwig wrote:
> No admin command defined in an NVMe specification supports metadata,
> but to protect against vendor specific commands using metadata ensure
> that we don't try to use SGLs for metadata on the admin queue, as NVMe
> does not support SGLs on the admin queue for the PCI transport. Do
> this by checking if the data transfer has been setup using SGLs as
> that is required for using SGLs for metadata.
>
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
> drivers/nvme/host/pci.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index e6b6b6ee0878..24f5292a349b 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -971,7 +971,10 @@ static blk_status_t nvme_pci_setup_meta_mptr(struct nvme_dev *dev,
>
> static blk_status_t nvme_map_metadata(struct nvme_dev *dev, struct request *req)
> {
> - if (nvme_pci_metadata_use_sgls(dev, req))
> + struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
> +
> + if ((iod->cmd.common.flags & NVME_CMD_SGL_METABUF) &&
Won't it be more future error proof to check for NVME_CMD_SGL_ALL?
Anyway current proposal is also fine.
Thanks,
Reviewed-by: Leon Romanovsky <leon at kernel.org>
More information about the Linux-nvme
mailing list