Add PREVENTALLOWMEDIUMREMOVAL support

This commit is contained in:
Ronnie Sahlberg
2012-07-17 18:12:03 +10:00
parent 4a3935770d
commit 16da01ed4e
7 changed files with 89 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ iscsi_prefetch10_sync
iscsi_prefetch10_task
iscsi_prefetch16_sync
iscsi_prefetch16_task
iscsi_preventallow_sync
iscsi_preventallow_task
iscsi_queue_length
iscsi_read10_sync
iscsi_read10_task
@@ -110,6 +112,7 @@ scsi_cdb_get_lba_status
scsi_cdb_modesense6
scsi_cdb_prefetch10
scsi_cdb_prefetch16
scsi_cdb_preventallow
scsi_cdb_read10
scsi_cdb_read12
scsi_cdb_read16

View File

@@ -28,6 +28,8 @@ iscsi_prefetch10_sync
iscsi_prefetch10_task
iscsi_prefetch16_sync
iscsi_prefetch16_task
iscsi_preventallow_sync
iscsi_preventallow_task
iscsi_queue_length
iscsi_read10_sync
iscsi_read10_task
@@ -108,6 +110,7 @@ scsi_cdb_get_lba_status
scsi_cdb_modesense6
scsi_cdb_prefetch10
scsi_cdb_prefetch16
scsi_cdb_preventallow
scsi_cdb_read10
scsi_cdb_read12
scsi_cdb_read16

View File

@@ -1192,6 +1192,28 @@ iscsi_startstopunit_task(struct iscsi_context *iscsi, int lun,
return task;
}
struct scsi_task *
iscsi_preventallow_task(struct iscsi_context *iscsi, int lun,
int prevent,
iscsi_command_cb cb, void *private_data)
{
struct scsi_task *task;
task = scsi_cdb_preventallow(prevent);
if (task == NULL) {
iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
"PreventAllowMediumRemoval 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,

View File

@@ -1567,6 +1567,33 @@ scsi_cdb_startstopunit(int immed, int pcm, int pc, int no_flush, int loej, int s
return task;
}
/*
* PREVENTALLOWMEDIUMREMOVAL
*/
struct scsi_task *
scsi_cdb_preventallow(int prevent)
{
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_PREVENTALLOW;
task->cdb[4] = prevent & 0x03;
task->cdb_size = 6;
task->xfer_dir = SCSI_XFER_NONE;
task->expxferlen = 0;
task->params.preventallow.prevent = prevent;
return task;
}
/*
* SYNCHRONIZECACHE10
*/

View File

@@ -419,6 +419,26 @@ iscsi_startstopunit_sync(struct iscsi_context *iscsi, int lun,
return state.task;
}
struct scsi_task *
iscsi_preventallow_sync(struct iscsi_context *iscsi, int lun,
int prevent)
{
struct iscsi_sync_state state;
memset(&state, 0, sizeof(state));
if (iscsi_preventallow_task(iscsi, lun, prevent,
scsi_sync_cb, &state) == NULL) {
iscsi_set_error(iscsi,
"Failed to send PreventAllowMediumRemoval 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)