CIFS: Use multicredits for SMB 2.1/3 writes
[cascardo/linux.git] / fs / cifs / transport.c
index 18cd565..9d087f4 100644 (file)
@@ -448,6 +448,15 @@ wait_for_free_request(struct TCP_Server_Info *server, const int timeout,
        return wait_for_free_credits(server, timeout, val);
 }
 
+int
+cifs_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,
+                     unsigned int *num, unsigned int *credits)
+{
+       *num = size;
+       *credits = 0;
+       return 0;
+}
+
 static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
                        struct mid_q_entry **ppmidQ)
 {
@@ -531,20 +540,23 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
 {
        int rc, timeout, optype;
        struct mid_q_entry *mid;
+       unsigned int credits = 0;
 
        timeout = flags & CIFS_TIMEOUT_MASK;
        optype = flags & CIFS_OP_MASK;
 
-       rc = wait_for_free_request(server, timeout, optype);
-       if (rc)
-               return rc;
+       if ((flags & CIFS_HAS_CREDITS) == 0) {
+               rc = wait_for_free_request(server, timeout, optype);
+               if (rc)
+                       return rc;
+               credits = 1;
+       }
 
        mutex_lock(&server->srv_mutex);
        mid = server->ops->setup_async_request(server, rqst);
        if (IS_ERR(mid)) {
                mutex_unlock(&server->srv_mutex);
-               add_credits(server, 1, optype);
-               wake_up(&server->request_q);
+               add_credits_and_wake_if(server, credits, optype);
                return PTR_ERR(mid);
        }
 
@@ -572,8 +584,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
                return 0;
 
        cifs_delete_mid(mid);
-       add_credits(server, 1, optype);
-       wake_up(&server->request_q);
+       add_credits_and_wake_if(server, credits, optype);
        return rc;
 }