Add support for PERSISTENT_RESERVE_IN and add a simple test for READ_KEYS

This commit is contained in:
Ronnie Sahlberg
2012-12-17 19:01:50 -08:00
parent f1d3aa073f
commit c60093eafe
11 changed files with 213 additions and 1 deletions

View File

@@ -1254,6 +1254,28 @@ iscsi_synchronizecache16_task(struct iscsi_context *iscsi, int lun, uint64_t lba
return task;
}
struct scsi_task *
iscsi_persistent_reserve_in_task(struct iscsi_context *iscsi, int lun,
int sa, uint16_t xferlen,
iscsi_command_cb cb, void *private_data)
{
struct scsi_task *task;
task = scsi_cdb_persistent_reserve_in(sa, xferlen);
if (task == NULL) {
iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
"persistent-reserver-in 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_prefetch10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
int num_blocks, int immed, int group,

View File

@@ -28,6 +28,8 @@ iscsi_modesense6_task
iscsi_nop_out_async
iscsi_parse_full_url
iscsi_parse_portal_url
iscsi_persistent_reserve_in_task
iscsi_persistent_reserve_in_sync
iscsi_prefetch10_sync
iscsi_prefetch10_task
iscsi_prefetch16_sync
@@ -133,6 +135,7 @@ scsi_association_to_str
scsi_cdb_inquiry
scsi_cdb_get_lba_status
scsi_cdb_modesense6
scsi_cdb_persistent_reserve_in
scsi_cdb_prefetch10
scsi_cdb_prefetch16
scsi_cdb_preventallow

View File

@@ -26,6 +26,8 @@ iscsi_modesense6_task
iscsi_nop_out_async
iscsi_parse_full_url
iscsi_parse_portal_url
iscsi_persistent_reserve_in_task
iscsi_persistent_reserve_in_sync
iscsi_prefetch10_sync
iscsi_prefetch10_task
iscsi_prefetch16_sync
@@ -131,6 +133,7 @@ scsi_association_to_str
scsi_cdb_inquiry
scsi_cdb_get_lba_status
scsi_cdb_modesense6
scsi_cdb_persistent_reserve_in
scsi_cdb_prefetch10
scsi_cdb_prefetch16
scsi_cdb_preventallow

View File

@@ -1611,6 +1611,37 @@ scsi_cdb_unmap(int anchor, int group, uint16_t xferlen)
return task;
}
/*
* PERSISTENT_RESEERVE_IN
*/
struct scsi_task *
scsi_cdb_persistent_reserve_in(enum scsi_persistent_in_sa sa, uint16_t xferlen)
{
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_PERSISTENT_RESERVE_IN;
task->cdb[1] |= sa & 0x1f;
scsi_set_uint16(&task->cdb[7], xferlen);
task->cdb_size = 10;
if (xferlen != 0) {
task->xfer_dir = SCSI_XFER_READ;
} else {
task->xfer_dir = SCSI_XFER_NONE;
}
task->expxferlen = xferlen;
return task;
}
/*
* WRITE_SAME10
*/

View File

@@ -798,6 +798,26 @@ iscsi_writesame16_sync(struct iscsi_context *iscsi, int lun,
return state.task;
}
struct scsi_task *
iscsi_persistent_reserve_in_sync(struct iscsi_context *iscsi, int lun,
int sa, uint16_t xferlen)
{
struct iscsi_sync_state state;
memset(&state, 0, sizeof(state));
if (iscsi_persistent_reserve_in_task(iscsi, lun, sa, xferlen,
scsi_sync_cb, &state) == NULL) {
iscsi_set_error(iscsi,
"Failed to send PERSISTENT_RESERVE_IN command");
return NULL;
}
event_loop(iscsi, &state);
return state.task;
}
struct scsi_task *
iscsi_unmap_sync(struct iscsi_context *iscsi, int lun, int anchor, int group,
struct unmap_list *list, int list_len)