get rid of the _async() scsi functions.
We dotn need two interfaces that only diuffer in whether they return a pointer or NULL vs an semiidentical interface that returns 0 or <0 All uses of _async() for scsi tasks should be replaced with the equivalent _task() function instead
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
/* This is the host/port we connect to.*/
|
||||
#define TARGET "127.0.0.1:3262"
|
||||
#define TARGET "127.0.0.1:3260"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -159,7 +159,7 @@ void readcapacity10_cb(struct iscsi_context *iscsi, int status, void *command_da
|
||||
clnt->block_size = rc10->block_size;
|
||||
printf("READCAPACITY10 successful. Size:%d blocks blocksize:%d. Read first block\n", rc10->lba, rc10->block_size);
|
||||
|
||||
if (iscsi_read10_async(iscsi, clnt->lun, 0, clnt->block_size, clnt->block_size, read10_cb, private_data) != 0) {
|
||||
if (iscsi_read10_task(iscsi, clnt->lun, 0, clnt->block_size, clnt->block_size, read10_cb, private_data) == NULL) {
|
||||
printf("failed to send read10 command\n");
|
||||
scsi_free_scsi_task(task);
|
||||
exit(10);
|
||||
@@ -179,7 +179,7 @@ void modesense6_cb(struct iscsi_context *iscsi, int status, void *command_data,
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
printf("did not get enough data for mode sense, sening modesense again asking for bigger buffer\n");
|
||||
if (iscsi_modesense6_async(iscsi, clnt->lun, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODESENSE_PAGECODE_RETURN_ALL_PAGES, 0, full_size, modesense6_cb, private_data) != 0) {
|
||||
if (iscsi_modesense6_task(iscsi, clnt->lun, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODESENSE_PAGECODE_RETURN_ALL_PAGES, 0, full_size, modesense6_cb, private_data) == NULL) {
|
||||
printf("failed to send modesense6 command\n");
|
||||
scsi_free_scsi_task(task);
|
||||
exit(10);
|
||||
@@ -192,7 +192,7 @@ void modesense6_cb(struct iscsi_context *iscsi, int status, void *command_data,
|
||||
}
|
||||
|
||||
printf("Send READCAPACITY10\n");
|
||||
if (iscsi_readcapacity10_async(iscsi, clnt->lun, 0, 0, readcapacity10_cb, private_data) != 0) {
|
||||
if (iscsi_readcapacity10_task(iscsi, clnt->lun, 0, 0, readcapacity10_cb, private_data) == NULL) {
|
||||
printf("failed to send readcapacity command\n");
|
||||
scsi_free_scsi_task(task);
|
||||
exit(10);
|
||||
@@ -222,7 +222,7 @@ void inquiry_cb(struct iscsi_context *iscsi, int status, void *command_data, voi
|
||||
|
||||
printf("Device Type is %d. VendorId:%s ProductId:%s\n", inq->periperal_device_type, inq->vendor_identification, inq->product_identification);
|
||||
printf("Send MODESENSE6\n");
|
||||
if (iscsi_modesense6_async(iscsi, clnt->lun, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODESENSE_PAGECODE_RETURN_ALL_PAGES, 0, 4, modesense6_cb, private_data) != 0) {
|
||||
if (iscsi_modesense6_task(iscsi, clnt->lun, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODESENSE_PAGECODE_RETURN_ALL_PAGES, 0, 4, modesense6_cb, private_data) == NULL) {
|
||||
printf("failed to send modesense6 command\n");
|
||||
scsi_free_scsi_task(task);
|
||||
exit(10);
|
||||
@@ -240,7 +240,7 @@ void testunitready_cb(struct iscsi_context *iscsi, int status, void *command_dat
|
||||
if (task->sense.key == SCSI_SENSE_UNIT_ATTENTION && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) {
|
||||
printf("target device just came online, try again\n");
|
||||
|
||||
if (iscsi_testunitready_async(iscsi, clnt->lun, testunitready_cb, private_data) != 0) {
|
||||
if (iscsi_testunitready_task(iscsi, clnt->lun, testunitready_cb, private_data) == NULL) {
|
||||
printf("failed to send testunitready command\n");
|
||||
scsi_free_scsi_task(task);
|
||||
exit(10);
|
||||
@@ -251,7 +251,7 @@ void testunitready_cb(struct iscsi_context *iscsi, int status, void *command_dat
|
||||
}
|
||||
|
||||
printf("TESTUNITREADY successful, do an inquiry on lun:%d\n", clnt->lun);
|
||||
if (iscsi_inquiry_async(iscsi, clnt->lun, 0, 0, 64, inquiry_cb, private_data) != 0) {
|
||||
if (iscsi_inquiry_task(iscsi, clnt->lun, 0, 0, 64, inquiry_cb, private_data) == NULL) {
|
||||
printf("failed to send inquiry command : %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
exit(10);
|
||||
@@ -279,7 +279,7 @@ void reportluns_cb(struct iscsi_context *iscsi, int status, void *command_data,
|
||||
printf("REPORTLUNS status:%d data size:%d, full reports luns data size:%d\n", status, task->datain.size, full_report_size);
|
||||
if (full_report_size > task->datain.size) {
|
||||
printf("We did not get all the data we need in reportluns, ask again\n");
|
||||
if (iscsi_reportluns_async(iscsi, 0, full_report_size, reportluns_cb, private_data) != 0) {
|
||||
if (iscsi_reportluns_task(iscsi, 0, full_report_size, reportluns_cb, private_data) == NULL) {
|
||||
printf("failed to send reportluns command\n");
|
||||
scsi_free_scsi_task(task);
|
||||
exit(10);
|
||||
@@ -302,7 +302,7 @@ void reportluns_cb(struct iscsi_context *iscsi, int status, void *command_data,
|
||||
|
||||
printf("Will use LUN:%d\n", clnt->lun);
|
||||
printf("Send testunitready to lun %d\n", clnt->lun);
|
||||
if (iscsi_testunitready_async(iscsi, clnt->lun, testunitready_cb, private_data) != 0) {
|
||||
if (iscsi_testunitready_task(iscsi, clnt->lun, testunitready_cb, private_data) == NULL) {
|
||||
printf("failed to send testunitready command : %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
exit(10);
|
||||
@@ -319,7 +319,7 @@ void normallogin_cb(struct iscsi_context *iscsi, int status, void *command_data
|
||||
}
|
||||
|
||||
printf("Logged in normal session, send reportluns\n");
|
||||
if (iscsi_reportluns_async(iscsi, 0, 16, reportluns_cb, private_data) != 0) {
|
||||
if (iscsi_reportluns_task(iscsi, 0, 16, reportluns_cb, private_data) == NULL) {
|
||||
printf("failed to send reportluns command : %s\n", iscsi_get_error(iscsi));
|
||||
exit(10);
|
||||
}
|
||||
|
||||
@@ -527,48 +527,19 @@ iscsi_set_isid_reserved(struct iscsi_context *iscsi);
|
||||
|
||||
|
||||
/*
|
||||
* The scsi commands use/return a scsi_task structure either when invoked
|
||||
* or through the callback.
|
||||
* The scsi commands use/return a scsi_task structure when invoked
|
||||
* and also through the callback.
|
||||
*
|
||||
* You must release this structure when you are finished with the task
|
||||
* by calling scsi_free_scsi_task().
|
||||
* Most of the time this means you should call this function before returning
|
||||
* from the callback.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Async commands for SCSI
|
||||
*/
|
||||
int iscsi_scsi_command_async(struct iscsi_context *iscsi, int lun,
|
||||
struct scsi_task *task, iscsi_command_cb cb,
|
||||
struct iscsi_data *data, void *private_data);
|
||||
|
||||
int iscsi_reportluns_async(struct iscsi_context *iscsi, int report_type,
|
||||
int alloc_len, iscsi_command_cb cb,
|
||||
void *private_data);
|
||||
int iscsi_testunitready_async(struct iscsi_context *iscsi, int lun,
|
||||
iscsi_command_cb cb, void *private_data);
|
||||
int iscsi_inquiry_async(struct iscsi_context *iscsi, int lun, int evpd,
|
||||
int page_code, int maxsize, iscsi_command_cb cb,
|
||||
void *private_data);
|
||||
int iscsi_readcapacity10_async(struct iscsi_context *iscsi, int lun, int lba,
|
||||
int pmi, iscsi_command_cb cb,
|
||||
void *private_data);
|
||||
int iscsi_synchronizecache10_async(struct iscsi_context *iscsi, int lun,
|
||||
int lba, int num_blocks, int syncnv,
|
||||
int immed, iscsi_command_cb cb,
|
||||
void *private_data);
|
||||
int iscsi_read10_async(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, iscsi_command_cb cb,
|
||||
void *private_data);
|
||||
int iscsi_write10_async(struct iscsi_context *iscsi, int lun,
|
||||
unsigned char *data, uint32_t datalen, uint32_t lba, int fua,
|
||||
int fuanv, int blocksize, iscsi_command_cb cb,
|
||||
void *private_data);
|
||||
int iscsi_modesense6_async(struct iscsi_context *iscsi, int lun, int dbd,
|
||||
int pc, int page_code, int sub_page_code,
|
||||
unsigned char alloc_len, iscsi_command_cb cb,
|
||||
void *private_data);
|
||||
|
||||
/*
|
||||
* Async commands for SCSI
|
||||
*
|
||||
|
||||
@@ -41,9 +41,9 @@ iscsi_testunitready_cb(struct iscsi_context *iscsi, int status,
|
||||
* you always get just after a fresh login. Try
|
||||
* again.
|
||||
*/
|
||||
if (iscsi_testunitready_async(iscsi, ct->lun,
|
||||
if (iscsi_testunitready_task(iscsi, ct->lun,
|
||||
iscsi_testunitready_cb,
|
||||
ct) != 0) {
|
||||
ct) == NULL) {
|
||||
iscsi_set_error(iscsi, "iscsi_testunitready "
|
||||
"failed.");
|
||||
ct->cb(iscsi, SCSI_STATUS_ERROR, NULL,
|
||||
@@ -73,8 +73,8 @@ iscsi_login_cb(struct iscsi_context *iscsi, int status, void *command_data _U_,
|
||||
return;
|
||||
}
|
||||
|
||||
if (iscsi_testunitready_async(iscsi, ct->lun,
|
||||
iscsi_testunitready_cb, ct) != 0) {
|
||||
if (iscsi_testunitready_task(iscsi, ct->lun,
|
||||
iscsi_testunitready_cb, ct) == NULL) {
|
||||
iscsi_set_error(iscsi, "iscsi_testunitready_async failed.");
|
||||
ct->cb(iscsi, SCSI_STATUS_ERROR, NULL, ct->private_data);
|
||||
free(ct);
|
||||
|
||||
@@ -492,14 +492,6 @@ iscsi_testunitready_task(struct iscsi_context *iscsi, int lun,
|
||||
return task;
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_testunitready_async(struct iscsi_context *iscsi, int lun,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
return iscsi_testunitready_task(iscsi, lun,
|
||||
cb, private_data) == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_reportluns_task(struct iscsi_context *iscsi, int report_type,
|
||||
int alloc_len, iscsi_command_cb cb, void *private_data)
|
||||
@@ -529,14 +521,6 @@ iscsi_reportluns_task(struct iscsi_context *iscsi, int report_type,
|
||||
return task;
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_reportluns_async(struct iscsi_context *iscsi, int report_type,
|
||||
int alloc_len, iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
return iscsi_reportluns_task(iscsi, report_type,
|
||||
alloc_len, cb, private_data) == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_inquiry_task(struct iscsi_context *iscsi, int lun, int evpd,
|
||||
int page_code, int maxsize,
|
||||
@@ -559,16 +543,6 @@ iscsi_inquiry_task(struct iscsi_context *iscsi, int lun, int evpd,
|
||||
return task;
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_inquiry_async(struct iscsi_context *iscsi, int lun, int evpd,
|
||||
int page_code, int maxsize,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
return iscsi_inquiry_task(iscsi, lun, evpd,
|
||||
page_code, maxsize,
|
||||
cb, private_data) == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_readcapacity10_task(struct iscsi_context *iscsi, int lun, int lba,
|
||||
int pmi, iscsi_command_cb cb, void *private_data)
|
||||
@@ -590,14 +564,6 @@ iscsi_readcapacity10_task(struct iscsi_context *iscsi, int lun, int lba,
|
||||
return task;
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_readcapacity10_async(struct iscsi_context *iscsi, int lun, int lba,
|
||||
int pmi, iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
return iscsi_readcapacity10_task(iscsi, lun, lba,
|
||||
pmi, cb, private_data) == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_read10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize,
|
||||
@@ -626,16 +592,6 @@ iscsi_read10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
return task;
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_read10_async(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
return iscsi_read10_task(iscsi, lun, lba,
|
||||
datalen, blocksize,
|
||||
cb, private_data) == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_write10_task(struct iscsi_context *iscsi, int lun, unsigned char *data,
|
||||
uint32_t datalen, uint32_t lba, int fua, int fuanv, int blocksize,
|
||||
@@ -669,16 +625,6 @@ iscsi_write10_task(struct iscsi_context *iscsi, int lun, unsigned char *data,
|
||||
return task;
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_write10_async(struct iscsi_context *iscsi, int lun, unsigned char *data,
|
||||
uint32_t datalen, uint32_t lba, int fua, int fuanv, int blocksize,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
return iscsi_write10_task(iscsi, lun, data,
|
||||
datalen, lba, fua, fuanv, blocksize,
|
||||
cb, private_data) == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_modesense6_task(struct iscsi_context *iscsi, int lun, int dbd, int pc,
|
||||
int page_code, int sub_page_code,
|
||||
@@ -703,18 +649,6 @@ iscsi_modesense6_task(struct iscsi_context *iscsi, int lun, int dbd, int pc,
|
||||
return task;
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_modesense6_async(struct iscsi_context *iscsi, int lun, int dbd, int pc,
|
||||
int page_code, int sub_page_code,
|
||||
unsigned char alloc_len,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
return iscsi_modesense6_task(iscsi, lun, dbd, pc,
|
||||
page_code, sub_page_code,
|
||||
alloc_len,
|
||||
cb, private_data) == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
struct scsi_task *
|
||||
iscsi_synchronizecache10_task(struct iscsi_context *iscsi, int lun, int lba,
|
||||
int num_blocks, int syncnv, int immed,
|
||||
@@ -738,12 +672,3 @@ iscsi_synchronizecache10_task(struct iscsi_context *iscsi, int lun, int lba,
|
||||
return task;
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_synchronizecache10_async(struct iscsi_context *iscsi, int lun, int lba,
|
||||
int num_blocks, int syncnv, int immed,
|
||||
iscsi_command_cb cb, void *private_data)
|
||||
{
|
||||
return iscsi_synchronizecache10_task(iscsi, lun, lba,
|
||||
num_blocks, syncnv, immed,
|
||||
cb, private_data) == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
24
lib/sync.c
24
lib/sync.c
@@ -166,8 +166,8 @@ iscsi_reportluns_sync(struct iscsi_context *iscsi, int report_type,
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_reportluns_async(iscsi, report_type, alloc_len,
|
||||
scsi_sync_cb, &state) != 0) {
|
||||
if (iscsi_reportluns_task(iscsi, report_type, alloc_len,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi, "Failed to send ReportLuns command");
|
||||
return NULL;
|
||||
}
|
||||
@@ -185,8 +185,8 @@ iscsi_testunitready_sync(struct iscsi_context *iscsi, int lun)
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_testunitready_async(iscsi, lun,
|
||||
scsi_sync_cb, &state) != 0) {
|
||||
if (iscsi_testunitready_task(iscsi, lun,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Failed to send TestUnitReady command");
|
||||
return NULL;
|
||||
@@ -205,8 +205,8 @@ iscsi_inquiry_sync(struct iscsi_context *iscsi, int lun, int evpd,
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_inquiry_async(iscsi, lun, evpd, page_code, maxsize,
|
||||
scsi_sync_cb, &state) != 0) {
|
||||
if (iscsi_inquiry_task(iscsi, lun, evpd, page_code, maxsize,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi, "Failed to send Inquiry command");
|
||||
return NULL;
|
||||
}
|
||||
@@ -224,8 +224,8 @@ iscsi_read10_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_read10_async(iscsi, lun, lba, datalen, blocksize,
|
||||
scsi_sync_cb, &state) != 0) {
|
||||
if (iscsi_read10_task(iscsi, lun, lba, datalen, blocksize,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Failed to send Read10 command");
|
||||
return NULL;
|
||||
@@ -244,8 +244,8 @@ iscsi_readcapacity10_sync(struct iscsi_context *iscsi, int lun, int lba,
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_readcapacity10_async(iscsi, lun, lba, pmi,
|
||||
scsi_sync_cb, &state) != 0) {
|
||||
if (iscsi_readcapacity10_task(iscsi, lun, lba, pmi,
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Failed to send ReadCapacity10 command");
|
||||
return NULL;
|
||||
@@ -264,9 +264,9 @@ iscsi_synchronizecache10_sync(struct iscsi_context *iscsi, int lun, int lba,
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_synchronizecache10_async(iscsi, lun, lba, num_blocks,
|
||||
if (iscsi_synchronizecache10_task(iscsi, lun, lba, num_blocks,
|
||||
syncnv, immed,
|
||||
scsi_sync_cb, &state) != 0) {
|
||||
scsi_sync_cb, &state) == NULL) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Failed to send SynchronizeCache10 command");
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user