Add initial support for SANITIZE and a simple test to generate this opcode.
This commit is contained in:
@@ -1632,6 +1632,30 @@ iscsi_release6_task(struct iscsi_context *iscsi, int lun,
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_sanitize_task(struct iscsi_context *iscsi, int lun,
|
||||
int immed, int ause, int sa, int param_len,
|
||||
struct iscsi_data *data,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_cdb_sanitize(immed, ause, sa, param_len);
|
||||
if (task == NULL) {
|
||||
iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
|
||||
"sanitize cdb.");
|
||||
return NULL;
|
||||
}
|
||||
if (iscsi_scsi_command_async(iscsi, lun, task, cb,
|
||||
data, private_data) != 0) {
|
||||
scsi_free_scsi_task(task);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_report_supported_opcodes_task(struct iscsi_context *iscsi, int lun,
|
||||
int rctd, int options,
|
||||
|
||||
@@ -61,6 +61,8 @@ iscsi_release6_task
|
||||
iscsi_report_supported_opcodes_sync
|
||||
iscsi_report_supported_opcodes_task
|
||||
iscsi_reconnect
|
||||
iscsi_sanitize_sync
|
||||
iscsi_sanitize_task
|
||||
iscsi_set_noautoreconnect
|
||||
iscsi_set_reconnect_max_retries
|
||||
iscsi_set_timeout
|
||||
@@ -159,6 +161,7 @@ scsi_cdb_readtoc
|
||||
scsi_cdb_reserve6
|
||||
scsi_cdb_release6
|
||||
scsi_cdb_report_supported_opcodes
|
||||
scsi_cdb_sanitize
|
||||
scsi_cdb_serviceactionin16
|
||||
scsi_cdb_startstopunit
|
||||
scsi_cdb_synchronizecache10
|
||||
|
||||
@@ -59,6 +59,8 @@ iscsi_release6_task
|
||||
iscsi_report_supported_opcodes_sync
|
||||
iscsi_report_supported_opcodes_task
|
||||
iscsi_reconnect
|
||||
iscsi_sanitize_sync
|
||||
iscsi_sanitize_task
|
||||
iscsi_set_noautoreconnect
|
||||
iscsi_set_reconnect_max_retries
|
||||
iscsi_set_timeout
|
||||
@@ -157,6 +159,7 @@ scsi_cdb_readtoc
|
||||
scsi_cdb_reserve6
|
||||
scsi_cdb_release6
|
||||
scsi_cdb_report_supported_opcodes
|
||||
scsi_cdb_sanitize
|
||||
scsi_cdb_serviceactionin16
|
||||
scsi_cdb_startstopunit
|
||||
scsi_cdb_synchronizecache10
|
||||
|
||||
@@ -332,6 +332,42 @@ scsi_cdb_testunitready(void)
|
||||
return task;
|
||||
}
|
||||
|
||||
/*
|
||||
* SANITIZE
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_sanitize(int immed, int ause, int sa, int param_len)
|
||||
{
|
||||
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_SANITIZE;
|
||||
|
||||
task->cdb[1] = sa & 0x1f;
|
||||
if (immed) {
|
||||
task->cdb[1] |= 0x80;
|
||||
}
|
||||
if (ause) {
|
||||
task->cdb[1] |= 0x20;
|
||||
}
|
||||
|
||||
scsi_set_uint16(&task->cdb[7], param_len);
|
||||
|
||||
task->cdb_size = 10;
|
||||
if (param_len != 0) {
|
||||
task->xfer_dir = SCSI_XFER_WRITE;
|
||||
} else {
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
}
|
||||
task->expxferlen = param_len;
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
/*
|
||||
* REPORTLUNS
|
||||
|
||||
22
lib/sync.c
22
lib/sync.c
@@ -481,6 +481,28 @@ iscsi_readcapacity16_sync(struct iscsi_context *iscsi, int lun)
|
||||
return state.task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_sanitize_sync(struct iscsi_context *iscsi, int lun,
|
||||
int immed, int ause, int sa, int param_len,
|
||||
struct iscsi_data *data)
|
||||
{
|
||||
struct iscsi_sync_state state;
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_sanitize_task(iscsi, lun,
|
||||
immed, ause, sa, param_len, data,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Failed to send Sanitize command");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
event_loop(iscsi, &state);
|
||||
|
||||
return state.task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_get_lba_status_sync(struct iscsi_context *iscsi, int lun, uint64_t starting_lba, uint32_t alloc_len)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user