From 8ffdd099e6f31afeaa53557061e3b41b2e29b4f2 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 24 Jun 2014 13:33:23 +0000 Subject: [PATCH] ib_srpt: Set SCSI residual fields in SRP_CMD reply git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5622 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 807485476..8b5998914 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -1542,8 +1542,9 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch, int status, const u8 *sense_data, int sense_data_len) { + struct scst_cmd *cmd = &ioctx->scmnd; struct srp_rsp *srp_rsp; - int max_sense_len; + int resid, max_sense_len; /* * The lowest bit of all SAM-3 status codes is zero (see also @@ -1560,6 +1561,23 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch, srp_rsp->tag = tag; srp_rsp->status = status; + if (unlikely(scst_get_resid(cmd, &resid, NULL) && resid != 0)) { + if (scst_cmd_get_data_direction(cmd) & SCST_DATA_READ) { + if (resid > 0) + srp_rsp->flags |= SRP_RSP_FLAG_DIUNDER; + else if (resid < 0) + srp_rsp->flags |= SRP_RSP_FLAG_DIOVER; + srp_rsp->data_in_res_cnt = cpu_to_be32(abs(resid)); + } + if (scst_cmd_get_data_direction(cmd) & SCST_DATA_WRITE) { + if (resid > 0) + srp_rsp->flags |= SRP_RSP_FLAG_DOUNDER; + else if (resid < 0) + srp_rsp->flags |= SRP_RSP_FLAG_DOOVER; + srp_rsp->data_out_res_cnt = cpu_to_be32(abs(resid)); + } + } + if (!scst_sense_valid(sense_data)) sense_data_len = 0; else {