From 40869e57d1830c8ea60245890b797c012c9e70f8 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 14 Feb 2010 12:08:47 +0000 Subject: [PATCH] Moved srpt_unmap_sg_to_ib_sge(ch, ioctx) call back into srpt_abort_scst_cmd(). git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1506 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index d75cd0bed..4ee4c7763 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -1029,6 +1029,13 @@ static void srpt_reset_ioctx(struct srpt_rdma_ch *ch, struct srpt_ioctx *ioctx) BUG_ON(!ch); BUG_ON(!ioctx); + /* + * If the WARN_ON() below gets triggered this means that + * srpt_unmap_sg_to_ib_sge() has not been called before + * scst_tgt_cmd_done(). + */ + WARN_ON(ioctx->mapped_sg_count); + if (ioctx->n_rbuf > 1) { kfree(ioctx->rbufs); ioctx->rbufs = NULL; @@ -1075,6 +1082,8 @@ static void srpt_abort_scst_cmd(struct srpt_ioctx *ioctx, TRACE_DBG("Aborting cmd with state %d and tag %lld", state, scst_cmd_get_tag(scmnd)); + srpt_unmap_sg_to_ib_sge(ioctx->ch, ioctx); + switch (state) { case SRPT_STATE_NEW: scst_set_delivery_status(scmnd, SCST_CMD_DELIVERY_ABORTED); @@ -1116,7 +1125,6 @@ static void srpt_handle_err_comp(struct srpt_rdma_ch *ch, struct ib_wc *wc, } else { ioctx = sdev->ioctx_ring[wc->wr_id]; - srpt_unmap_sg_to_ib_sge(ch, ioctx); if (ioctx->scmnd) srpt_abort_scst_cmd(ioctx, context); else @@ -1167,8 +1175,10 @@ static void srpt_handle_rdma_comp(struct srpt_rdma_ch *ch, if (unlikely(scst_cmd_aborted(scmnd))) srpt_abort_scst_cmd(ioctx, context); - else + else { + srpt_unmap_sg_to_ib_sge(ch, ioctx); scst_rx_data(ioctx->scmnd, SCST_RX_STATUS_SUCCESS, context); + } } /** @@ -2632,6 +2642,7 @@ static int srpt_xmit_response(struct scst_cmd *scmnd) scst_cmd_get_sense_buffer_len(scmnd)); if (srpt_post_send(ch, ioctx, resp_len)) { + srpt_unmap_sg_to_ib_sge(ch, ioctx); srpt_set_cmd_state(ioctx, SRPT_STATE_DONE); scst_set_delivery_status(scmnd, SCST_CMD_DELIVERY_FAILED); scst_tgt_cmd_done(scmnd, SCST_CONTEXT_SAME); @@ -2717,13 +2728,6 @@ static void srpt_on_free_cmd(struct scst_cmd *scmnd) WARN_ON(srpt_get_cmd_state(ioctx) != SRPT_STATE_DONE); - /* - * If the WARN_ON() below gets triggered this means that - * srpt_unmap_sg_to_ib_sge() has not been called before - * scst_tgt_cmd_done(). - */ - WARN_ON(ioctx->mapped_sg_count); - ch = ioctx->ch; BUG_ON(!ch);