Merge pull request #57 from plieven/outqueue-itt-fix

Nice catch.
This commit is contained in:
Ronnie Sahlberg
2012-12-17 07:28:22 -08:00
2 changed files with 15 additions and 5 deletions

View File

@@ -59,6 +59,14 @@ iscsi_itt_post_increment(struct iscsi_context *iscsi) {
return old_itt;
}
void iscsi_dump_pdu_header(struct iscsi_context *iscsi, unsigned char *data) {
char dump[ISCSI_RAW_HEADER_SIZE*3+1]={0};
int i;
for (i=0;i<ISCSI_RAW_HEADER_SIZE;i++) {
snprintf(&dump[i*3], 4," %02x",data[i]);
}
ISCSI_LOG(iscsi, 0, "PDU header:%s",dump);
}
struct iscsi_pdu *
iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi, enum iscsi_opcode opcode,
@@ -291,6 +299,10 @@ int iscsi_process_reject(struct iscsi_context *iscsi,
itt = scsi_get_uint32(&in->data[16]);
if (iscsi->log_level > 1) {
iscsi_dump_pdu_header(iscsi, in->data);
}
for (pdu = iscsi->waitpdu; pdu; pdu = pdu->next) {
if (pdu->itt == itt) {
break;

View File

@@ -61,13 +61,11 @@ iscsi_add_to_outqueue(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
return;
}
/* queue pdus in ascending order of itt.
* ensure that pakets with the same itt are kept in order.
* queue pdus with itt = 0xffffffff (SNACK / DataACK) in order but at head of queue.
/* queue pdus in ascending order of CmdSN.
* ensure that pakets with the same CmdSN are kept in FIFO order.
*/
do {
if (iscsi_serial32_compare(pdu->itt, current->itt) < 0
|| (pdu->itt == 0xffffffff && current->itt != 0xffffffff)) {
if (iscsi_serial32_compare(pdu->cmdsn, current->cmdsn) < 0) {
/* insert PDU before the current */
if (last != NULL) {
last->next=pdu;