]> err.no Git - linux-2.6/commitdiff
[SCSI] iscsi: Some fixes in preparation for bidirectional support - total_length
authorMike Christie <michaelc@cs.wisc.edu>
Wed, 30 May 2007 17:57:15 +0000 (12:57 -0500)
committerJames Bottomley <jejb@mulgrave.(none)>
Fri, 1 Jun 2007 16:58:22 +0000 (12:58 -0400)
- Remove shadow of request length from struct iscsi_cmd_task.
- change all users to use scsi_cmnd->request_bufflen directly

(With bidi we will use scsi-ml API to retrieve in/out length)

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Cc: Roland Dreier <rdreier@cisco.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/infiniband/ulp/iser/iscsi_iser.c
drivers/scsi/iscsi_tcp.c
drivers/scsi/libiscsi.c
include/scsi/libiscsi.h

index e39d9a07bc5d2cdd403cd840c202311c85db3a05..568f88bf7c91ac0a4e102aa541c7a473d43a3da5 100644 (file)
@@ -140,10 +140,10 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask)
        iser_ctask->iser_conn    = iser_conn;
 
        if (sc->sc_data_direction == DMA_TO_DEVICE) {
-               BUG_ON(ctask->total_length == 0);
+               BUG_ON(sc->request_bufflen == 0);
 
                debug_scsi("cmd [itt %x total %d imm %d unsol_data %d\n",
-                          ctask->itt, ctask->total_length, ctask->imm_count,
+                          ctask->itt, sc->request_bufflen, ctask->imm_count,
                           ctask->unsol_count);
        }
 
index 17fc79c408a2c1b37ffd8acfe3c8d966e596223d..b2827d112cb0a4f599598db7c3d3d04562174c10 100644 (file)
@@ -216,6 +216,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
        struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
        struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr;
        struct iscsi_session *session = conn->session;
+       struct scsi_cmnd *sc = ctask->sc;
        int datasn = be32_to_cpu(rhdr->datasn);
 
        rc = iscsi_check_assign_cmdsn(session, (struct iscsi_nopin*)rhdr);
@@ -238,12 +239,14 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
        tcp_ctask->exp_datasn++;
 
        tcp_ctask->data_offset = be32_to_cpu(rhdr->offset);
