abstract transport to static driver functions and opaque driver specific information.
This splits a transport into static driver specific functions for the common iscsi commands. Optionally, a driver specific opaque memory is introduced which is currently only used by iSER transport. Last a lot of functions changed to static. Signed-off-by: Peter Lieven <pl@kamp.de>
This commit is contained in:
28
lib/pdu.c
28
lib/pdu.c
@@ -96,7 +96,7 @@ iscsi_allocate_pdu(struct iscsi_context *iscsi, enum iscsi_opcode opcode,
|
||||
{
|
||||
struct iscsi_pdu *pdu;
|
||||
|
||||
pdu = iscsi->t->new_pdu(iscsi, sizeof(struct iscsi_pdu));
|
||||
pdu = iscsi->drv->new_pdu(iscsi, sizeof(struct iscsi_pdu));
|
||||
if (pdu == NULL) {
|
||||
iscsi_set_error(iscsi, "failed to allocate pdu");
|
||||
return NULL;
|
||||
@@ -379,7 +379,7 @@ int iscsi_process_reject(struct iscsi_context *iscsi,
|
||||
}
|
||||
|
||||
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -528,7 +528,7 @@ iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||
case ISCSI_PDU_LOGIN_RESPONSE:
|
||||
if (iscsi_process_login_reply(iscsi, pdu, in) != 0) {
|
||||
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
iscsi_set_error(iscsi, "iscsi login reply "
|
||||
"failed");
|
||||
return -1;
|
||||
@@ -537,7 +537,7 @@ iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||
case ISCSI_PDU_TEXT_RESPONSE:
|
||||
if (iscsi_process_text_reply(iscsi, pdu, in) != 0) {
|
||||
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
iscsi_set_error(iscsi, "iscsi text reply "
|
||||
"failed");
|
||||
return -1;
|
||||
@@ -546,7 +546,7 @@ iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||
case ISCSI_PDU_LOGOUT_RESPONSE:
|
||||
if (iscsi_process_logout_reply(iscsi, pdu, in) != 0) {
|
||||
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
iscsi_set_error(iscsi, "iscsi logout reply "
|
||||
"failed");
|
||||
return -1;
|
||||
@@ -555,7 +555,7 @@ iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||
case ISCSI_PDU_SCSI_RESPONSE:
|
||||
if (iscsi_process_scsi_reply(iscsi, pdu, in) != 0) {
|
||||
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
iscsi_set_error(iscsi, "iscsi response reply "
|
||||
"failed");
|
||||
return -1;
|
||||
@@ -565,7 +565,7 @@ iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||
if (iscsi_process_scsi_data_in(iscsi, pdu, in,
|
||||
&is_finished) != 0) {
|
||||
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
iscsi_set_error(iscsi, "iscsi data in "
|
||||
"failed");
|
||||
return -1;
|
||||
@@ -574,7 +574,7 @@ iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||
case ISCSI_PDU_NOP_IN:
|
||||
if (iscsi_process_nop_out_reply(iscsi, pdu, in) != 0) {
|
||||
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
iscsi_set_error(iscsi, "iscsi nop-in failed");
|
||||
return -1;
|
||||
}
|
||||
@@ -583,7 +583,7 @@ iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||
if (iscsi_process_task_mgmt_reply(iscsi, pdu,
|
||||
in) != 0) {
|
||||
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
iscsi_set_error(iscsi, "iscsi task-mgmt failed");
|
||||
return -1;
|
||||
}
|
||||
@@ -591,7 +591,7 @@ iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||
case ISCSI_PDU_R2T:
|
||||
if (iscsi_process_r2t(iscsi, pdu, in) != 0) {
|
||||
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
iscsi_set_error(iscsi, "iscsi r2t "
|
||||
"failed");
|
||||
return -1;
|
||||
@@ -606,7 +606,7 @@ iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||
|
||||
if (is_finished) {
|
||||
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -720,7 +720,7 @@ iscsi_timeout_scan(struct iscsi_context *iscsi)
|
||||
pdu->callback(iscsi, SCSI_STATUS_TIMEOUT,
|
||||
NULL, pdu->private_data);
|
||||
}
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
}
|
||||
for (pdu = iscsi->waitpdu; pdu; pdu = next_pdu) {
|
||||
next_pdu = pdu->next;
|
||||
@@ -740,12 +740,12 @@ iscsi_timeout_scan(struct iscsi_context *iscsi)
|
||||
pdu->callback(iscsi, SCSI_STATUS_TIMEOUT,
|
||||
NULL, pdu->private_data);
|
||||
}
|
||||
iscsi->t->free_pdu(iscsi, pdu);
|
||||
iscsi->drv->free_pdu(iscsi, pdu);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
|
||||
{
|
||||
return iscsi->t->queue_pdu(iscsi, pdu);
|
||||
return iscsi->drv->queue_pdu(iscsi, pdu);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user