Skip to content

Commit

Permalink
pdu: drop ISCSI_PDU_NO_CALLBACK
Browse files Browse the repository at this point in the history
we use the flag ISCSI_PDU_NO_CALLBACK and pdu->callback simultaneously, but
check only for one of them in various places. So drop ISCSI_PDU_NO_CALLBACK
and check for pdu->callback != NULL instead.

All PDUs that carried this flag have pdu->callback set to NULL.

Signed-off-by: Peter Lieven <pl@kamp.de>
  • Loading branch information
plieven committed May 2, 2016
1 parent 03fe4d7 commit cde2043
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 28 deletions.
2 changes: 0 additions & 2 deletions include/iscsi-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ struct iscsi_pdu {

/* There will not be a response to this pdu, so delete it once it is sent on the wire. Don't put it on the wait-queue */
#define ISCSI_PDU_DELETE_WHEN_SENT 0x00000001
/* Don't call the CANCEL callback when the context is destroyed */
#define ISCSI_PDU_NO_CALLBACK 0x00000002
/* When reconnecting, just drop all these PDUs. Don't re-queue them.
* This includes any DATA-OUT PDU as well as all NOPs.
*/
Expand Down
18 changes: 8 additions & 10 deletions lib/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,25 +270,23 @@ void iscsi_defer_reconnect(struct iscsi_context *iscsi)

while ((pdu = iscsi->outqueue)) {
ISCSI_LIST_REMOVE(&iscsi->outqueue, pdu);
if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) {
if (iscsi->is_loggedin && pdu->callback) {
/* If an error happened during connect/login,
we don't want to call any of the callbacks.
*/
if (iscsi->is_loggedin) {
pdu->callback(iscsi, SCSI_STATUS_CANCELLED,
NULL, pdu->private_data);
}
pdu->callback(iscsi, SCSI_STATUS_CANCELLED,
NULL, pdu->private_data);
}
iscsi_free_pdu(iscsi, pdu);
}
while ((pdu = iscsi->waitpdu)) {
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
/* If an error happened during connect/login,
we don't want to call any of the callbacks.
*/
if (iscsi->is_loggedin) {
if (iscsi->is_loggedin && pdu->callback) {
/* If an error happened during connect/login,
we don't want to call any of the callbacks.
*/
pdu->callback(iscsi, SCSI_STATUS_CANCELLED,
NULL, pdu->private_data);
NULL, pdu->private_data);
}
iscsi_free_pdu(iscsi, pdu);
}
Expand Down
18 changes: 8 additions & 10 deletions lib/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,25 +304,23 @@ iscsi_destroy_context(struct iscsi_context *iscsi)

while ((pdu = iscsi->outqueue)) {
ISCSI_LIST_REMOVE(&iscsi->outqueue, pdu);
if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) {
if (iscsi->is_loggedin && pdu->callback) {
/* If an error happened during connect/login, we don't want to
call any of the callbacks.
*/
if (iscsi->is_loggedin && pdu->callback != NULL) {
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
pdu->private_data);
}
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
pdu->private_data);
}
iscsi_free_pdu(iscsi, pdu);
}
while ((pdu = iscsi->waitpdu)) {
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
/* If an error happened during connect/login, we don't want to
call any of the callbacks.
*/
if (iscsi->is_loggedin && pdu->callback != NULL) {
if (iscsi->is_loggedin && pdu->callback) {
/* If an error happened during connect/login, we don't want to
call any of the callbacks.
*/
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
pdu->private_data);
pdu->private_data);
}
iscsi_free_pdu(iscsi, pdu);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/iscsi-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ iscsi_send_data_out(struct iscsi_context *iscsi, struct iscsi_pdu *cmd_pdu,
ISCSI_PDU_DATA_OUT,
ISCSI_PDU_NO_PDU,
cmd_pdu->itt,
ISCSI_PDU_DROP_ON_RECONNECT|ISCSI_PDU_DELETE_WHEN_SENT|ISCSI_PDU_NO_CALLBACK);
ISCSI_PDU_DROP_ON_RECONNECT|ISCSI_PDU_DELETE_WHEN_SENT);
if (pdu == NULL) {
iscsi_set_error(iscsi, "Out-of-memory, Failed to allocate "
"scsi data out pdu.");
Expand Down Expand Up @@ -1891,7 +1891,7 @@ iscsi_scsi_cancel_task(struct iscsi_context *iscsi,
for (pdu = iscsi->waitpdu; pdu; pdu = pdu->next) {
if (pdu->itt == task->itt) {
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) {
if (pdu->callback) {
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
pdu->private_data);
}
Expand All @@ -1902,7 +1902,7 @@ iscsi_scsi_cancel_task(struct iscsi_context *iscsi,
for (pdu = iscsi->outqueue; pdu; pdu = pdu->next) {
if (pdu->itt == task->itt) {
ISCSI_LIST_REMOVE(&iscsi->outqueue, pdu);
if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) {
if (pdu->callback) {
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
pdu->private_data);
}
Expand All @@ -1920,15 +1920,15 @@ iscsi_scsi_cancel_all_tasks(struct iscsi_context *iscsi)

while ((pdu = iscsi->waitpdu)) {
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) {
if (pdu->callback) {
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
pdu->private_data);
}
iscsi_free_pdu(iscsi, pdu);
}
while ((pdu = iscsi->outqueue)) {
ISCSI_LIST_REMOVE(&iscsi->outqueue, pdu);
if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) {
if (pdu->callback) {
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
pdu->private_data);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/nop.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ iscsi_send_target_nop_out(struct iscsi_context *iscsi, uint32_t ttt, uint32_t lu
ISCSI_PDU_NOP_OUT,
ISCSI_PDU_NO_PDU,
0xffffffff,
ISCSI_PDU_DROP_ON_RECONNECT|ISCSI_PDU_DELETE_WHEN_SENT|ISCSI_PDU_NO_CALLBACK);
ISCSI_PDU_DROP_ON_RECONNECT|ISCSI_PDU_DELETE_WHEN_SENT);
if (pdu == NULL) {
iscsi_set_error(iscsi, "Failed to allocate nop-out pdu");
return -1;
Expand Down

0 comments on commit cde2043

Please sign in to comment.