]> www.infradead.org Git - nvme.git/commitdiff
nvme-pci: don't try to use SGLs for metadata on the admin queue
authorChristoph Hellwig <hch@lst.de>
Sun, 11 May 2025 04:04:27 +0000 (06:04 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 20 May 2025 03:34:27 +0000 (05:34 +0200)
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@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Leon Romanovsky <leon@kernel.org>
drivers/nvme/host/pci.c

index e6b6b6ee08786f596423d6765765a9b0994cd299..24f5292a349b9198b0e4bc5e39af2a87576cdb55 100644 (file)
@@ -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) &&
+           nvme_pci_metadata_use_sgls(dev, req))
                return nvme_pci_setup_meta_sgls(dev, req);
        return nvme_pci_setup_meta_mptr(dev, req);
 }