cifs: wait_for_free_credits() make it possible to wait for >=1 credits
authorRonnie Sahlberg <lsahlber@redhat.com>
Fri, 8 Mar 2019 02:58:20 +0000 (12:58 +1000)
committerSteve French <stfrench@microsoft.com>
Fri, 15 Mar 2019 00:32:35 +0000 (19:32 -0500)
Change wait_for_free_credits() to allow waiting for >=1 credits instead of just
a single credit.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
fs/cifs/cifsglob.h
fs/cifs/smb2ops.c
fs/cifs/transport.c

index f293e052e351de99e4ebad80cc9805375e5980b4..ddb299494cd66011469a16e09663ce315a2d7423 100644 (file)
@@ -735,13 +735,13 @@ in_flight(struct TCP_Server_Info *server)
 }
 
 static inline bool
-has_credits(struct TCP_Server_Info *server, int *credits)
+has_credits(struct TCP_Server_Info *server, int *credits, int num_credits)
 {
        int num;
        spin_lock(&server->req_lock);
        num = *credits;
        spin_unlock(&server->req_lock);
-       return num > 0;
+       return num >= num_credits;
 }
 
 static inline void
index 085e91436da7e6d24b89e87ba753b9b672b89f6a..1654d50b8aef344ff68a9d4b82f73b9db8002be0 100644 (file)
@@ -185,7 +185,7 @@ smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,
                        spin_unlock(&server->req_lock);
                        cifs_num_waiters_inc(server);
                        rc = wait_event_killable(server->request_q,
-                                       has_credits(server, &server->credits));
+                               has_credits(server, &server->credits, 1));
                        cifs_num_waiters_dec(server);
                        if (rc)
                                return rc;
index 9fcc4a82943d76110d52d89f1d09f331d5b9a759..1951f9f74bb2591fbdbc19b9fa71523d69e4e176 100644 (file)
@@ -486,8 +486,8 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer,
 }
 
 static int
-wait_for_free_credits(struct TCP_Server_Info *server, const int flags,
-                     unsigned int *instance)
+wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits,
+                     const int flags, unsigned int *instance)
 {
        int rc;
        int *credits;
@@ -513,11 +513,11 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int flags,
        }
 
        while (1) {
-               if (*credits <= 0) {
+               if (*credits < num_credits) {
                        spin_unlock(&server->req_lock);
                        cifs_num_waiters_inc(server);
                        rc = wait_event_killable(server->request_q,
-                                                has_credits(server, credits));
+                               has_credits(server, credits, num_credits));
                        cifs_num_waiters_dec(server);
                        if (rc)
                                return rc;
@@ -535,8 +535,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int flags,
 
                        /* update # of requests on the wire to server */
                        if ((flags & CIFS_TIMEOUT_MASK) != CIFS_BLOCKING_OP) {
-                               *credits -= 1;
-                               server->in_flight++;
+                               *credits -= num_credits;
+                               server->in_flight += num_credits;
                                *instance = server->reconnect_instance;
                        }
                        spin_unlock(&server->req_lock);
@@ -550,7 +550,7 @@ static int
 wait_for_free_request(struct TCP_Server_Info *server, const int flags,
                      unsigned int *instance)
 {
-       return wait_for_free_credits(server, flags, instance);
+       return wait_for_free_credits(server, 1, flags, instance);
 }
 
 int