From 1856c4985b1e3936ec9912335c4d015381dda928 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 26 Apr 2012 12:37:48 +0000 Subject: [PATCH] ib_srpt: Process chained sg lists correctly git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4235 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index af4798d7b..ee0f4c1eb 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2767,7 +2767,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, struct srpt_send_ioctx *ioctx, struct scst_cmd *scmnd) { - struct scatterlist *sg; + struct scatterlist *sg, *cur_sg; int sg_cnt; scst_data_direction dir; struct rdma_iu *riu; @@ -2842,7 +2842,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, * we need to allocate extra rdma_iu to carry extra #ib_sge in * another rdma wr */ - for (i = 0, j = 0; + for (i = 0, j = 0, cur_sg = sg; j < count && i < ioctx->n_rbuf && tsize > 0; ++i, ++riu, ++db) { rsize = be32_to_cpu(db->len); raddr = be64_to_cpu(db->va); @@ -2861,8 +2861,10 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, if (tsize > 0) { ++j; - if (j < count) - dma_len = sg_dma_len(&sg[j]); + if (j < count) { + cur_sg = sg_next(cur_sg); + dma_len = sg_dma_len(cur_sg); + } } } else { tsize -= rsize; @@ -2896,7 +2898,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, dma_addr = sg_dma_address(&sg[0]); /* this second loop is really mapped sg_addres to rdma_iu->ib_sge */ - for (i = 0, j = 0; + for (i = 0, j = 0, cur_sg = sg; j < count && i < ioctx->n_rbuf && tsize > 0; ++i, ++riu, ++db) { rsize = be32_to_cpu(db->len); sge = riu->sge; @@ -2915,9 +2917,10 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, if (tsize > 0) { ++j; if (j < count) { - dma_len = sg_dma_len(&sg[j]); + cur_sg = sg_next(cur_sg); + dma_len = sg_dma_len(cur_sg); dma_addr = - sg_dma_address(&sg[j]); + sg_dma_address(cur_sg); } } } else {