[bug report] nvme sends invalid command capsule over rdma transport for 5KiB write when target supports MSDBD > 1

Christoph Hellwig hch at infradead.org
Wed May 26 07:10:52 PDT 2021


On Wed, May 26, 2021 at 02:12:08AM -0700, Sagi Grimberg wrote:
>  {
> -       struct nvme_sgl_desc *sg = &c->common.dptr.sgl;
> -       struct scatterlist *sgl = req->data_sgl.sg_table.sgl;
> +       struct nvme_sgl_desc *sgl = &c->common.dptr.sgl;
> +       struct scatterlist *sg, *scat = req->data_sgl.sg_table.sgl;
>         struct ib_sge *sge = &req->sge[1];
>         u32 len = 0;
>         int i;
> 
> -       for (i = 0; i < count; i++, sgl++, sge++) {
> -               sge->addr = sg_dma_address(sgl);
> -               sge->length = sg_dma_len(sgl);
> +       for_each_sg(scat, sg, count, i) {
> +               sge->addr = sg_dma_address(sg);
> +               sge->length = sg_dma_len(sg);
>                 sge->lkey = queue->device->pd->local_dma_lkey;
>                 len += sge->length;
>         }

We do need for_each_sg here indeed, but you also need to keep
incrementing sge for each loop iteration.  I think we can also
drop the scat local variable with just a single users and all the
renaming while we're at it.



More information about the Linux-nvme mailing list