]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iser-target: Fix variable-length response error completion
authorSagi Grimberg <sagig@mellanox.com>
Thu, 4 Jun 2015 16:49:19 +0000 (19:49 +0300)
committerSasha Levin <sasha.levin@oracle.com>
Thu, 2 Jul 2015 01:44:05 +0000 (21:44 -0400)
[ Upstream commit 9253e667ab50fd4611a60e1cdd6a6e05a1d91cf1 ]

Since commit "2426bd456a6 target: Report correct response ..."
we might get a command with data_size that does not fit to
the number of allocated data sg elements. Given that we rely on
cmd t_data_nents which might be different than the data_size,
we sometimes receive local length error completion. The correct
approach would be to take the command data_size into account when
constructing the ib sg_list.

Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Jenny Falkovich <jennyf@mellanox.com>
Cc: stable@vger.kernel.org # 3.16+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/infiniband/ulp/isert/ib_isert.c

index 0618e407197db60af57d9e428bba264432683af7..9fdf1a4376dbc26e8c1eba36d17096b57ef612f9 100644 (file)
@@ -2485,7 +2485,6 @@ isert_build_rdma_wr(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
        page_off = offset % PAGE_SIZE;
 
        send_wr->sg_list = ib_sge;
-       send_wr->num_sge = sg_nents;
        send_wr->wr_id = (unsigned long)&isert_cmd->tx_desc;
        /*
         * Perform mapping of TCM scatterlist memory ib_sge dma_addr.
@@ -2504,14 +2503,17 @@ isert_build_rdma_wr(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
                         ib_sge->addr, ib_sge->length, ib_sge->lkey);
                page_off = 0;
                data_left -= ib_sge->length;
+               if (!data_left)
+                       break;
                ib_sge++;
                pr_debug("Incrementing ib_sge pointer to %p\n", ib_sge);
        }
 
+       send_wr->num_sge = ++i;
        pr_debug("Set outgoing sg_list: %p num_sg: %u from TCM SGLs\n",
                 send_wr->sg_list, send_wr->num_sge);
 
-       return sg_nents;
+       return send_wr->num_sge;
 }
 
 static int