Add support for STARTSTOPUNIT command
This commit is contained in:
@@ -61,6 +61,8 @@ iscsi_set_isid_reserved
|
||||
iscsi_set_session_type
|
||||
iscsi_set_targetname
|
||||
iscsi_set_tcp_keepalive
|
||||
iscsi_startstopunit_sync
|
||||
iscsi_startstopunit_task
|
||||
iscsi_synchronizecache10_sync
|
||||
iscsi_synchronizecache10_task
|
||||
iscsi_synchronizecache16_sync
|
||||
@@ -115,7 +117,9 @@ scsi_cdb_read6
|
||||
scsi_cdb_readcapacity10
|
||||
scsi_cdb_readcapacity16
|
||||
scsi_cdb_serviceactionin16
|
||||
scsi_cdb_startstopunit
|
||||
scsi_cdb_synchronizecache10
|
||||
scsi_cdb_synchronizecache16
|
||||
scsi_cdb_testunitready
|
||||
scsi_cdb_unmap
|
||||
scsi_cdb_verify10
|
||||
|
||||
@@ -59,6 +59,8 @@ iscsi_set_isid_reserved
|
||||
iscsi_set_session_type
|
||||
iscsi_set_targetname
|
||||
iscsi_set_tcp_keepalive
|
||||
iscsi_startstopunit_sync
|
||||
iscsi_startstopunit_task
|
||||
iscsi_synchronizecache10_sync
|
||||
iscsi_synchronizecache10_task
|
||||
iscsi_synchronizecache16_sync
|
||||
@@ -113,7 +115,9 @@ scsi_cdb_read6
|
||||
scsi_cdb_readcapacity10
|
||||
scsi_cdb_readcapacity16
|
||||
scsi_cdb_serviceactionin16
|
||||
scsi_cdb_startstopunit
|
||||
scsi_cdb_synchronizecache10
|
||||
scsi_cdb_synchronizecache16
|
||||
scsi_cdb_testunitready
|
||||
scsi_cdb_unmap
|
||||
scsi_cdb_verify10
|
||||
|
||||
@@ -1168,6 +1168,30 @@ iscsi_modesense6_task(struct iscsi_context *iscsi, int lun, int dbd, int pc,
|
||||
return task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_startstopunit_task(struct iscsi_context *iscsi, int lun,
|
||||
int immed, int pcm, int pc,
|
||||
int no_flush, int loej, int start,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_cdb_startstopunit(immed, pcm, pc, no_flush,
|
||||
loej, start);
|
||||
if (task == NULL) {
|
||||
iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
|
||||
"startstopunit 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_synchronizecache10_task(struct iscsi_context *iscsi, int lun, int lba,
|
||||
int num_blocks, int syncnv, int immed,
|
||||
|
||||
@@ -1521,6 +1521,51 @@ scsi_modesense_datain_unmarshall(struct scsi_task *task)
|
||||
return ms;
|
||||
}
|
||||
|
||||
/*
|
||||
* STARTSTOPUNIT
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_startstopunit(int immed, int pcm, int pc, int no_flush, int loej, int start)
|
||||
{
|
||||
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_STARTSTOPUNIT;
|
||||
|
||||
if (immed) {
|
||||
task->cdb[1] |= 0x01;
|
||||
}
|
||||
task->cdb[3] |= pcm & 0x0f;
|
||||
task->cdb[4] |= (pc << 4) & 0xf0;
|
||||
if (no_flush) {
|
||||
task->cdb[4] |= 0x04;
|
||||
}
|
||||
if (loej) {
|
||||
task->cdb[4] |= 0x02;
|
||||
}
|
||||
if (start) {
|
||||
task->cdb[4] |= 0x01;
|
||||
}
|
||||
|
||||
|
||||
task->cdb_size = 6;
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
task->expxferlen = 0;
|
||||
|
||||
task->params.startstopunit.immed = immed;
|
||||
task->params.startstopunit.pcm = pcm;
|
||||
task->params.startstopunit.pc = pc;
|
||||
task->params.startstopunit.no_flush = no_flush;
|
||||
task->params.startstopunit.loej = loej;
|
||||
task->params.startstopunit.start = start;
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
/*
|
||||
* SYNCHRONIZECACHE10
|
||||
|
||||
22
lib/sync.c
22
lib/sync.c
@@ -397,6 +397,28 @@ iscsi_synchronizecache10_sync(struct iscsi_context *iscsi, int lun, int lba,
|
||||
return state.task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_startstopunit_sync(struct iscsi_context *iscsi, int lun,
|
||||
int immed, int pcm, int pc,
|
||||
int no_flush, int loej, int start)
|
||||
{
|
||||
struct iscsi_sync_state state;
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_startstopunit_task(iscsi, lun, immed, pcm, pc,
|
||||
no_flush, loej, start,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Failed to send StartStopUnit command");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
event_loop(iscsi, &state);
|
||||
|
||||
return state.task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_synchronizecache16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
uint32_t num_blocks, int syncnv, int immed)
|
||||
|
||||
Reference in New Issue
Block a user