disable some mediatekl custom warnings
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / cifs / transport.c
index 1a528680ec5a29e4b59485fba5df54568a1e3787..b70aa7c913940c3766263b67e564a053883f9f32 100644 (file)
@@ -49,7 +49,7 @@ AllocMidQEntry(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server)
        struct mid_q_entry *temp;
 
        if (server == NULL) {
-               cERROR(1, "Null TCP session in AllocMidQEntry");
+               cifs_dbg(VFS, "Null TCP session in AllocMidQEntry\n");
                return NULL;
        }
 
@@ -61,7 +61,7 @@ AllocMidQEntry(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server)
                temp->mid = smb_buffer->Mid;    /* always LE */
                temp->pid = current->pid;
                temp->command = cpu_to_le16(smb_buffer->Command);
-               cFYI(1, "For smb_command %d", smb_buffer->Command);
+               cifs_dbg(FYI, "For smb_command %d\n", smb_buffer->Command);
        /*      do_gettimeofday(&temp->when_sent);*/ /* easier to use jiffies */
                /* when mid allocated can be before when sent */
                temp->when_alloc = jiffies;
@@ -179,17 +179,11 @@ smb_send_kvec(struct TCP_Server_Info *server, struct kvec *iov, size_t n_vec,
                 */
                rc = kernel_sendmsg(ssocket, &smb_msg, &iov[first_vec],
                                    n_vec - first_vec, remaining);
-               if (rc == -ENOSPC || rc == -EAGAIN) {
-                       /*
-                        * Catch if a low level driver returns -ENOSPC. This
-                        * WARN_ON will be removed by 3.10 if no one reports
-                        * seeing this.
-                        */
-                       WARN_ON_ONCE(rc == -ENOSPC);
+               if (rc == -EAGAIN) {
                        i++;
                        if (i >= 14 || (!server->noblocksnd && (i > 2))) {
-                               cERROR(1, "sends on sock %p stuck for 15 "
-                                         "seconds", ssocket);
+                               cifs_dbg(VFS, "sends on sock %p stuck for 15 seconds\n",
+                                        ssocket);
                                rc = -EAGAIN;
                                break;
                        }
@@ -209,14 +203,14 @@ smb_send_kvec(struct TCP_Server_Info *server, struct kvec *iov, size_t n_vec,
                }
 
                if (rc > remaining) {
-                       cERROR(1, "sent %d requested %d", rc, remaining);
+                       cifs_dbg(VFS, "sent %d requested %d\n", rc, remaining);
                        break;
                }
 
                if (rc == 0) {
                        /* should never happen, letting socket clear before
                           retrying is our only obvious option here */
-                       cERROR(1, "tcp sent no data");
+                       cifs_dbg(VFS, "tcp sent no data\n");
                        msleep(500);
                        continue;
                }
@@ -291,7 +285,7 @@ smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst)
        if (ssocket == NULL)
                return -ENOTSOCK;
 
-       cFYI(1, "Sending smb: smb_len=%u", smb_buf_length);
+       cifs_dbg(FYI, "Sending smb: smb_len=%u\n", smb_buf_length);
        dump_smb(iov[0].iov_base, iov[0].iov_len);
 
        /* cork the socket */
@@ -324,8 +318,8 @@ uncork:
                                (char *)&val, sizeof(val));
 
        if ((total_len > 0) && (total_len != smb_buf_length + 4)) {
-               cFYI(1, "partial send (wanted=%u sent=%zu): terminating "
-                       "session", smb_buf_length + 4, total_len);
+               cifs_dbg(FYI, "partial send (wanted=%u sent=%zu): terminating session\n",
+                        smb_buf_length + 4, total_len);
                /*
                 * If we have only sent part of an SMB then the next SMB could
                 * be taken as the remainder of this one. We need to kill the
@@ -335,7 +329,8 @@ uncork:
        }
 
        if (rc < 0 && rc != -EINTR)
-               cERROR(1, "Error %d sending data on socket to server", rc);
+               cifs_dbg(VFS, "Error %d sending data on socket to server\n",
+                        rc);
        else
                rc = 0;
 
@@ -427,7 +422,7 @@ static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
        }
 
        if (ses->server->tcpStatus == CifsNeedReconnect) {
-               cFYI(1, "tcp session dead - return to caller to retry");
+               cifs_dbg(FYI, "tcp session dead - return to caller to retry\n");
                return -EAGAIN;
        }
 
@@ -452,7 +447,7 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ)
 {
        int error;
 
-       error = wait_event_freezekillable(server->response_q,
+       error = wait_event_freezekillable_unsafe(server->response_q,
                                    midQ->mid_state != MID_REQUEST_SUBMITTED);
        if (error < 0)
                return -ERESTARTSYS;
@@ -527,6 +522,9 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
        rc = smb_send_rqst(server, rqst);
        cifs_in_send_dec(server);
        cifs_save_when_sent(mid);
+
+       if (rc < 0)
+               server->sequence_number -= 2;
        mutex_unlock(&server->srv_mutex);
 
        if (rc == 0)
@@ -559,7 +557,7 @@ SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
        iov[0].iov_len = get_rfc1002_length(in_buf) + 4;
        flags |= CIFS_NO_RESP;
        rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags);
-       cFYI(DBG2, "SendRcvNoRsp flags %d rc %d", flags, rc);
+       cifs_dbg(NOISY, "SendRcvNoRsp flags %d rc %d\n", flags, rc);
 
        return rc;
 }
@@ -569,8 +567,8 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server)
 {
        int rc = 0;
 
-       cFYI(1, "%s: cmd=%d mid=%llu state=%d", __func__,
-            le16_to_cpu(mid->command), mid->mid, mid->mid_state);
+       cifs_dbg(FYI, "%s: cmd=%d mid=%llu state=%d\n",
+                __func__, le16_to_cpu(mid->command), mid->mid, mid->mid_state);
 
        spin_lock(&GlobalMid_Lock);
        switch (mid->mid_state) {
@@ -588,8 +586,8 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server)
                break;
        default:
                list_del_init(&mid->qhead);
-               cERROR(1, "%s: invalid mid state mid=%llu state=%d", __func__,
-                      mid->mid, mid->mid_state);
+               cifs_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n",
+                        __func__, mid->mid, mid->mid_state);
                rc = -EIO;
        }
        spin_unlock(&GlobalMid_Lock);
@@ -624,10 +622,10 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
                iov.iov_len = len;
                /* FIXME: add code to kill session */
                rc = cifs_verify_signature(&rqst, server,
-                                          mid->sequence_number + 1);
+                                          mid->sequence_number);
                if (rc)
-                       cERROR(1, "SMB signature verification returned error = "
-                              "%d", rc);
+                       cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
+                                rc);
        }
 
        /* BB special case reconnect tid and uid here? */
