drivers: replace NIPQUAD()
[safe/jmp/linux-2.6] / drivers / scsi / iscsi_tcp.c
index 91cb1fd..e11bce6 100644 (file)
@@ -523,28 +523,26 @@ iscsi_tcp_cleanup_task(struct iscsi_conn *conn, struct iscsi_task *task)
 }
 
 /**
- * iscsi_data_rsp - SCSI Data-In Response processing
+ * iscsi_data_in - SCSI Data-In Response processing
  * @conn: iscsi connection
  * @task: scsi command task
  **/
 static int
-iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
+iscsi_data_in(struct iscsi_conn *conn, struct iscsi_task *task)
 {
        struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
        struct iscsi_tcp_task *tcp_task = task->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 = task->sc;
        int datasn = be32_to_cpu(rhdr->datasn);
-       unsigned total_in_length = scsi_in(sc)->length;
+       unsigned total_in_length = scsi_in(task->sc)->length;
 
-       iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
+       iscsi_update_cmdsn(conn->session, (struct iscsi_nopin*)rhdr);
        if (tcp_conn->in.datalen == 0)
                return 0;
 
        if (tcp_task->exp_datasn != datasn) {
                debug_tcp("%s: task->exp_datasn(%d) != rhdr->datasn(%d)\n",
-                         __FUNCTION__, tcp_task->exp_datasn, datasn);
+                         __func__, tcp_task->exp_datasn, datasn);
                return ISCSI_ERR_DATASN;
        }
 
@@ -553,28 +551,11 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
        tcp_task->data_offset = be32_to_cpu(rhdr->offset);
        if (tcp_task->data_offset + tcp_conn->in.datalen > total_in_length) {
                debug_tcp("%s: data_offset(%d) + data_len(%d) > total_length_in(%d)\n",
-                         __FUNCTION__, tcp_task->data_offset,
+                         __func__, tcp_task->data_offset,
                          tcp_conn->in.datalen, total_in_length);
                return ISCSI_ERR_DATA_OFFSET;
        }
 
-       if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) {
-               sc->result = (DID_OK << 16) | rhdr->cmd_status;
-               conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
-               if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
-                                  ISCSI_FLAG_DATA_OVERFLOW)) {
-                       int res_count = be32_to_cpu(rhdr->residual_count);
-
-                       if (res_count > 0 &&
-                           (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
-                            res_count <= total_in_length))
-                               scsi_in(sc)->resid = res_count;
-                       else
-                               sc->result = (DID_BAD_TARGET << 16) |
-                                       rhdr->cmd_status;
-               }
-       }
-
        conn->datain_pdus_cnt++;
        return 0;
 }
@@ -646,7 +627,7 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
 
        if (tcp_task->exp_datasn != r2tsn){
                debug_tcp("%s: task->exp_datasn(%d) != rhdr->r2tsn(%d)\n",
-                         __FUNCTION__, tcp_task->exp_datasn, r2tsn);
+                         __func__, tcp_task->exp_datasn, r2tsn);
                return ISCSI_ERR_R2TSN;
        }
 
@@ -774,7 +755,7 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
                if (!task)
                        rc = ISCSI_ERR_BAD_ITT;
                else
-                       rc = iscsi_data_rsp(conn, task);
+                       rc = iscsi_data_in(conn, task);
                if (rc) {
                        spin_unlock(&conn->session->lock);
                        break;
@@ -998,7 +979,7 @@ iscsi_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,
 
 error:
        debug_tcp("Error receiving PDU, errno=%d\n", rc);
-       iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
+       iscsi_conn_failure(conn, rc);
        return 0;
 }
 
