Merge branch 'x86/cpu' into x86/urgent
[sfrench/cifs-2.6.git] / drivers / target / iscsi / iscsi_target_erl1.c
index 1b54a9c7085183da5cc7bb94464f6e480b27f720..e02e1aaf63c5552a0430aecd21bfdf7e4d7b495b 100644 (file)
@@ -48,14 +48,20 @@ int iscsit_dump_data_payload(
        u32 buf_len,
        int dump_padding_digest)
 {
-       char *buf, pad_bytes[4];
+       char *buf;
        int ret = DATAOUT_WITHIN_COMMAND_RECOVERY, rx_got;
-       u32 length, padding, offset = 0, size;
+       u32 length, offset = 0, size;
        struct kvec iov;
 
        if (conn->sess->sess_ops->RDMAExtensions)
                return 0;
 
+       if (dump_padding_digest) {
+               buf_len = ALIGN(buf_len, 4);
+               if (conn->conn_ops->DataDigest)
+                       buf_len += ISCSI_CRC_LEN;
+       }
+
        length = min(buf_len, OFFLOAD_BUF_SIZE);
 
        buf = kzalloc(length, GFP_ATOMIC);
@@ -75,41 +81,12 @@ int iscsit_dump_data_payload(
                rx_got = rx_data(conn, &iov, 1, size);
                if (rx_got != size) {
                        ret = DATAOUT_CANNOT_RECOVER;
-                       goto out;
+                       break;
                }
 
                offset += size;
        }
 
-       if (!dump_padding_digest)
-               goto out;
-
-       padding = ((-buf_len) & 3);
-       if (padding != 0) {
-               iov.iov_len = padding;
-               iov.iov_base = pad_bytes;
-
-               rx_got = rx_data(conn, &iov, 1, padding);
-               if (rx_got != padding) {
-                       ret = DATAOUT_CANNOT_RECOVER;
-                       goto out;
-               }
-       }
-
-       if (conn->conn_ops->DataDigest) {
-               u32 data_crc;
-
-               iov.iov_len = ISCSI_CRC_LEN;
-               iov.iov_base = &data_crc;
-
-               rx_got = rx_data(conn, &iov, 1, ISCSI_CRC_LEN);
-               if (rx_got != ISCSI_CRC_LEN) {
-                       ret = DATAOUT_CANNOT_RECOVER;
-                       goto out;
-               }
-       }
-
-out:
        kfree(buf);
        return ret;
 }
@@ -797,14 +774,14 @@ static struct iscsi_ooo_cmdsn *iscsit_allocate_ooo_cmdsn(void)
        return ooo_cmdsn;
 }
 
-/*
- *     Called with sess->cmdsn_mutex held.
- */
 static int iscsit_attach_ooo_cmdsn(
        struct iscsi_session *sess,
        struct iscsi_ooo_cmdsn *ooo_cmdsn)
 {
        struct iscsi_ooo_cmdsn *ooo_tail, *ooo_tmp;
+
+       lockdep_assert_held(&sess->cmdsn_mutex);
+
        /*
         * We attach the struct iscsi_ooo_cmdsn entry to the out of order
         * list in increasing CmdSN order.
@@ -871,15 +848,14 @@ void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *conn)
        mutex_unlock(&sess->cmdsn_mutex);
 }
 
-/*
- *     Called with sess->cmdsn_mutex held.
- */
 int iscsit_execute_ooo_cmdsns(struct iscsi_session *sess)
 {
        int ooo_count = 0;
        struct iscsi_cmd *cmd = NULL;
        struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;
 
+       lockdep_assert_held(&sess->cmdsn_mutex);
+
        list_for_each_entry_safe(ooo_cmdsn, ooo_cmdsn_tmp,
                                &sess->sess_ooo_cmdsn_list, ooo_list) {
                if (ooo_cmdsn->cmdsn != sess->exp_cmd_sn)
@@ -980,7 +956,7 @@ int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo)
                        if (cmd->se_cmd.transport_state & CMD_T_ABORTED)
                                return 0;
 
-                       iscsit_set_unsoliticed_dataout(cmd);
+                       iscsit_set_unsolicited_dataout(cmd);
                }
                return transport_handle_cdb_direct(&cmd->se_cmd);
 
@@ -1232,9 +1208,6 @@ void iscsit_mod_dataout_timer(struct iscsi_cmd *cmd)
        spin_unlock_bh(&cmd->dataout_timeout_lock);
 }
 
-/*
- *     Called with cmd->dataout_timeout_lock held.
- */
 void iscsit_start_dataout_timer(
        struct iscsi_cmd *cmd,
        struct iscsi_conn *conn)
@@ -1242,6 +1215,8 @@ void iscsit_start_dataout_timer(
        struct iscsi_session *sess = conn->sess;
        struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
 
+       lockdep_assert_held(&cmd->dataout_timeout_lock);
+
        if (cmd->dataout_timer_flags & ISCSI_TF_RUNNING)
                return;