aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2014-07-09 09:57:51 -0400
committerRoland Dreier <roland@purestorage.com>2014-08-01 18:21:51 -0400
commite714531a349f614885ca11f68c38270940c5e915 (patch)
tree4df5f32ed7c50dd14437b83cc25fb52dd5ba82ce /drivers/infiniband
parentbcc05910359183b431da92713e98eed478edf83a (diff)
IB/srp: Fix residual handling
From Documentation/scsi/scsi_mid_low_api.txt: "resid - an LLD should set this signed integer to the requested transfer length (i.e. 'request_bufflen') less the number of bytes that are actually transferred." This means that resid > 0 in case of an underrun and also that resid < 0 in case of an overrun. Modify the SRP initiator code such that it matches this requirement. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Reviewed-by: David Dillow <dave@thedillows.org> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 767000811cf9..7f5ee7fc02a6 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1644,10 +1644,14 @@ static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp)
1644 SCSI_SENSE_BUFFERSIZE)); 1644 SCSI_SENSE_BUFFERSIZE));
1645 } 1645 }
1646 1646
1647 if (rsp->flags & (SRP_RSP_FLAG_DOOVER | SRP_RSP_FLAG_DOUNDER)) 1647 if (unlikely(rsp->flags & SRP_RSP_FLAG_DIUNDER))
1648 scsi_set_resid(scmnd, be32_to_cpu(rsp->data_out_res_cnt));
1649 else if (rsp->flags & (SRP_RSP_FLAG_DIOVER | SRP_RSP_FLAG_DIUNDER))
1650 scsi_set_resid(scmnd, be32_to_cpu(rsp->data_in_res_cnt)); 1648 scsi_set_resid(scmnd, be32_to_cpu(rsp->data_in_res_cnt));
1649 else if (unlikely(rsp->flags & SRP_RSP_FLAG_DIOVER))
1650 scsi_set_resid(scmnd, -be32_to_cpu(rsp->data_in_res_cnt));
1651 else if (unlikely(rsp->flags & SRP_RSP_FLAG_DOUNDER))
1652 scsi_set_resid(scmnd, be32_to_cpu(rsp->data_out_res_cnt));
1653 else if (unlikely(rsp->flags & SRP_RSP_FLAG_DOOVER))
1654 scsi_set_resid(scmnd, -be32_to_cpu(rsp->data_out_res_cnt));
1651 1655
1652 srp_free_req(target, req, scmnd, 1656 srp_free_req(target, req, scmnd,
1653 be32_to_cpu(rsp->req_lim_delta)); 1657 be32_to_cpu(rsp->req_lim_delta));