From 4d9c05f1ee6054f8d9e2162c2026d6da6f0368aa Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 14 Oct 2015 22:22:19 +0000 Subject: [PATCH] ib_srpt: Increase maximum sg-list length from 128 to 65536 This avoids that the following message appears in the target system kernel log: Unable to complete command due to SG IO count limitation git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6545 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 3a69578a8..7579ea64c 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -1449,15 +1449,24 @@ static void srpt_handle_send_err_comp(struct srpt_rdma_ch *ch, u64 wr_id, { u32 index = idx_from_wr_id(wr_id); struct srpt_send_ioctx *ioctx = ch->ioctx_ring[index]; + struct scst_cmd *cmd = &ioctx->cmd; enum srpt_command_state state = ioctx->state; - - srpt_adjust_sq_wr_avail(ch, 1); + int wr_avail_delta = 1; switch (state) { case SRPT_STATE_NEED_DATA: srpt_abort_cmd(ioctx, context); break; case SRPT_STATE_CMD_RSP_SENT: + if (scst_cmd_get_data_direction(cmd) == SCST_DATA_READ) { + /* + * IB_SEND_SIGNALED is not set for RDMA writes so + * process the wr_avail delta when the response + * send completion has been received. + */ + EXTRACHECKS_WARN_ON(ioctx->n_rdma <= 0); + wr_avail_delta += ioctx->n_rdma; + } srpt_undo_inc_req_lim(ch, ioctx->req_lim_delta); srpt_abort_cmd(ioctx, context); break; @@ -1473,6 +1482,8 @@ static void srpt_handle_send_err_comp(struct srpt_rdma_ch *ch, u64 wr_id, EXTRACHECKS_WARN_ON(true); break; } + + srpt_adjust_sq_wr_avail(ch, wr_avail_delta); } /** @@ -1482,10 +1493,20 @@ static void srpt_handle_send_comp(struct srpt_rdma_ch *ch, struct srpt_send_ioctx *ioctx, enum scst_exec_context context) { - srpt_adjust_sq_wr_avail(ch, 1); + struct scst_cmd *cmd = &ioctx->cmd; + int wr_avail_delta = 1; switch (srpt_set_cmd_state(ioctx, SRPT_STATE_DONE)) { case SRPT_STATE_CMD_RSP_SENT: + if (scst_cmd_get_data_direction(cmd) == SCST_DATA_READ) { + /* + * IB_SEND_SIGNALED is not set for RDMA writes so + * process the wr_avail delta when the response + * send completion has been received. + */ + EXTRACHECKS_WARN_ON(ioctx->n_rdma <= 0); + wr_avail_delta += ioctx->n_rdma; + } srpt_unmap_sg_to_ib_sge(ch, ioctx); scst_tgt_cmd_done(&ioctx->cmd, context); break; @@ -1499,6 +1520,8 @@ static void srpt_handle_send_comp(struct srpt_rdma_ch *ch, default: EXTRACHECKS_WARN_ON(true); } + + srpt_adjust_sq_wr_avail(ch, wr_avail_delta); } /** @@ -3347,18 +3370,15 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, struct ib_send_wr *bad_wr; struct rdma_iu *riu; int i; - int ret; + int ret = -ENOMEM; int sq_wr_avail; const int n_rdma = ioctx->n_rdma; - if (dir == SCST_DATA_WRITE) { - ret = -ENOMEM; - sq_wr_avail = srpt_adjust_sq_wr_avail(ch, -n_rdma); - if (sq_wr_avail < 0) { - pr_warn("ch %s-%d send queue full (needed %d)\n", - ch->sess_name, ch->qp->qp_num, n_rdma); - goto out; - } + sq_wr_avail = srpt_adjust_sq_wr_avail(ch, -n_rdma); + if (sq_wr_avail < 0) { + pr_warn("ch %s-%d send queue full (needed %d)\n", + ch->sess_name, ch->qp->qp_num, n_rdma); + goto out; } ioctx->rdma_aborted = false; @@ -3421,7 +3441,7 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, } out: - if (unlikely(dir == SCST_DATA_WRITE && ret < 0)) + if (unlikely(ret < 0)) srpt_adjust_sq_wr_avail(ch, n_rdma); return ret; }