aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libiscsi.c
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2009-08-20 16:10:58 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-09-05 10:42:41 -0400
commitd3305f3407fa3e9452079ec6cc8379067456e4aa (patch)
tree8e8abaea070305d25d9de788dd07e5cdbd8b6f83 /drivers/scsi/libiscsi.c
parent523eeac6703a995d58918aaf321f128f75c13108 (diff)
[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>
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r--drivers/scsi/libiscsi.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index a751f6230c22..c68cb53a984b 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -301,8 +301,6 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
301 hdr->flags = ISCSI_ATTR_SIMPLE; 301 hdr->flags = ISCSI_ATTR_SIMPLE;
302 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun); 302 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
303 memcpy(task->lun, hdr->lun, sizeof(task->lun)); 303 memcpy(task->lun, hdr->lun, sizeof(task->lun));
304 hdr->cmdsn = task->cmdsn = cpu_to_be32(session->cmdsn);
305 session->cmdsn++;
306 hdr->exp_statsn = cpu_to_be32(conn->exp_statsn); 304 hdr->exp_statsn = cpu_to_be32(conn->exp_statsn);
307 cmd_len = sc->cmd_len; 305 cmd_len = sc->cmd_len;
308 if (cmd_len < ISCSI_CDB_SIZE) 306 if (cmd_len < ISCSI_CDB_SIZE)
@@ -388,6 +386,8 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
388 return -EIO; 386 return -EIO;
389 387
390 task->state = ISCSI_TASK_RUNNING; 388 task->state = ISCSI_TASK_RUNNING;
389 hdr->cmdsn = task->cmdsn = cpu_to_be32(session->cmdsn);
390 session->cmdsn++;
391 391
392 conn->scsicmd_pdus_cnt++; 392 conn->scsicmd_pdus_cnt++;
393 ISCSI_DBG_SESSION(session, "iscsi prep [%s cid %d sc %p cdb 0x%x " 393 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 *))
1497 } 1497 }
1498 } 1498 }
1499 if (session->tt->xmit_task(task)) { 1499 if (session->tt->xmit_task(task)) {
1500 session->cmdsn--;
1500 reason = FAILURE_SESSION_NOT_READY; 1501 reason = FAILURE_SESSION_NOT_READY;
1501 goto prepd_reject; 1502 goto prepd_reject;
1502 } 1503 }