@@ -672,7 +670,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
 
        if ((ses == NULL) || (ses->server == NULL)) {
                cifs_small_buf_release(buf);
-               cERROR(1, "Null session");
+               cifs_dbg(VFS, "Null session\n");
                return -EIO;
        }
 
@@ -716,6 +714,8 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
        cifs_in_send_dec(ses->server);
        cifs_save_when_sent(midQ);
 
+       if (rc < 0)
+               ses->server->sequence_number -= 2;
        mutex_unlock(&ses->server->srv_mutex);
 
        if (rc < 0) {
@@ -752,7 +752,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
 
        if (!midQ->resp_buf || midQ->mid_state != MID_RESPONSE_RECEIVED) {
                rc = -EIO;
-               cFYI(1, "Bad MID state?");
+               cifs_dbg(FYI, "Bad MID state?\n");
                goto out;
        }
 
@@ -788,11 +788,11 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
        struct mid_q_entry *midQ;
 
        if (ses == NULL) {
-               cERROR(1, "Null smb session");
+               cifs_dbg(VFS, "Null smb session\n");
                return -EIO;
        }
        if (ses->server == NULL) {
-               cERROR(1, "Null tcp session");
+               cifs_dbg(VFS, "Null tcp session\n");
                return -EIO;
        }
 
@@ -805,8 +805,8 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
 
        if (be32_to_cpu(in_buf->smb_buf_length) > CIFSMaxBufSize +
                        MAX_CIFS_HDR_SIZE - 4) {
-               cERROR(1, "Illegal length, greater than maximum frame, %d",
-                          be32_to_cpu(in_buf->smb_buf_length));
+               cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
+                        be32_to_cpu(in_buf->smb_buf_length));
                return -EIO;
        }
 
@@ -840,6 +840,10 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
        rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
        cifs_in_send_dec(ses->server);
        cifs_save_when_sent(midQ);
+
+       if (rc < 0)
+               ses->server->sequence_number -= 2;
+
        mutex_unlock(&ses->server->srv_mutex);
 
        if (rc < 0)
@@ -871,7 +875,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
        if (!midQ->resp_buf || !out_buf ||
            midQ->mid_state != MID_RESPONSE_RECEIVED) {
                rc = -EIO;
-               cERROR(1, "Bad MID state?");
+               cifs_dbg(VFS, "Bad MID state?\n");
                goto out;
        }
 
@@ -921,13 +925,13 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
        struct cifs_ses *ses;
 
        if (tcon == NULL || tcon->ses == NULL) {
-               cERROR(1, "Null smb session");
+               cifs_dbg(VFS, "Null smb session\n");
                return -EIO;
        }
        ses = tcon->ses;
 
        if (ses->server == NULL) {
-               cERROR(1, "Null tcp session");
+               cifs_dbg(VFS, "Null tcp session\n");
                return -EIO;
        }
 
@@ -940,8 +944,8 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
 
        if (be32_to_cpu(in_buf->smb_buf_length) > CIFSMaxBufSize +
                        MAX_CIFS_HDR_SIZE - 4) {
-               cERROR(1, "Illegal length, greater than maximum frame, %d",
-                          be32_to_cpu(in_buf->smb_buf_length));
+               cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
+                        be32_to_cpu(in_buf->smb_buf_length));
                return -EIO;
        }
 
@@ -973,6 +977,10 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
        rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
        cifs_in_send_dec(ses->server);
        cifs_save_when_sent(midQ);
+
+       if (rc < 0)
+               ses->server->sequence_number -= 2;
+
        mutex_unlock(&ses->server->srv_mutex);
 
        if (rc < 0) {
@@ -1038,7 +1046,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
        /* rcvd frame is ok */
        if (out_buf == NULL || midQ->mid_state != MID_RESPONSE_RECEIVED) {
                rc = -EIO;
-               cERROR(1, "Bad MID state?");
+               cifs_dbg(VFS, "Bad MID state?\n");
                goto out;
        }