From cb7882a84ce47f5b87799e77e7965724ddf3c3af Mon Sep 17 00:00:00 2001 From: Sebastian Herbszt Date: Sun, 15 Feb 2015 22:26:32 +0100 Subject: [PATCH] test-tool: fix SG_IO Handle io_hdr.resid and adjust datain.size. Signed-off-by: Sebastian Herbszt --- test-tool/iscsi-support.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 3c69d9c..abdde7d 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -277,6 +277,17 @@ static struct scsi_task *send_scsi_command(struct scsi_device *sdev, struct scsi return NULL; } + task->residual_status = SCSI_RESIDUAL_NO_RESIDUAL; + task->residual = 0; + + if (io_hdr.resid) { + task->residual_status = SCSI_RESIDUAL_UNDERFLOW; + task->residual = io_hdr.resid; + } + + if (task->xfer_dir == SCSI_XFER_READ) + task->datain.size -= task->residual; + /* now for the error processing */ if(io_hdr.sb_len_wr > 0){ task->status = SCSI_STATUS_CHECK_CONDITION;