Re: [PATCH v10 23/24] nvme-pci: convert to blk_rq_dma_map

Keith Busch
2025-04-28T16:46:24Z

On Mon, Apr 28, 2025 at 12:22:29PM +0300, Leon Romanovsky wrote:
> + do {
> + if (WARN_ON_ONCE(mapped == entries)) {
> + iter.status = BLK_STS_IOERR;
> + break;
> + }
> + nvme_pci_sgl_set_data(&sg_list[mapped++], &iter);

I think this should say "++mapped" so that the data blocks start at
index 1 (continued below...)

> + iod->total_len += iter.len;
> + } while (blk_rq_dma_map_iter_next(req, dev->dev, &iod->dma_meta_state,
> + &iter));
>
> -out_unmap_sg:
> - dma_unmap_sgtable(dev->dev, &iod->meta_sgt, rq_dma_dir(req), 0);
> -out_free_sg:
> - mempool_free(iod->meta_sgt.sgl, dev->iod_meta_mempool);
> - return BLK_STS_RESOURCE;
> + nvme_pci_sgl_set_seg(sg_list, sgl_dma, mapped);

because this here is setting sg_list index 0 to be the segment
descriptor.

And you also need to increment sgl_dma to point to the element after
sg_list, otherwise it's pointing right back to itself, creating a looped
list.

> + if (unlikely(iter.status))
> + nvme_unmap_metadata(dev, req);
> + return iter.status;
> }