-       if (tcp_ctask->data_offset + tcp_conn->in.datalen > ctask->total_length)
+       if (tcp_ctask->data_offset + tcp_conn->in.datalen > sc->request_bufflen) {
+               debug_tcp("%s: data_offset(%d) + data_len(%d) > total_length_in(%d)\n",
+                         __FUNCTION__, tcp_ctask->data_offset,
+                         tcp_conn->in.datalen, sc->request_bufflen);
                return ISCSI_ERR_DATA_OFFSET;
+       }
 
        if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) {
-               struct scsi_cmnd *sc = ctask->sc;
-
                conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
                if (rhdr->flags & ISCSI_FLAG_DATA_UNDERFLOW) {
                        int res_count = be32_to_cpu(rhdr->residual_count);
@@ -405,11 +408,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
                            r2t->data_length, session->max_burst);
 
        r2t->data_offset = be32_to_cpu(rhdr->data_offset);
-       if (r2t->data_offset + r2t->data_length > ctask->total_length) {
+       if (r2t->data_offset + r2t->data_length > ctask->sc->request_bufflen) {
                spin_unlock(&session->lock);
                printk(KERN_ERR "iscsi_tcp: invalid R2T with data len %u at "
                       "offset %u and total length %d\n", r2t->data_length,
-                      r2t->data_offset, ctask->total_length);
+                      r2t->data_offset, ctask->sc->request_bufflen);
                return ISCSI_ERR_DATALEN;
        }
 
@@ -604,7 +607,7 @@ iscsi_ctask_copy(struct iscsi_tcp_conn *tcp_conn, struct iscsi_cmd_task *ctask,
 {
        struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
        int buf_left = buf_size - (tcp_conn->data_copied + offset);
-       int size = min(tcp_conn->in.copy, buf_left);
+       unsigned size = min(tcp_conn->in.copy, buf_left);
        int rc;
 
        size = min(size, ctask->data_count);
@@ -613,7 +616,7 @@ iscsi_ctask_copy(struct iscsi_tcp_conn *tcp_conn, struct iscsi_cmd_task *ctask,
               size, tcp_conn->in.offset, tcp_conn->in.copied);
 
        BUG_ON(size <= 0);
-       BUG_ON(tcp_ctask->sent + size > ctask->total_length);
+       BUG_ON(tcp_ctask->sent + size > ctask->sc->request_bufflen);
 
        rc = skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset,
                           (char*)buf + (offset + tcp_conn->data_copied), size);
@@ -1292,7 +1295,7 @@ iscsi_tcp_cmd_init(struct iscsi_cmd_task *ctask)
 
        if (sc->sc_data_direction == DMA_TO_DEVICE) {
                tcp_ctask->xmstate = XMSTATE_W_HDR;
-               BUG_ON(ctask->total_length == 0);
+               BUG_ON(sc->request_bufflen == 0);
 
                if (sc->use_sg) {
                        struct scatterlist *sg = sc->request_buffer;
@@ -1309,7 +1312,7 @@ iscsi_tcp_cmd_init(struct iscsi_cmd_task *ctask)
                }
                debug_scsi("cmd [itt 0x%x total %d imm_data %d "
                           "unsol count %d, unsol offset %d]\n",
-                          ctask->itt, ctask->total_length, ctask->imm_count,
+                          ctask->itt, sc->request_bufflen, ctask->imm_count,
                           ctask->unsol_count, ctask->unsol_offset);
        } else
                tcp_ctask->xmstate = XMSTATE_R_HDR;
index eb51136079585880f318c002b11a087392779bd5..0a9c64e9ce8b57fd712ccb69e5eeb3ee86ec5c0a 100644 (file)
@@ -147,19 +147,19 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
                ctask->unsol_datasn = 0;
 
                if (session->imm_data_en) {
-                       if (ctask->total_length >= session->first_burst)
+                       if (sc->request_bufflen >= session->first_burst)
                                ctask->imm_count = min(session->first_burst,
                                                        conn->max_xmit_dlength);
                        else
-                               ctask->imm_count = min(ctask->total_length,
+                               ctask->imm_count = min(sc->request_bufflen,
                                                        conn->max_xmit_dlength);
                        hton24(ctask->hdr->dlength, ctask->imm_count);
                } else
                        zero_data(ctask->hdr->dlength);
 
                if (!session->initial_r2t_en) {
-                       ctask->unsol_count = min(session->first_burst,
-                               ctask->total_length) - ctask->imm_count;
+                       ctask->unsol_count = min((session->first_burst),
+                               (sc->request_bufflen)) - ctask->imm_count;
                        ctask->unsol_offset = ctask->imm_count;
                }
 
@@ -815,7 +815,6 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
        ctask->conn = conn;
        ctask->sc = sc;
        INIT_LIST_HEAD(&ctask->running);
-       ctask->total_length = sc->request_bufflen;
        iscsi_prep_scsi_cmd_pdu(ctask);
 
        session->tt->init_cmd_task(ctask);
index 61e069206ac5dd4237683d0ddb5ace20163b4ae3..348265d4a27e152276cb24d22abe788eb4094868 100644 (file)
@@ -80,7 +80,7 @@ struct iscsi_mgmt_task {
         */
        struct iscsi_hdr        *hdr;
        char                    *data;          /* mgmt payload */
-       int                     data_count;     /* counts data to be sent */
+       unsigned                data_count;     /* counts data to be sent */
        uint32_t                itt;            /* this ITT */
        void                    *dd_data;       /* driver/transport data */
        struct list_head        running;
@@ -101,13 +101,12 @@ struct iscsi_cmd_task {
        int                     itt;            /* this ITT */
 
        uint32_t                unsol_datasn;
-       int                     imm_count;      /* imm-data (bytes)   */
-       int                     unsol_count;    /* unsolicited (bytes)*/
+       unsigned                imm_count;      /* imm-data (bytes)   */
+       unsigned                unsol_count;    /* unsolicited (bytes)*/
        /* offset in unsolicited stream (bytes); */
-       int                     unsol_offset;
-       int                     data_count;     /* remaining Data-Out */
+       unsigned                unsol_offset;
+       unsigned                data_count;     /* remaining Data-Out */
        struct scsi_cmnd        *sc;            /* associated SCSI cmd*/
-       int                     total_length;
        struct iscsi_conn       *conn;          /* used connection    */
        struct iscsi_mgmt_task  *mtask;         /* tmf mtask in progr */
 
@@ -173,8 +172,8 @@ struct iscsi_conn {
        int                     tmabort_state;  /* see TMABORT_INITIAL, etc.*/
 
        /* negotiated params */
-       int                     max_recv_dlength; /* initiator_max_recv_dsl*/
-       int                     max_xmit_dlength; /* target_max_recv_dsl */
+       unsigned                max_recv_dlength; /* initiator_max_recv_dsl*/
+       unsigned                max_xmit_dlength; /* target_max_recv_dsl */
        int                     hdrdgst_en;
        int                     datadgst_en;
        int                     ifmarker_en;
@@ -212,10 +211,10 @@ struct iscsi_session {
 
        /* configuration */
        int                     initial_r2t_en;
-       int                     max_r2t;
+       unsigned                max_r2t;
        int                     imm_data_en;
-       int                     first_burst;
-       int                     max_burst;
+       unsigned                first_burst;
+       unsigned                max_burst;
        int                     time2wait;
        int                     time2retain;
        int                     pdu_inorder_en;