From 2277551e22cb180528c6384e6fbe06a79350beba Mon Sep 17 00:00:00 2001 From: Yan Burman Date: Mon, 13 Oct 2014 12:32:41 +0000 Subject: [PATCH] isert: Make sure we do dma_unmap on RDMA memory upon flushes Signed-off-by: Yan Burman git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/iser@5838 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/isert-scst/iser_rdma.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index 7af9f43fc..8e2dcf817 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -521,6 +521,9 @@ static void isert_handle_wc_error(struct ib_wc *wc) struct isert_wr *wr = _u64_to_ptr(wc->wr_id); struct isert_cmnd *isert_pdu = wr->pdu; struct isert_connection *isert_conn = wr->conn; + struct isert_buf *isert_buf = wr->buf; + struct isert_device *isert_dev = wr->isert_dev; + struct ib_device *ib_dev = isert_dev->ib_dev; TRACE_ENTRY(); @@ -537,11 +540,22 @@ static void isert_handle_wc_error(struct ib_wc *wc) isert_pdu_err(&isert_pdu->iscsi); break; case ISER_WR_RDMA_READ: + if (isert_buf->sg_cnt != 0) { + isert_buf->sg_cnt = 0; + ib_dma_unmap_sg(ib_dev, isert_buf->sg, isert_buf->sg_cnt, + isert_buf->dma_dir); + } isert_pdu_err(&isert_pdu->iscsi); break; case ISER_WR_RECV: /* this should be the Flush, no task has been created yet */ + break; case ISER_WR_RDMA_WRITE: + if (isert_buf->sg_cnt != 0) { + isert_buf->sg_cnt = 0; + ib_dma_unmap_sg(ib_dev, isert_buf->sg, isert_buf->sg_cnt, + isert_buf->dma_dir); + } /* RDMA-WR and SEND response of a READ task are sent together, so when receiving RDMA-WR error, wait until SEND error arrives to complete the task */