diff --git a/include/iscsi-private.h b/include/iscsi-private.h index 1be0f61..4bce783 100644 --- a/include/iscsi-private.h +++ b/include/iscsi-private.h @@ -195,7 +195,12 @@ struct iscsi_pdu { /* There will not be a response to this pdu, so delete it once it is sent on the wire. Dont put it on the wait-queue */ #define ISCSI_PDU_DELETE_WHEN_SENT 0x00000001 /* Dont call the CANCEL callback when the context is destroyed */ -#define ISCSI_PDU_NO_CALLBACK 0x00000002 +#define ISCSI_PDU_NO_CALLBACK 0x00000002 +/* When reconnecting, just drop all these PDUs. Dont re-queue them. + * This includes any DATA-OUT PDU as well as all NOPs. + */ +#define ISCSI_PDU_DROP_ON_RECONNECT 0x00000004 + uint32_t flags; uint32_t lun; diff --git a/lib/connect.c b/lib/connect.c index fd4c97b..47fcd11 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -302,10 +302,11 @@ try_again: continue; } - if (pdu->flags & ISCSI_PDU_DELETE_WHEN_SENT) { + if (pdu->flags & ISCSI_PDU_DROP_ON_RECONNECT) { /* We dont want to requeue things like DATA-OUT since these guys * will be reissued automatically anyway once the corresponding * write command is replayed. + * Similarly we dont want to requeue NOPs. */ iscsi_free_pdu(old_iscsi, pdu); continue; diff --git a/lib/iscsi-command.c b/lib/iscsi-command.c index 901964c..00e9286 100644 --- a/lib/iscsi-command.c +++ b/lib/iscsi-command.c @@ -69,7 +69,7 @@ iscsi_send_data_out(struct iscsi_context *iscsi, struct iscsi_pdu *cmd_pdu, pdu = iscsi_allocate_pdu_with_itt_flags(iscsi, ISCSI_PDU_DATA_OUT, ISCSI_PDU_NO_PDU, cmd_pdu->itt, - ISCSI_PDU_DELETE_WHEN_SENT|ISCSI_PDU_NO_CALLBACK); + ISCSI_PDU_DROP_ON_RECONNECT|ISCSI_PDU_DELETE_WHEN_SENT|ISCSI_PDU_NO_CALLBACK); if (pdu == NULL) { iscsi_set_error(iscsi, "Out-of-memory, Failed to allocate " "scsi data out pdu."); diff --git a/lib/nop.c b/lib/nop.c index 3f930c0..102df7c 100644 --- a/lib/nop.c +++ b/lib/nop.c @@ -42,6 +42,9 @@ iscsi_nop_out_async(struct iscsi_context *iscsi, iscsi_command_cb cb, return -1; } + /* We dont want to requeue these on reconnect */ + pdu->flags |= ISCSI_PDU_DROP_ON_RECONNECT; + /* immediate flag */ iscsi_pdu_set_immediate(pdu); @@ -87,7 +90,7 @@ iscsi_send_target_nop_out(struct iscsi_context *iscsi, uint32_t ttt) struct iscsi_pdu *pdu; pdu = iscsi_allocate_pdu_with_itt_flags(iscsi, ISCSI_PDU_NOP_OUT, ISCSI_PDU_NO_PDU, - 0xffffffff,ISCSI_PDU_DELETE_WHEN_SENT|ISCSI_PDU_NO_CALLBACK); + 0xffffffff,ISCSI_PDU_DROP_ON_RECONNECT|ISCSI_PDU_DELETE_WHEN_SENT|ISCSI_PDU_NO_CALLBACK); if (pdu == NULL) { iscsi_set_error(iscsi, "Failed to allocate nop-out pdu"); return -1;