aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2008-01-31 14:36:53 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-02-07 19:02:37 -0500
commit8b1d03434ee44b08c57f50403eaeab099facebf5 (patch)
tree48d7c5aeb3b765284dcc3d8685ed6ea6aed350cb
parent322d739da83bbff0309c202181f79c08d9534880 (diff)
[SCSI] libiscsi: fix session age rollover and remove cid encoding
The session age mask is only 4 bits, but session->age is 32. When it gets larger then 15 and we try to or the bits some bits get dropped and the check for session age in iscsi_verify_itt is useless. The ISCSI_CID_MASK related bits are also useless since cid is always one. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/scsi/libiscsi.c14
-rw-r--r--include/scsi/iscsi_proto.h4
-rw-r--r--include/scsi/libiscsi.h2
3 files changed, 6 insertions, 14 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 10ba76285852..59f8445eab0d 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -160,7 +160,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
160 hdr->opcode = ISCSI_OP_SCSI_CMD; 160 hdr->opcode = ISCSI_OP_SCSI_CMD;
161 hdr->flags = ISCSI_ATTR_SIMPLE; 161 hdr->flags = ISCSI_ATTR_SIMPLE;
162 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun); 162 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
163 hdr->itt = build_itt(ctask->itt, conn->id, session->age); 163 hdr->itt = build_itt(ctask->itt, session->age);
164 hdr->data_length = cpu_to_be32(scsi_bufflen(sc)); 164 hdr->data_length = cpu_to_be32(scsi_bufflen(sc));
165 hdr->cmdsn = cpu_to_be32(session->cmdsn); 165 hdr->cmdsn = cpu_to_be32(session->cmdsn);
166 session->cmdsn++; 166 session->cmdsn++;
@@ -705,14 +705,6 @@ int iscsi_verify_itt(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
705 return ISCSI_ERR_BAD_ITT; 705 return ISCSI_ERR_BAD_ITT;
706 } 706 }
707 707
708 if (((__force u32)hdr->itt & ISCSI_CID_MASK) !=
709 (conn->id << ISCSI_CID_SHIFT)) {
710 iscsi_conn_printk(KERN_ERR, conn,
711 "iscsi: received itt %x, expected "
712 "CID (%x)\n",
713 (__force u32)hdr->itt, conn->id);
714 return ISCSI_ERR_BAD_ITT;
715 }
716 itt = get_itt(hdr->itt); 708 itt = get_itt(hdr->itt);
717 } else 709 } else
718 itt = ~0U; 710 itt = ~0U;
@@ -776,7 +768,7 @@ static void iscsi_prep_mtask(struct iscsi_conn *conn,
776 */ 768 */
777 nop->cmdsn = cpu_to_be32(session->cmdsn); 769 nop->cmdsn = cpu_to_be32(session->cmdsn);
778 if (hdr->itt != RESERVED_ITT) { 770 if (hdr->itt != RESERVED_ITT) {
779 hdr->itt = build_itt(mtask->itt, conn->id, session->age); 771 hdr->itt = build_itt(mtask->itt, session->age);
780 /* 772 /*
781 * TODO: We always use immediate, so we never hit this. 773 * TODO: We always use immediate, so we never hit this.
782 * If we start to send tmfs or nops as non-immediate then 774 * If we start to send tmfs or nops as non-immediate then
@@ -2036,6 +2028,8 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
2036 conn->stop_stage = 0; 2028 conn->stop_stage = 0;
2037 conn->tmf_state = TMF_INITIAL; 2029 conn->tmf_state = TMF_INITIAL;
2038 session->age++; 2030 session->age++;
2031 if (session->age == 16)
2032 session->age = 0;
2039 break; 2033 break;
2040 case STOP_CONN_TERM: 2034 case STOP_CONN_TERM:
2041 conn->stop_stage = 0; 2035 conn->stop_stage = 0;
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h
index 318a909e7ae1..5ffec8ad6964 100644
--- a/include/scsi/iscsi_proto.h
+++ b/include/scsi/iscsi_proto.h
@@ -45,8 +45,8 @@
45/* initiator tags; opaque for target */ 45/* initiator tags; opaque for target */
46typedef uint32_t __bitwise__ itt_t; 46typedef uint32_t __bitwise__ itt_t;
47/* below makes sense only for initiator that created this tag */ 47/* below makes sense only for initiator that created this tag */
48#define build_itt(itt, id, age) ((__force itt_t)\ 48#define build_itt(itt, age) ((__force itt_t)\
49 ((itt) | ((id) << ISCSI_CID_SHIFT) | ((age) << ISCSI_AGE_SHIFT))) 49 ((itt) | ((age) << ISCSI_AGE_SHIFT)))
50#define get_itt(itt) ((__force uint32_t)(itt_t)(itt) & ISCSI_ITT_MASK) 50#define get_itt(itt) ((__force uint32_t)(itt_t)(itt) & ISCSI_ITT_MASK)
51#define RESERVED_ITT ((__force itt_t)0xffffffff) 51#define RESERVED_ITT ((__force itt_t)0xffffffff)
52 52
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 5784e4ff8edc..7b90b63fb5c7 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -70,8 +70,6 @@ enum {
70#define ISCSI_SUSPEND_BIT 1 70#define ISCSI_SUSPEND_BIT 1
71 71
72#define ISCSI_ITT_MASK (0xfff) 72#define ISCSI_ITT_MASK (0xfff)
73#define ISCSI_CID_SHIFT 12
74#define ISCSI_CID_MASK (0xffff << ISCSI_CID_SHIFT)
75#define ISCSI_AGE_SHIFT 28 73#define ISCSI_AGE_SHIFT 28
76#define ISCSI_AGE_MASK (0xf << ISCSI_AGE_SHIFT) 74#define ISCSI_AGE_MASK (0xf << ISCSI_AGE_SHIFT)
77 75