Commit a40c20a6 authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

nvme-pci: don't try to use SGLs for metadata on the admin queue



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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
Reviewed-by: default avatarLeon Romanovsky <leon@kernel.org>
parent d977506f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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);
}