From f9767e729acfbb9e84bb54c85f3cd831b62908ce Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 18 Nov 2012 09:44:38 -0800 Subject: [PATCH] VERIFY10/12/16 If BYTCHK is false we dont need to transfer any blocks to the target If BYTCHK is false the target will perform a medium check of the indicated LBAs only and not compare with anything out of the DATA-OUT buffers. As such we dont need to/should not transfer any DAT-OUT to the target. --- lib/iscsi-command.c | 15 +++++++++------ lib/scsi-lowlevel.c | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/iscsi-command.c b/lib/iscsi-command.c index fbbd016..626c07b 100644 --- a/lib/iscsi-command.c +++ b/lib/iscsi-command.c @@ -1082,8 +1082,9 @@ iscsi_verify10_task(struct iscsi_context *iscsi, int lun, unsigned char *data, return NULL; } - outdata.data = data; - outdata.size = datalen; + /* We only transfer data if BYTCHK is true */ + outdata.data = bytchk ? data : NULL; + outdata.size = bytchk ? datalen : 0; if (iscsi_scsi_command_async(iscsi, lun, task, cb, &outdata, private_data) != 0) { @@ -1115,8 +1116,9 @@ iscsi_verify12_task(struct iscsi_context *iscsi, int lun, unsigned char *data, return NULL; } - outdata.data = data; - outdata.size = datalen; + /* We only transfer data if BYTCHK is true */ + outdata.data = bytchk ? data : NULL; + outdata.size = bytchk ? datalen : 0; if (iscsi_scsi_command_async(iscsi, lun, task, cb, &outdata, private_data) != 0) { @@ -1148,8 +1150,9 @@ iscsi_verify16_task(struct iscsi_context *iscsi, int lun, unsigned char *data, return NULL; } - outdata.data = data; - outdata.size = datalen; + /* We only transfer data if BYTCHK is true */ + outdata.data = bytchk ? data : NULL; + outdata.size = bytchk ? datalen : 0; if (iscsi_scsi_command_async(iscsi, lun, task, cb, &outdata, private_data) != 0) { diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c index fa14533..b6befee 100644 --- a/lib/scsi-lowlevel.c +++ b/lib/scsi-lowlevel.c @@ -1433,12 +1433,13 @@ scsi_cdb_verify10(uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int byt *(uint16_t *)&task->cdb[7] = htons(xferlen/blocksize); task->cdb_size = 10; - if (xferlen != 0) { + if (xferlen != 0 && bytchk) { task->xfer_dir = SCSI_XFER_WRITE; + task->expxferlen = xferlen; } else { task->xfer_dir = SCSI_XFER_NONE; + task->expxferlen = 0; } - task->expxferlen = xferlen; task->params.verify10.lba = lba; task->params.verify10.num_blocks = xferlen/blocksize; @@ -1479,12 +1480,13 @@ scsi_cdb_verify12(uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int byt *(uint32_t *)&task->cdb[6] = htonl(xferlen/blocksize); task->cdb_size = 12; - if (xferlen != 0) { + if (xferlen != 0 && bytchk) { task->xfer_dir = SCSI_XFER_WRITE; + task->expxferlen = xferlen; } else { task->xfer_dir = SCSI_XFER_NONE; + task->expxferlen = 0; } - task->expxferlen = xferlen; task->params.verify12.lba = lba; task->params.verify12.num_blocks = xferlen/blocksize; @@ -1526,12 +1528,13 @@ scsi_cdb_verify16(uint64_t lba, uint32_t xferlen, int vprotect, int dpo, int byt *(uint32_t *)&task->cdb[10] = htonl(xferlen/blocksize); task->cdb_size = 16; - if (xferlen != 0) { + if (xferlen != 0 && bytchk) { task->xfer_dir = SCSI_XFER_WRITE; + task->expxferlen = xferlen; } else { task->xfer_dir = SCSI_XFER_NONE; + task->expxferlen = 0; } - task->expxferlen = xferlen; task->params.verify16.lba = lba; task->params.verify16.num_blocks = xferlen/blocksize;