SCSI-LOWLEVEL revert changes to scsi-lowlevel
The memory tracking code reports memory allocated by iscsi_allocate_pdu_with_itt_flags_size() as lost. This memory is allocated by the iscsi part of libiscsi, but later freed by the lowlevel scsi part. We will fix this later by introducing an iscsi_task object.
This commit is contained in:
@@ -35,58 +35,39 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "slist.h"
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-private.h"
|
||||
|
||||
struct scsi_allocated_memory {
|
||||
struct scsi_allocated_memory *next;
|
||||
char buf[0];
|
||||
};
|
||||
|
||||
void
|
||||
scsi_free_scsi_task(struct scsi_task *task)
|
||||
{
|
||||
struct scsi_allocated_memory *mem;
|
||||
|
||||
if (task->iscsi != NULL) {
|
||||
while ((mem = task->mem)) {
|
||||
SLIST_REMOVE(&task->mem, mem);
|
||||
iscsi_free(task->iscsi, mem);
|
||||
}
|
||||
iscsi_free(task->iscsi,task->datain.data);
|
||||
iscsi_free(task->iscsi,task);
|
||||
} else {
|
||||
while ((mem = task->mem)) {
|
||||
SLIST_REMOVE(&task->mem, mem);
|
||||
free(mem);
|
||||
}
|
||||
free(task->datain.data);
|
||||
free(task);
|
||||
while ((mem = task->mem)) {
|
||||
SLIST_REMOVE(&task->mem, mem);
|
||||
free(mem);
|
||||
}
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
scsi_create_scsi_task(struct iscsi_context *iscsi)
|
||||
{
|
||||
struct scsi_task * task;
|
||||
task = iscsi_zmalloc(iscsi, sizeof(struct scsi_task));
|
||||
if (task==NULL) return NULL;
|
||||
task->iscsi=iscsi;
|
||||
return task;
|
||||
free(task->datain.data);
|
||||
free(task);
|
||||
}
|
||||
|
||||
void *
|
||||
scsi_malloc(struct scsi_task *task, size_t size)
|
||||
{
|
||||
struct scsi_allocated_memory *mem;
|
||||
if (task->iscsi != NULL)
|
||||
mem = iscsi_malloc(task->iscsi,sizeof(struct scsi_allocated_memory) + size);
|
||||
else
|
||||
mem = malloc(sizeof(struct scsi_allocated_memory) + size);
|
||||
|
||||
mem = malloc(sizeof(struct scsi_allocated_memory) + size);
|
||||
if (mem == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memset(mem, 0, sizeof(struct scsi_allocated_memory) + size);
|
||||
mem->ptr = (void *) ((uintptr_t)mem + sizeof(struct scsi_allocated_memory));
|
||||
SLIST_ADD(&task->mem, mem);
|
||||
return mem->ptr;
|
||||
return &mem->buf[0];
|
||||
}
|
||||
|
||||
struct value_string {
|
||||
@@ -183,15 +164,16 @@ scsi_sense_ascq_str(int ascq)
|
||||
* TESTUNITREADY
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_testunitready(struct iscsi_context *iscsi)
|
||||
scsi_cdb_testunitready(void)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_TESTUNITREADY;
|
||||
|
||||
task->cdb_size = 6;
|
||||
@@ -206,15 +188,16 @@ scsi_cdb_testunitready(struct iscsi_context *iscsi)
|
||||
* REPORTLUNS
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_reportluns_cdb(struct iscsi_context *iscsi, int report_type, int alloc_len)
|
||||
scsi_reportluns_cdb(int report_type, int alloc_len)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_REPORTLUNS;
|
||||
task->cdb[2] = report_type;
|
||||
*(uint32_t *)&task->cdb[6] = htonl(alloc_len);
|
||||
@@ -286,15 +269,16 @@ scsi_reportluns_datain_unmarshall(struct scsi_task *task)
|
||||
* READCAPACITY10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_readcapacity10(struct iscsi_context *iscsi, int lba, int pmi)
|
||||
scsi_cdb_readcapacity10(int lba, int pmi)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_READCAPACITY10;
|
||||
|
||||
*(uint32_t *)&task->cdb[2] = htonl(lba);
|
||||
@@ -319,7 +303,7 @@ scsi_cdb_readcapacity10(struct iscsi_context *iscsi, int lba, int pmi)
|
||||
* READTOC
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_readtoc(struct iscsi_context *iscsi, int msf, int format, int track_session, uint16_t alloc_len)
|
||||
scsi_cdb_readtoc(int msf, int format, int track_session, uint16_t alloc_len)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
@@ -329,11 +313,12 @@ scsi_cdb_readtoc(struct iscsi_context *iscsi, int msf, int format, int track_ses
|
||||
return NULL;
|
||||
}
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_READTOC;
|
||||
|
||||
if (msf) {
|
||||
@@ -472,15 +457,16 @@ scsi_readtoc_datain_unmarshall(struct scsi_task *task)
|
||||
* RESERVE6
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_reserve6(struct iscsi_context *iscsi)
|
||||
scsi_cdb_reserve6(void)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_RESERVE6;
|
||||
|
||||
task->cdb_size = 6;
|
||||
@@ -492,15 +478,16 @@ scsi_cdb_reserve6(struct iscsi_context *iscsi)
|
||||
* RELEASE10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_release6(struct iscsi_context *iscsi)
|
||||
scsi_cdb_release6(void)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_RELEASE6;
|
||||
|
||||
task->cdb_size = 6;
|
||||
@@ -651,15 +638,16 @@ scsi_maintenancein_datain_unmarshall(struct scsi_task *task)
|
||||
* MAINTENANCE In / Read Supported Op Codes
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_report_supported_opcodes(struct iscsi_context *iscsi, int return_timeouts, uint32_t alloc_len)
|
||||
scsi_cdb_report_supported_opcodes(int return_timeouts, uint32_t alloc_len)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_MAINTENANCE_IN;
|
||||
task->cdb[1] = SCSI_REPORT_SUPPORTED_OP_CODES;
|
||||
task->cdb[2] = SCSI_REPORT_SUPPORTING_OPS_ALL;
|
||||
@@ -724,15 +712,16 @@ scsi_readcapacity10_datain_unmarshall(struct scsi_task *task)
|
||||
* INQUIRY
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_inquiry(struct iscsi_context *iscsi, int evpd, int page_code, int alloc_len)
|
||||
scsi_cdb_inquiry(int evpd, int page_code, int alloc_len)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_INQUIRY;
|
||||
|
||||
if (evpd) {
|
||||
@@ -999,7 +988,7 @@ scsi_inquiry_datain_unmarshall(struct scsi_task *task)
|
||||
* READ6
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_read6(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int blocksize)
|
||||
scsi_cdb_read6(uint32_t lba, uint32_t xferlen, int blocksize)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
int num_blocks;
|
||||
@@ -1013,11 +1002,12 @@ scsi_cdb_read6(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int
|
||||
return NULL;
|
||||
}
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_READ6;
|
||||
task->cdb_size = 6;
|
||||
|
||||
@@ -1046,15 +1036,16 @@ scsi_cdb_read6(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int
|
||||
* READ10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_read10(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
scsi_cdb_read10(uint32_t lba, uint32_t xferlen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_READ10;
|
||||
|
||||
task->cdb[1] |= ((rdprotect & 0x07) << 5);
|
||||
@@ -1091,15 +1082,16 @@ scsi_cdb_read10(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int
|
||||
* READ12
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_read12(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
scsi_cdb_read12(uint32_t lba, uint32_t xferlen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_READ12;
|
||||
|
||||
task->cdb[1] |= ((rdprotect & 0x07) << 5);
|
||||
@@ -1136,15 +1128,16 @@ scsi_cdb_read12(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int
|
||||
* READ16
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_read16(struct iscsi_context *iscsi, uint64_t lba, uint32_t xferlen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
scsi_cdb_read16(uint64_t lba, uint32_t xferlen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_READ16;
|
||||
|
||||
task->cdb[1] |= ((rdprotect & 0x07) << 5);
|
||||
@@ -1182,15 +1175,16 @@ scsi_cdb_read16(struct iscsi_context *iscsi, uint64_t lba, uint32_t xferlen, int
|
||||
* WRITE10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_write10(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
scsi_cdb_write10(uint32_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_WRITE10;
|
||||
|
||||
task->cdb[1] |= ((wrprotect & 0x07) << 5);
|
||||
@@ -1227,15 +1221,16 @@ scsi_cdb_write10(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, in
|
||||
* WRITE12
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_write12(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
scsi_cdb_write12(uint32_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_WRITE12;
|
||||
|
||||
task->cdb[1] |= ((wrprotect & 0x07) << 5);
|
||||
@@ -1272,15 +1267,16 @@ scsi_cdb_write12(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, in
|
||||
* WRITE16
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_write16(struct iscsi_context *iscsi, uint64_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
scsi_cdb_write16(uint64_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_WRITE16;
|
||||
|
||||
task->cdb[1] |= ((wrprotect & 0x07) << 5);
|
||||
@@ -1318,15 +1314,16 @@ scsi_cdb_write16(struct iscsi_context *iscsi, uint64_t lba, uint32_t xferlen, in
|
||||
* ORWRITE
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_orwrite(struct iscsi_context *iscsi, uint64_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
scsi_cdb_orwrite(uint64_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_ORWRITE;
|
||||
|
||||
task->cdb[1] |= ((wrprotect & 0x07) << 5);
|
||||
@@ -1364,15 +1361,16 @@ scsi_cdb_orwrite(struct iscsi_context *iscsi, uint64_t lba, uint32_t xferlen, in
|
||||
* COMPAREANDWRITE
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_compareandwrite(struct iscsi_context *iscsi, uint64_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
scsi_cdb_compareandwrite(uint64_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_COMPARE_AND_WRITE;
|
||||
|
||||
task->cdb[1] |= ((wrprotect & 0x07) << 5);
|
||||
@@ -1409,15 +1407,16 @@ scsi_cdb_compareandwrite(struct iscsi_context *iscsi, uint64_t lba, uint32_t xfe
|
||||
* VERIFY10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_verify10(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int bytchk, int blocksize)
|
||||
scsi_cdb_verify10(uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int bytchk, int blocksize)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_VERIFY10;
|
||||
|
||||
if (vprotect) {
|
||||
@@ -1454,15 +1453,16 @@ scsi_cdb_verify10(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, i
|
||||
* VERIFY12
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_verify12(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int bytchk, int blocksize)
|
||||
scsi_cdb_verify12(uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int bytchk, int blocksize)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_VERIFY12;
|
||||
|
||||
if (vprotect) {
|
||||
@@ -1499,15 +1499,16 @@ scsi_cdb_verify12(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, i
|
||||
* VERIFY16
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_verify16(struct iscsi_context *iscsi, uint64_t lba, uint32_t xferlen, int vprotect, int dpo, int bytchk, int blocksize)
|
||||
scsi_cdb_verify16(uint64_t lba, uint32_t xferlen, int vprotect, int dpo, int bytchk, int blocksize)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_VERIFY16;
|
||||
|
||||
if (vprotect) {
|
||||
@@ -1545,15 +1546,16 @@ scsi_cdb_verify16(struct iscsi_context *iscsi, uint64_t lba, uint32_t xferlen, i
|
||||
* UNMAP
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_unmap(struct iscsi_context *iscsi, int anchor, int group, uint16_t xferlen)
|
||||
scsi_cdb_unmap(int anchor, int group, uint16_t xferlen)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_UNMAP;
|
||||
|
||||
if (anchor) {
|
||||
@@ -1578,15 +1580,16 @@ scsi_cdb_unmap(struct iscsi_context *iscsi, int anchor, int group, uint16_t xfer
|
||||
* WRITE_SAME10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_writesame10(struct iscsi_context *iscsi, int wrprotect, int anchor, int unmap, int pbdata, int lbdata, uint32_t lba, int group, uint16_t num_blocks)
|
||||
scsi_cdb_writesame10(int wrprotect, int anchor, int unmap, int pbdata, int lbdata, uint32_t lba, int group, uint16_t num_blocks)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_WRITE_SAME10;
|
||||
|
||||
if (wrprotect) {
|
||||
@@ -1621,15 +1624,16 @@ scsi_cdb_writesame10(struct iscsi_context *iscsi, int wrprotect, int anchor, int
|
||||
* WRITE_SAME16
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_writesame16(struct iscsi_context *iscsi, int wrprotect, int anchor, int unmap, int pbdata, int lbdata, uint64_t lba, int group, uint32_t num_blocks)
|
||||
scsi_cdb_writesame16(int wrprotect, int anchor, int unmap, int pbdata, int lbdata, uint64_t lba, int group, uint32_t num_blocks)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_WRITE_SAME16;
|
||||
|
||||
if (wrprotect) {
|
||||
@@ -1665,17 +1669,18 @@ scsi_cdb_writesame16(struct iscsi_context *iscsi, int wrprotect, int anchor, int
|
||||
* MODESENSE6
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_modesense6(struct iscsi_context *iscsi, int dbd, enum scsi_modesense_page_control pc,
|
||||
scsi_cdb_modesense6(int dbd, enum scsi_modesense_page_control pc,
|
||||
enum scsi_modesense_page_code page_code,
|
||||
int sub_page_code, unsigned char alloc_len)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_MODESENSE6;
|
||||
|
||||
if (dbd) {
|
||||
@@ -1855,15 +1860,16 @@ scsi_modesense_datain_unmarshall(struct scsi_task *task)
|
||||
* STARTSTOPUNIT
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_startstopunit(struct iscsi_context *iscsi, int immed, int pcm, int pc, int no_flush, int loej, int start)
|
||||
scsi_cdb_startstopunit(int immed, int pcm, int pc, int no_flush, int loej, int start)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
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) {
|
||||
@@ -1900,15 +1906,16 @@ scsi_cdb_startstopunit(struct iscsi_context *iscsi, int immed, int pcm, int pc,
|
||||
* PREVENTALLOWMEDIUMREMOVAL
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_preventallow(struct iscsi_context *iscsi, int prevent)
|
||||
scsi_cdb_preventallow(int prevent)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
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;
|
||||
@@ -1926,15 +1933,16 @@ scsi_cdb_preventallow(struct iscsi_context *iscsi, int prevent)
|
||||
* SYNCHRONIZECACHE10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_synchronizecache10(struct iscsi_context *iscsi, int lba, int num_blocks, int syncnv, int immed)
|
||||
scsi_cdb_synchronizecache10(int lba, int num_blocks, int syncnv, int immed)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_SYNCHRONIZECACHE10;
|
||||
|
||||
if (syncnv) {
|
||||
@@ -1957,15 +1965,16 @@ scsi_cdb_synchronizecache10(struct iscsi_context *iscsi, int lba, int num_blocks
|
||||
* SYNCHRONIZECACHE16
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_synchronizecache16(struct iscsi_context *iscsi, uint64_t lba, uint32_t num_blocks, int syncnv, int immed)
|
||||
scsi_cdb_synchronizecache16(uint64_t lba, uint32_t num_blocks, int syncnv, int immed)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_SYNCHRONIZECACHE16;
|
||||
|
||||
if (syncnv) {
|
||||
@@ -1989,15 +1998,16 @@ scsi_cdb_synchronizecache16(struct iscsi_context *iscsi, uint64_t lba, uint32_t
|
||||
* PREFETCH10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_prefetch10(struct iscsi_context *iscsi, uint32_t lba, int num_blocks, int immed, int group)
|
||||
scsi_cdb_prefetch10(uint32_t lba, int num_blocks, int immed, int group)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
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) {
|
||||
@@ -2018,15 +2028,16 @@ scsi_cdb_prefetch10(struct iscsi_context *iscsi, uint32_t lba, int num_blocks, i
|
||||
* PREFETCH16
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_prefetch16(struct iscsi_context *iscsi, uint64_t lba, int num_blocks, int immed, int group)
|
||||
scsi_cdb_prefetch16(uint64_t lba, int num_blocks, int immed, int group)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
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) {
|
||||
@@ -2049,15 +2060,16 @@ scsi_cdb_prefetch16(struct iscsi_context *iscsi, uint64_t lba, int num_blocks, i
|
||||
* SERVICEACTIONIN16
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_serviceactionin16(struct iscsi_context *iscsi, enum scsi_service_action_in sa, uint32_t xferlen)
|
||||
scsi_cdb_serviceactionin16(enum scsi_service_action_in sa, uint32_t xferlen)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_SERVICE_ACTION_IN;
|
||||
|
||||
task->cdb[1] = sa;
|
||||
@@ -2081,24 +2093,25 @@ scsi_cdb_serviceactionin16(struct iscsi_context *iscsi, enum scsi_service_action
|
||||
* READCAPACITY16
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_readcapacity16(struct iscsi_context *iscsi)
|
||||
scsi_cdb_readcapacity16(void)
|
||||
{
|
||||
return scsi_cdb_serviceactionin16(iscsi, SCSI_READCAPACITY16, 32);
|
||||
return scsi_cdb_serviceactionin16(SCSI_READCAPACITY16, 32);
|
||||
}
|
||||
|
||||
/*
|
||||
* GET_LBA_STATUS
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_get_lba_status(struct iscsi_context *iscsi, uint64_t starting_lba, uint32_t alloc_len)
|
||||
scsi_cdb_get_lba_status(uint64_t starting_lba, uint32_t alloc_len)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_SERVICE_ACTION_IN;
|
||||
|
||||
task->cdb[1] = SCSI_GET_LBA_STATUS;
|
||||
@@ -2124,15 +2137,16 @@ scsi_cdb_get_lba_status(struct iscsi_context *iscsi, uint64_t starting_lba, uint
|
||||
* WRITEVERIFY10
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_writeverify10(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int bytchk, int group_number)
|
||||
scsi_cdb_writeverify10(uint32_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int bytchk, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
|
||||
|
||||
task->cdb[1] |= ((wrprotect & 0x07) << 5);
|
||||
@@ -2166,15 +2180,16 @@ scsi_cdb_writeverify10(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferl
|
||||
* WRITEVERIFY12
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_writeverify12(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int bytchk, int group_number)
|
||||
scsi_cdb_writeverify12(uint32_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int bytchk, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
|
||||
|
||||
task->cdb[1] |= ((wrprotect & 0x07) << 5);
|
||||
@@ -2208,15 +2223,16 @@ scsi_cdb_writeverify12(struct iscsi_context *iscsi, uint32_t lba, uint32_t xferl
|
||||
* WRITEVERIFY16
|
||||
*/
|
||||
struct scsi_task *
|
||||
scsi_cdb_writeverify16(struct iscsi_context *iscsi, uint64_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int bytchk, int group_number)
|
||||
scsi_cdb_writeverify16(uint64_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int bytchk, int group_number)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
task = scsi_create_scsi_task(iscsi);
|
||||
task = malloc(sizeof(struct scsi_task));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
|
||||
|
||||
task->cdb[1] |= ((wrprotect & 0x07) << 5);
|
||||
@@ -2539,77 +2555,3 @@ scsi_task_get_data_in_buffer(struct scsi_task *task, uint32_t pos, ssize_t *coun
|
||||
|
||||
return &sdb->data[pos];
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_scsi_task_cancel(struct iscsi_context *iscsi,
|
||||
struct scsi_task *task)
|
||||
{
|
||||
struct iscsi_pdu *pdu;
|
||||
|
||||
for (pdu = iscsi->waitpdu; pdu; pdu = pdu->next) {
|
||||
if (pdu->itt == task->itt) {
|
||||
while(task->in_buffers != NULL) {
|
||||
struct scsi_data_buffer *ptr = task->in_buffers;
|
||||
SLIST_REMOVE(&task->in_buffers, ptr);
|
||||
}
|
||||
SLIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) {
|
||||
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
|
||||
pdu->private_data);
|
||||
}
|
||||
iscsi_free_pdu(iscsi, pdu);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for (pdu = iscsi->outqueue; pdu; pdu = pdu->next) {
|
||||
if (pdu->itt == task->itt) {
|
||||
while(task->in_buffers != NULL) {
|
||||
struct scsi_data_buffer *ptr = task->in_buffers;
|
||||
SLIST_REMOVE(&task->in_buffers, ptr);
|
||||
}
|
||||
SLIST_REMOVE(&iscsi->outqueue, pdu);
|
||||
if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) {
|
||||
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
|
||||
pdu->private_data);
|
||||
}
|
||||
iscsi_free_pdu(iscsi, pdu);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
iscsi_scsi_cancel_all_tasks(struct iscsi_context *iscsi)
|
||||
{
|
||||
struct iscsi_pdu *pdu;
|
||||
|
||||
for (pdu = iscsi->waitpdu; pdu; pdu = pdu->next) {
|
||||
struct scsi_task *task = iscsi_scsi_get_task_from_pdu(pdu);
|
||||
|
||||
while(task->in_buffers != NULL) {
|
||||
struct scsi_data_buffer *ptr = task->in_buffers;
|
||||
SLIST_REMOVE(&task->in_buffers, ptr);
|
||||
}
|
||||
SLIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) {
|
||||
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
|
||||
pdu->private_data);
|
||||
}
|
||||
iscsi_free_pdu(iscsi, pdu);
|
||||
}
|
||||
for (pdu = iscsi->outqueue; pdu; pdu = pdu->next) {
|
||||
struct scsi_task *task = iscsi_scsi_get_task_from_pdu(pdu);
|
||||
|
||||
while(task->in_buffers != NULL) {
|
||||
struct scsi_data_buffer *ptr = task->in_buffers;
|
||||
SLIST_REMOVE(&task->in_buffers, ptr);
|
||||
}
|
||||
SLIST_REMOVE(&iscsi->outqueue, pdu);
|
||||
if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) {
|
||||
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
|
||||
pdu->private_data);
|
||||
}
|
||||
iscsi_free_pdu(iscsi, pdu);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user