Add PREFETCH10/16 implementations
This commit is contained in:
@@ -588,6 +588,16 @@ iscsi_synchronizecache10_task(struct iscsi_context *iscsi, int lun,
|
||||
int immed, iscsi_command_cb cb,
|
||||
void *private_data);
|
||||
EXTERN struct scsi_task *
|
||||
iscsi_prefetch10_task(struct iscsi_context *iscsi, int lun,
|
||||
uint32_t lba, int num_blocks,
|
||||
int immed, int group,
|
||||
iscsi_command_cb cb, void *private_data);
|
||||
EXTERN struct scsi_task *
|
||||
iscsi_prefetch16_task(struct iscsi_context *iscsi, int lun,
|
||||
uint64_t lba, int num_blocks,
|
||||
int immed, int group,
|
||||
iscsi_command_cb cb, void *private_data);
|
||||
EXTERN struct scsi_task *
|
||||
iscsi_read6_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, iscsi_command_cb cb,
|
||||
void *private_data);
|
||||
@@ -720,6 +730,14 @@ EXTERN struct scsi_task *
|
||||
iscsi_synchronizecache10_sync(struct iscsi_context *iscsi, int lun, int lba,
|
||||
int num_blocks, int syncnv, int immed);
|
||||
|
||||
EXTERN struct scsi_task *
|
||||
iscsi_prefetch10_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
int num_blocks, int immed, int group);
|
||||
|
||||
EXTERN struct scsi_task *
|
||||
iscsi_prefetch16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
int num_blocks, int immed, int group);
|
||||
|
||||
EXTERN struct scsi_task *
|
||||
iscsi_verify10_sync(struct iscsi_context *iscsi, int lun,
|
||||
unsigned char *data, uint32_t datalen, uint32_t lba,
|
||||
|
||||
@@ -28,11 +28,13 @@ enum scsi_opcode {
|
||||
SCSI_OPCODE_READ10 = 0x28,
|
||||
SCSI_OPCODE_WRITE10 = 0x2A,
|
||||
SCSI_OPCODE_VERIFY10 = 0x2F,
|
||||
SCSI_OPCODE_PREFETCH10 = 0x34,
|
||||
SCSI_OPCODE_SYNCHRONIZECACHE10 = 0x35,
|
||||
SCSI_OPCODE_WRITE_SAME10 = 0x41,
|
||||
SCSI_OPCODE_UNMAP = 0x42,
|
||||
SCSI_OPCODE_READ16 = 0x88,
|
||||
SCSI_OPCODE_WRITE16 = 0x8A,
|
||||
SCSI_OPCODE_PREFETCH16 = 0x90,
|
||||
SCSI_OPCODE_WRITE_SAME16 = 0x93,
|
||||
SCSI_OPCODE_SERVICE_ACTION_IN = 0x9E,
|
||||
SCSI_OPCODE_REPORTLUNS = 0xA0,
|
||||
@@ -593,6 +595,8 @@ EXTERN struct scsi_task *scsi_cdb_readcapacity16(void);
|
||||
EXTERN struct scsi_task *scsi_cdb_unmap(int anchor, int group, uint16_t xferlen);
|
||||
EXTERN struct scsi_task *scsi_cdb_writesame10(int wrprotect, int anchor, int unmap, int pbdata, int lbdata, uint32_t lba, int group, uint16_t num_blocks);
|
||||
EXTERN struct scsi_task *scsi_cdb_writesame16(int wrprotect, int anchor, int unmap, int pbdata, int lbdata, uint64_t lba, int group, uint32_t num_blocks);
|
||||
EXTERN struct scsi_task *scsi_cdb_prefetch10(uint32_t lba, int num_blocks, int immed, int group);
|
||||
EXTERN struct scsi_task *scsi_cdb_prefetch16(uint64_t lba, int num_blocks, int immed, int group);
|
||||
|
||||
void *scsi_malloc(struct scsi_task *task, size_t size);
|
||||
|
||||
|
||||
@@ -924,6 +924,49 @@ iscsi_synchronizecache10_task(struct iscsi_context *iscsi, int lun, int lba,
|
||||
return task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_prefetch10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
int num_blocks, int immed, int group,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_cdb_prefetch10(lba, num_blocks, immed, group);
|
||||
if (task == NULL) {
|
||||
iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
|
||||
"prefetch10 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_prefetch16_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
int num_blocks, int immed, int group,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_cdb_prefetch16(lba, num_blocks, immed, group);
|
||||
if (task == NULL) {
|
||||
iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
|
||||
"prefetch16 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_writesame10_task(struct iscsi_context *iscsi, int lun,
|
||||
|
||||
@@ -1288,6 +1288,68 @@ scsi_cdb_synchronizecache10(int lba, int num_blocks, int syncnv, int immed)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* PREFETCH10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_prefetch10(uint32_t lba, int num_blocks, int immed, int group)
|
||||
{
|
||||
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_PREFETCH10;
|
||||
|
||||
if (immed) {
|
||||
task->cdb[1] |= 0x02;
|
||||
}
|
||||
*(uint32_t *)&task->cdb[2] = htonl(lba);
|
||||
task->cdb[6] |= group & 0x1f;
|
||||
*(uint16_t *)&task->cdb[7] = htons(num_blocks);
|
||||
|
||||
task->cdb_size = 10;
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
task->expxferlen = 0;
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
/*
|
||||
* PREFETCH16
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_prefetch16(uint64_t lba, int num_blocks, int immed, int group)
|
||||
{
|
||||
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_PREFETCH16;
|
||||
|
||||
if (immed) {
|
||||
task->cdb[1] |= 0x02;
|
||||
}
|
||||
*(uint32_t *)&task->cdb[2] = htonl(lba >> 32);
|
||||
*(uint32_t *)&task->cdb[6] = htonl(lba & 0xffffffff);
|
||||
*(uint32_t *)&task->cdb[10] = htonl(num_blocks);
|
||||
|
||||
task->cdb[14] |= group & 0x1f;
|
||||
|
||||
task->cdb_size = 16;
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
task->expxferlen = 0;
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
/*
|
||||
* SERVICEACTIONIN16
|
||||
*/
|
||||
|
||||
42
lib/sync.c
42
lib/sync.c
@@ -375,6 +375,48 @@ iscsi_synchronizecache10_sync(struct iscsi_context *iscsi, int lun, int lba,
|
||||
return state.task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_prefetch10_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
int num_blocks, int immed, int group)
|
||||
{
|
||||
struct iscsi_sync_state state;
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_prefetch10_task(iscsi, lun, lba, num_blocks,
|
||||
immed, group,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Failed to send PreFetch10 command");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
event_loop(iscsi, &state);
|
||||
|
||||
return state.task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_prefetch16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
int num_blocks, int immed, int group)
|
||||
{
|
||||
struct iscsi_sync_state state;
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_prefetch16_task(iscsi, lun, lba, num_blocks,
|
||||
immed, group,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Failed to send PreFetch16 command");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
event_loop(iscsi, &state);
|
||||
|
||||
return state.task;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_write10_sync(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba,
|
||||
int fua, int fuanv, int blocksize)
|
||||
|
||||
Reference in New Issue
Block a user