Add initial support for SANITIZE and a simple test to generate this opcode.

This commit is contained in:
Ronnie Sahlberg
2013-05-25 16:02:02 -07:00
parent 28cc715a7c
commit eebd04e613
13 changed files with 226 additions and 1 deletions

View File

@@ -56,6 +56,7 @@ uint64_t num_blocks;
int lbppb;
enum scsi_inquiry_peripheral_device_type device_type;
int data_loss;
int allow_sanitize;
int readonly;
int sbc3_support;
int maximum_transfer_length;
@@ -1313,6 +1314,42 @@ synchronizecache16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba,
return 0;
}
int sanitize(struct iscsi_context *iscsi, int lun, int immed, int ause, int sa, int param_len, struct iscsi_data *data)
{
struct scsi_task *task;
logging(LOG_VERBOSE, "Send SANITIZE IMMED:%d AUSE:%d SA:%d "
"PARAM_LEN:%d",
immed, ause, sa, param_len);
task = iscsi_sanitize_sync(iscsi, lun, immed, ause, sa, param_len,
data);
if (task == NULL) {
logging(LOG_NORMAL,
"[FAILED] Failed to send SANITIZE command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
"implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_NORMAL,
"[FAILED] SANITIZE command: failed with sense. %s",
iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] SANITIZE returned SUCCESS.");
return 0;
}
int startstopunit(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start)
{
struct scsi_task *task;