[PATCHv2 7/7] nvme: convert metadata mapping to dma iter
Christoph Hellwig
hch at lst.de
Mon Jul 21 00:50:53 PDT 2025
> + if (!blk_rq_integrity_dma_map_iter_start(req, dev->dev,
> + &iod->meta_dma_state, &iter))
Do the normal two-tab indent here to make this a bit more readable?
> if (entries == 1) {
> - nvme_pci_sgl_set_data_sg(sg_list, sgl);
> + iod->meta_total_len = iter.len;
> + nvme_pci_sgl_set_data(sg_list, &iter);
> + iod->nr_meta_descriptors = 0;
This should probably just set up the linear metadata pointer instead
of a single-segment SGL.
> + if (!iod->nr_meta_descriptors) {
> + dma_unmap_page(dma_dev, le64_to_cpu(sg_list->addr),
> + le32_to_cpu(sg_list->length), dir);
> + return;
> + }
> +
> + for (i = 1; i <= iod->nr_meta_descriptors; i++)
> + dma_unmap_page(dma_dev, le64_to_cpu(sg_list[i].addr),
> + le32_to_cpu(sg_list[i].length), dir);
> +}
The use of nr_meta_descriptors is still incorrect here. nr_descriptors
counts the number of descriptors we got from the dma pools, which
currently is always 1 for metadata SGLs. The length of the SGL
descriptor simplify comes from le32_to_cpu(sg_list[0].length) divided
by the sgl entry size.
More information about the Linux-nvme
mailing list