libiscsi: Also parse residual if SCSI status != GOOD

This change is needed for the test_write*_residuals tests.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
This commit is contained in:
Bart Van Assche
2014-07-16 15:13:43 +02:00
committed by Ronnie Sahlberg
parent 370741f83d
commit d77765548f

View File

@@ -347,7 +347,7 @@ int
iscsi_process_scsi_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, iscsi_process_scsi_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
struct iscsi_in_pdu *in) struct iscsi_in_pdu *in)
{ {
uint32_t flags, status; uint8_t flags, response, status;
struct iscsi_scsi_cbdata *scsi_cbdata = &pdu->scsi_cbdata; struct iscsi_scsi_cbdata *scsi_cbdata = &pdu->scsi_cbdata;
struct scsi_task *task = scsi_cbdata->task; struct scsi_task *task = scsi_cbdata->task;
@@ -370,21 +370,20 @@ iscsi_process_scsi_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
return -1; return -1;
} }
status = in->hdr[3]; response = in->hdr[2];
switch (status) {
case SCSI_STATUS_GOOD:
case SCSI_STATUS_CONDITION_MET:
task->datain.data = pdu->indata.data;
task->datain.size = pdu->indata.size;
task->residual_status = SCSI_RESIDUAL_NO_RESIDUAL; task->residual_status = SCSI_RESIDUAL_NO_RESIDUAL;
task->residual = 0; task->residual = 0;
/* if (flags & (ISCSI_PDU_DATA_RESIDUAL_OVERFLOW|
* These flags should only be set if the S flag is also set ISCSI_PDU_DATA_RESIDUAL_UNDERFLOW)) {
*/ if (response != 0) {
if (flags & (ISCSI_PDU_DATA_RESIDUAL_OVERFLOW|ISCSI_PDU_DATA_RESIDUAL_UNDERFLOW)) { iscsi_set_error(iscsi, "protocol error: flags %#02x;"
" response %#02x.", flags, response);
pdu->callback(iscsi, SCSI_STATUS_ERROR, task,
pdu->private_data);
return -1;
}
task->residual = scsi_get_uint32(&in->hdr[44]); task->residual = scsi_get_uint32(&in->hdr[44]);
if (flags & ISCSI_PDU_DATA_RESIDUAL_UNDERFLOW) { if (flags & ISCSI_PDU_DATA_RESIDUAL_UNDERFLOW) {
task->residual_status = SCSI_RESIDUAL_UNDERFLOW; task->residual_status = SCSI_RESIDUAL_UNDERFLOW;
@@ -393,6 +392,14 @@ iscsi_process_scsi_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
} }
} }
status = in->hdr[3];
switch (status) {
case SCSI_STATUS_GOOD:
case SCSI_STATUS_CONDITION_MET:
task->datain.data = pdu->indata.data;
task->datain.size = pdu->indata.size;
/* the pdu->datain.data was malloc'ed by iscsi_malloc, /* the pdu->datain.data was malloc'ed by iscsi_malloc,
as long as we have no struct iscsi_task we cannot track as long as we have no struct iscsi_task we cannot track
the free'ing of this buffer which is currently the free'ing of this buffer which is currently