From 7fe457cea872538a23648f6942cb89c1d3a9c003 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Mon, 18 Apr 2011 17:31:47 +1000 Subject: [PATCH] We can get over/underflow residuals in a DATA-IN segment if/when the S bit is set too. --- lib/scsi-command.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/scsi-command.c b/lib/scsi-command.c index c1c169e..f2469a5 100644 --- a/lib/scsi-command.c +++ b/lib/scsi-command.c @@ -455,6 +455,21 @@ iscsi_process_scsi_data_in(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, return 0; } + task->residual_status = SCSI_RESIDUAL_NO_RESIDUAL; + task->residual = 0; + + /* + * These flags should only be set if the S flag is also set + */ + if (flags & (ISCSI_PDU_DATA_RESIDUAL_OVERFLOW|ISCSI_PDU_DATA_RESIDUAL_UNDERFLOW)) { + task->residual = ntohl(*((uint32_t *)&in->hdr[44])); + if (flags & ISCSI_PDU_DATA_RESIDUAL_UNDERFLOW) { + task->residual_status = SCSI_RESIDUAL_UNDERFLOW; + } else { + task->residual_status = SCSI_RESIDUAL_OVERFLOW; + } + } + /* this was the final data-in packet in the sequence and it has * the s-bit set, so invoke the callback.