@@ -1117,8 +1098,10 @@ iscsi_xmit(struct iscsi_conn *conn)
 
        while (1) {
                rc = iscsi_tcp_xmit_segment(tcp_conn, segment);
-               if (rc < 0)
+               if (rc < 0) {
+                       rc = ISCSI_ERR_XMIT_FAILED;
                        goto error;
+               }
                if (rc == 0)
                        break;
 
@@ -1127,7 +1110,7 @@ iscsi_xmit(struct iscsi_conn *conn)
                if (segment->total_copied >= segment->total_size) {
                        if (segment->done != NULL) {
                                rc = segment->done(tcp_conn, segment);
-                               if (rc < 0)
+                               if (rc != 0)
                                        goto error;
                        }
                }
@@ -1142,8 +1125,8 @@ error:
        /* Transmit error. We could initiate error recovery
         * here. */
        debug_tcp("Error sending PDU, errno=%d\n", rc);
-       iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
-       return rc;
+       iscsi_conn_failure(conn, rc);
+       return -EIO;
 }
 
 /**
@@ -1193,7 +1176,7 @@ iscsi_tcp_send_hdr_prep(struct iscsi_conn *conn, void *hdr, size_t hdrlen)
 {
        struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
 
-       debug_tcp("%s(%p%s)\n", __FUNCTION__, tcp_conn,
+       debug_tcp("%s(%p%s)\n", __func__, tcp_conn,
                        conn->hdrdgst_en? ", digest enabled" : "");
 
        /* Clear the data segment - needs to be filled in by the
@@ -1234,7 +1217,7 @@ iscsi_tcp_send_data_prep(struct iscsi_conn *conn, struct scatterlist *sg,
        struct hash_desc *tx_hash = NULL;
        unsigned int hdr_spec_len;
 
-       debug_tcp("%s(%p, offset=%d, datalen=%d%s)\n", __FUNCTION__,
+       debug_tcp("%s(%p, offset=%d, datalen=%d%s)\n", __func__,
                        tcp_conn, offset, len,
                        conn->datadgst_en? ", digest enabled" : "");
 
@@ -1259,7 +1242,7 @@ iscsi_tcp_send_linear_data_prepare(struct iscsi_conn *conn, void *data,
        struct hash_desc *tx_hash = NULL;
        unsigned int hdr_spec_len;
 
-       debug_tcp("%s(%p, datalen=%d%s)\n", __FUNCTION__, tcp_conn, len,
+       debug_tcp("%s(%p, datalen=%d%s)\n", __func__, tcp_conn, len,
                  conn->datadgst_en? ", digest enabled" : "");
 
        /* Make sure the datalen matches what the caller
@@ -1618,14 +1601,14 @@ static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock,
        case AF_INET:
                sin = (struct sockaddr_in *)addr;
                spin_lock_bh(&conn->session->lock);
-               sprintf(buf, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr));
+               sprintf(buf, "%pI4", &sin->sin_addr.s_addr);
                *port = be16_to_cpu(sin->sin_port);
                spin_unlock_bh(&conn->session->lock);
                break;
        case AF_INET6:
                sin6 = (struct sockaddr_in6 *)addr;
                spin_lock_bh(&conn->session->lock);
-               sprintf(buf, NIP6_FMT, NIP6(sin6->sin6_addr));
+               sprintf(buf, "%pI6", &sin6->sin6_addr);
                *port = be16_to_cpu(sin6->sin6_port);
                spin_unlock_bh(&conn->session->lock);
                break;
@@ -1864,8 +1847,7 @@ iscsi_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max,
        shost->max_lun = iscsi_max_lun;
        shost->max_id = 0;
        shost->max_channel = 0;
-       shost->max_cmd_len = 16;
-       shost->can_queue = cmds_max;
+       shost->max_cmd_len = SCSI_MAX_VARLEN_CDB_SIZE;
 
        if (iscsi_host_add(shost, NULL))
                goto free_host;
@@ -1905,6 +1887,7 @@ static void iscsi_tcp_session_destroy(struct iscsi_cls_session *cls_session)
        struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
 
        iscsi_r2tpool_free(cls_session->dd_data);
+       iscsi_session_teardown(cls_session);
 
        iscsi_host_remove(shost);
        iscsi_host_free(shost);
@@ -1928,7 +1911,7 @@ static struct scsi_host_template iscsi_sht = {
        .cmd_per_lun            = ISCSI_DEF_CMD_PER_LUN,
        .eh_abort_handler       = iscsi_eh_abort,
        .eh_device_reset_handler= iscsi_eh_device_reset,
-       .eh_host_reset_handler  = iscsi_eh_host_reset,
+       .eh_target_reset_handler= iscsi_eh_target_reset,
        .use_clustering         = DISABLE_CLUSTERING,
        .slave_configure        = iscsi_tcp_slave_configure,
        .proc_name              = "iscsi_tcp",