[PATCH 2/2] nvme: convert metadata mapping to dma iter
Christoph Hellwig
hch at lst.de
Wed Jun 25 22:11:07 PDT 2025
On Wed, Jun 25, 2025 at 01:44:45PM -0700, Keith Busch wrote:
> static blk_status_t nvme_pci_setup_meta_sgls(struct request *req)
> {
> struct nvme_queue *nvmeq = req->mq_hctx->driver_data;
> struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
> + struct nvme_dev *dev = nvmeq->dev;
> struct nvme_sgl_desc *sg_list;
> + struct blk_dma_iter iter;
> dma_addr_t sgl_dma;
> + int i = 0;
>
> + if (!blk_rq_integrity_dma_map_iter_start(req, dev->dev, &iter))
> + return iter.status;
If blk_rq_dma_map_coalesce returns true after this, which it will do for
all mappings when using an IOMMU, we can simply set up a single contiguous
metadata pointers here, which will be a lot more efficient than using an
SGL.
> + for (i = 1; i <= iod->nr_meta_descriptors; i++)
> + dma_unmap_page(dev->dev, le64_to_cpu(sg_list[i].addr),
> + le32_to_cpu(sg_list[i].length), dir);
This should walk based on the size of SGL segment descriptor pointed to
by the metadata pointer, similar to what we do for the data SGLs. The
descriptors if counted as by the data mapping path are always one for
SGL mappings (and could in fact just be replaced with a flag if we
cared enough).
More information about the Linux-nvme
mailing list