Add VERIFY16 support and tests

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2012-06-04 20:16:44 +10:00
parent f6fd18ee3a
commit 6003000809
14 changed files with 725 additions and 1 deletions

View File

@@ -74,6 +74,8 @@ iscsi_unmap_sync
iscsi_unmap_task
iscsi_verify10_sync
iscsi_verify10_task
iscsi_verify16_sync
iscsi_verify16_task
iscsi_which_events
iscsi_write10_sync
iscsi_write10_task
@@ -102,6 +104,7 @@ scsi_cdb_synchronizecache10
scsi_cdb_testunitready
scsi_cdb_unmap
scsi_cdb_verify10
scsi_cdb_verify16
scsi_cdb_write10
scsi_cdb_write12
scsi_cdb_write16

View File

@@ -72,6 +72,8 @@ iscsi_unmap_sync
iscsi_unmap_task
iscsi_verify10_sync
iscsi_verify10_task
iscsi_verify16_sync
iscsi_verify16_task
iscsi_which_events
iscsi_write10_sync
iscsi_write10_task
@@ -100,6 +102,7 @@ scsi_cdb_synchronizecache10
scsi_cdb_testunitready
scsi_cdb_unmap
scsi_cdb_verify10
scsi_cdb_verify16
scsi_cdb_write10
scsi_cdb_write12
scsi_cdb_write16

View File

@@ -899,6 +899,39 @@ iscsi_verify10_task(struct iscsi_context *iscsi, int lun, unsigned char *data,
return task;
}
struct scsi_task *
iscsi_verify16_task(struct iscsi_context *iscsi, int lun, unsigned char *data,
uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize,
iscsi_command_cb cb, void *private_data)
{
struct scsi_task *task;
struct iscsi_data outdata;
if (datalen % blocksize != 0) {
iscsi_set_error(iscsi, "Datalen:%d is not a multiple of the "
"blocksize:%d.", datalen, blocksize);
return NULL;
}
task = scsi_cdb_verify16(lba, datalen, vprotect, dpo, bytchk, blocksize);
if (task == NULL) {
iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
"verify16 cdb.");
return NULL;
}
outdata.data = data;
outdata.size = datalen;
if (iscsi_scsi_command_async(iscsi, lun, task, cb, &outdata,
private_data) != 0) {
scsi_free_scsi_task(task);
return NULL;
}
return task;
}
struct scsi_task *
iscsi_modesense6_task(struct iscsi_context *iscsi, int lun, int dbd, int pc,
int page_code, int sub_page_code,

View File

@@ -978,6 +978,53 @@ scsi_cdb_verify10(uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int byt
return task;
}
/*
* VERIFY16
*/
struct scsi_task *
scsi_cdb_verify16(uint64_t lba, uint32_t xferlen, int vprotect, int dpo, int bytchk, int blocksize)
{
struct scsi_task *task;
task = malloc(sizeof(struct scsi_task));
if (task == NULL) {
return NULL;
}
memset(task, 0, sizeof(struct scsi_task));
task->cdb[0] = SCSI_OPCODE_VERIFY16;
if (vprotect) {
task->cdb[1] |= ((vprotect << 5) & 0xe0);
}
if (dpo) {
task->cdb[1] |= 0x10;
}
if (bytchk) {
task->cdb[1] |= 0x02;
}
*(uint32_t *)&task->cdb[2] = htonl(lba >> 32);
*(uint32_t *)&task->cdb[6] = htonl(lba & 0xffffffff);
*(uint32_t *)&task->cdb[10] = htonl(xferlen/blocksize);
task->cdb_size = 16;
if (xferlen != 0) {
task->xfer_dir = SCSI_XFER_WRITE;
} else {
task->xfer_dir = SCSI_XFER_NONE;
}
task->expxferlen = xferlen;
task->params.verify16.lba = lba;
task->params.verify16.num_blocks = xferlen/blocksize;
task->params.verify16.vprotect = vprotect;
task->params.verify16.dpo = dpo;
task->params.verify16.bytchk = bytchk;
return task;
}
/*
* UNMAP

View File

@@ -523,6 +523,26 @@ iscsi_verify10_sync(struct iscsi_context *iscsi, int lun, unsigned char *data, u
return state.task;
}
struct scsi_task *
iscsi_verify16_sync(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba,
int vprotect, int dpo, int bytchk, int blocksize)
{
struct iscsi_sync_state state;
memset(&state, 0, sizeof(state));
if (iscsi_verify16_task(iscsi, lun, data, datalen, lba, vprotect, dpo, bytchk, blocksize,
scsi_sync_cb, &state) == NULL) {
iscsi_set_error(iscsi,
"Failed to send Verify16 command");
return NULL;
}
event_loop(iscsi, &state);
return state.task;
}
struct scsi_task *
iscsi_writesame10_sync(struct iscsi_context *iscsi, int lun,
unsigned char *data, uint32_t datalen,