Skip to content

Commit d3305f3

Browse files
Mike ChristieJames Bottomley
authored andcommitted
[SCSI] libiscsi: don't increment cmdsn if cmd is not sent
We increment session->cmdsn at the top of iscsi_prep_scsi_cmd_pdu, but if the prep ecb or prep bidi or init_task calls fails then we leave the session->cmdsn incremented. This moves the cmdsn manipulation to the end of the function when we know it has succeeded. It also adds a session->cmdsn--; in queuecommand for if a driver like bnx2i tries to send a a task from that context but it fails. We do not have to do this in the xmit thread context because that code will retry the same task if the initial call fails. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 523eeac commit d3305f3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/scsi/libiscsi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
301301
hdr->flags = ISCSI_ATTR_SIMPLE;
302302
int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
303303
memcpy(task->lun, hdr->lun, sizeof(task->lun));
304-
hdr->cmdsn = task->cmdsn = cpu_to_be32(session->cmdsn);
305-
session->cmdsn++;
306304
hdr->exp_statsn = cpu_to_be32(conn->exp_statsn);
307305
cmd_len = sc->cmd_len;
308306
if (cmd_len < ISCSI_CDB_SIZE)
@@ -388,6 +386,8 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
388386
return -EIO;
389387

390388
task->state = ISCSI_TASK_RUNNING;
389+
hdr->cmdsn = task->cmdsn = cpu_to_be32(session->cmdsn);
390+
session->cmdsn++;
391391

392392
conn->scsicmd_pdus_cnt++;
393393
ISCSI_DBG_SESSION(session, "iscsi prep [%s cid %d sc %p cdb 0x%x "
@@ -1497,6 +1497,7 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
14971497
}
14981498
}
14991499
if (session->tt->xmit_task(task)) {
1500+
session->cmdsn--;
15001501
reason = FAILURE_SESSION_NOT_READY;
15011502
goto prepd_reject;
15021503
}

0 commit comments

Comments
 (0)