Add support for VERIFY12 and tests

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2012-06-04 20:35:15 +10:00
parent 6003000809
commit 9130d2eb45
13 changed files with 551 additions and 3 deletions

View File

@@ -74,6 +74,8 @@ iscsi_unmap_sync
iscsi_unmap_task
iscsi_verify10_sync
iscsi_verify10_task
iscsi_verify12_sync
iscsi_verify12_task
iscsi_verify16_sync
iscsi_verify16_task
iscsi_which_events
@@ -104,6 +106,7 @@ scsi_cdb_synchronizecache10
scsi_cdb_testunitready
scsi_cdb_unmap
scsi_cdb_verify10
scsi_cdb_verify12
scsi_cdb_verify16
scsi_cdb_write10
scsi_cdb_write12

View File

@@ -72,6 +72,8 @@ iscsi_unmap_sync
iscsi_unmap_task
iscsi_verify10_sync
iscsi_verify10_task
iscsi_verify12_sync
iscsi_verify12_task
iscsi_verify16_sync
iscsi_verify16_task
iscsi_which_events
@@ -102,6 +104,7 @@ scsi_cdb_synchronizecache10
scsi_cdb_testunitready
scsi_cdb_unmap
scsi_cdb_verify10
scsi_cdb_verify12
scsi_cdb_verify16
scsi_cdb_write10
scsi_cdb_write12

View File

@@ -899,6 +899,39 @@ iscsi_verify10_task(struct iscsi_context *iscsi, int lun, unsigned char *data,
return task;
}
struct scsi_task *
iscsi_verify12_task(struct iscsi_context *iscsi, int lun, unsigned char *data,
uint32_t datalen, uint32_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_verify12(lba, datalen, vprotect, dpo, bytchk, blocksize);
if (task == NULL) {
iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
"verify12 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_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,

View File

@@ -978,6 +978,52 @@ scsi_cdb_verify10(uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int byt
return task;
}
/*
* VERIFY12
*/
struct scsi_task *
scsi_cdb_verify12(uint32_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_VERIFY12;
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);
*(uint32_t *)&task->cdb[6] = htonl(xferlen/blocksize);
task->cdb_size = 12;
if (xferlen != 0) {
task->xfer_dir = SCSI_XFER_WRITE;
} else {
task->xfer_dir = SCSI_XFER_NONE;
}
task->expxferlen = xferlen;
task->params.verify12.lba = lba;
task->params.verify12.num_blocks = xferlen/blocksize;
task->params.verify12.vprotect = vprotect;
task->params.verify12.dpo = dpo;
task->params.verify12.bytchk = bytchk;
return task;
}
/*
* VERIFY16
*/
@@ -1025,7 +1071,6 @@ scsi_cdb_verify16(uint64_t lba, uint32_t xferlen, int vprotect, int dpo, int byt
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_verify12_sync(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba,
int vprotect, int dpo, int bytchk, int blocksize)
{
struct iscsi_sync_state state;
memset(&state, 0, sizeof(state));
if (iscsi_verify12_task(iscsi, lun, data, datalen, lba, vprotect, dpo, bytchk, blocksize,
scsi_sync_cb, &state) == NULL) {
iscsi_set_error(iscsi,
"Failed to send Verify12 command");
return NULL;
}
event_loop(iscsi, &state);
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)