TESTS: simple support for READDEFECTDATA10/12
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -718,6 +718,57 @@ iscsi_readcapacity16_task(struct iscsi_context *iscsi, int lun,
|
||||
return task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_readdefectdata10_task(struct iscsi_context *iscsi, int lun,
|
||||
int req_plist, int req_glist,
|
||||
int defect_list_format, uint16_t alloc_len,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_cdb_readdefectdata10(req_plist, req_glist,
|
||||
defect_list_format, alloc_len);
|
||||
if (task == NULL) {
|
||||
iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
|
||||
"readdefectdata10 cdb.");
|
||||
return NULL;
|
||||
}
|
||||
if (iscsi_scsi_command_async(iscsi, lun, task, cb,
|
||||
NULL, private_data) != 0) {
|
||||
scsi_free_scsi_task(task);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_readdefectdata12_task(struct iscsi_context *iscsi, int lun,
|
||||
int req_plist, int req_glist,
|
||||
int defect_list_format,
|
||||
uint32_t address_descriptor_index,
|
||||
uint32_t alloc_len,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_cdb_readdefectdata12(req_plist, req_glist,
|
||||
defect_list_format,
|
||||
address_descriptor_index, alloc_len);
|
||||
if (task == NULL) {
|
||||
iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
|
||||
"readdefectdata12 cdb.");
|
||||
return NULL;
|
||||
}
|
||||
if (iscsi_scsi_command_async(iscsi, lun, task, cb,
|
||||
NULL, private_data) != 0) {
|
||||
scsi_free_scsi_task(task);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_get_lba_status_task(struct iscsi_context *iscsi, int lun,
|
||||
uint64_t starting_lba, uint32_t alloc_len,
|
||||
|
||||
@@ -69,6 +69,10 @@ iscsi_readcapacity10_sync
|
||||
iscsi_readcapacity10_task
|
||||
iscsi_readcapacity16_sync
|
||||
iscsi_readcapacity16_task
|
||||
iscsi_readdefectdata10_sync
|
||||
iscsi_readdefectdata10_task
|
||||
iscsi_readdefectdata12_sync
|
||||
iscsi_readdefectdata12_task
|
||||
iscsi_readtoc_sync
|
||||
iscsi_readtoc_task
|
||||
iscsi_reserve6_sync
|
||||
@@ -212,6 +216,8 @@ scsi_cdb_read16
|
||||
scsi_cdb_read6
|
||||
scsi_cdb_readcapacity10
|
||||
scsi_cdb_readcapacity16
|
||||
scsi_cdb_readdefectdata10
|
||||
scsi_cdb_readdefectdata12
|
||||
scsi_cdb_readtoc
|
||||
scsi_cdb_receive_copy_results
|
||||
scsi_cdb_reserve6
|
||||
|
||||
@@ -67,6 +67,10 @@ iscsi_readcapacity10_sync
|
||||
iscsi_readcapacity10_task
|
||||
iscsi_readcapacity16_sync
|
||||
iscsi_readcapacity16_task
|
||||
iscsi_readdefectdata10_sync
|
||||
iscsi_readdefectdata10_task
|
||||
iscsi_readdefectdata12_sync
|
||||
iscsi_readdefectdata12_task
|
||||
iscsi_readtoc_sync
|
||||
iscsi_readtoc_task
|
||||
iscsi_reserve6_sync
|
||||
@@ -210,6 +214,8 @@ scsi_cdb_read16
|
||||
scsi_cdb_read6
|
||||
scsi_cdb_readcapacity10
|
||||
scsi_cdb_readcapacity16
|
||||
scsi_cdb_readdefectdata10
|
||||
scsi_cdb_readdefectdata12
|
||||
scsi_cdb_readtoc
|
||||
scsi_cdb_receive_copy_results
|
||||
scsi_cdb_reserve6
|
||||
|
||||
@@ -536,6 +536,75 @@ scsi_cdb_readcapacity10(int lba, int pmi)
|
||||
return task;
|
||||
}
|
||||
|
||||
/*
|
||||
* READDEFECTDATA10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_readdefectdata10(int req_plist, int req_glist, int defect_list_format,
|
||||
uint16_t alloc_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_READ_DEFECT_DATA10;
|
||||
|
||||
if (req_plist) {
|
||||
task->cdb[2] |= 0x10;
|
||||
}
|
||||
if (req_glist) {
|
||||
task->cdb[2] |= 0x08;
|
||||
}
|
||||
task->cdb[2] |= (defect_list_format & 0x07);
|
||||
|
||||
scsi_set_uint16(&task->cdb[7], alloc_len);
|
||||
|
||||
task->cdb_size = 10;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
task->expxferlen = alloc_len;
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
/*
|
||||
* READDEFECTDATA12
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_readdefectdata12(int req_plist, int req_glist, int defect_list_format,
|
||||
uint32_t address_descriptor_index, uint32_t alloc_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_READ_DEFECT_DATA12;
|
||||
|
||||
if (req_plist) {
|
||||
task->cdb[2] |= 0x10;
|
||||
}
|
||||
if (req_glist) {
|
||||
task->cdb[2] |= 0x08;
|
||||
}
|
||||
task->cdb[2] |= (defect_list_format & 0x07);
|
||||
|
||||
scsi_set_uint32(&task->cdb[2], address_descriptor_index);
|
||||
scsi_set_uint32(&task->cdb[6], alloc_len);
|
||||
|
||||
task->cdb_size = 12;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
task->expxferlen = alloc_len;
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
/*
|
||||
* READTOC
|
||||
*/
|
||||
|
||||
49
lib/sync.c
49
lib/sync.c
@@ -614,6 +614,55 @@ iscsi_readcapacity16_sync(struct iscsi_context *iscsi, int lun)
|
||||
return state.task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_readdefectdata10_sync(struct iscsi_context *iscsi, int lun,
|
||||
int req_plist, int req_glist,
|
||||
int defect_list_format, uint16_t alloc_len)
|
||||
{
|
||||
struct iscsi_sync_state state;
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_readdefectdata10_task(iscsi, lun,
|
||||
req_plist, req_glist,
|
||||
defect_list_format, alloc_len,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Failed to send ReadDefectData10 command");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
event_loop(iscsi, &state);
|
||||
|
||||
return state.task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_readdefectdata12_sync(struct iscsi_context *iscsi, int lun,
|
||||
int req_plist, int req_glist,
|
||||
int defect_list_format,
|
||||
uint32_t address_descriptor_index,
|
||||
uint32_t alloc_len)
|
||||
{
|
||||
struct iscsi_sync_state state;
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_readdefectdata12_task(iscsi, lun,
|
||||
req_plist, req_glist,
|
||||
defect_list_format,
|
||||
address_descriptor_index, alloc_len,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Failed to send ReadDefectData12 command");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
event_loop(iscsi, &state);
|
||||
|
||||
return state.task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_sanitize_sync(struct iscsi_context *iscsi, int lun,
|
||||
int immed, int ause, int sa, int param_len,
|
||||
|
||||
Reference in New Issue
Block a user