This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / fs / cifs / transport.c
index 3668ab0..f3824d5 100644 (file)
@@ -200,23 +200,41 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
        }
 
        /* Ensure that we do not send more than 50 overlapping requests 
-               to the same server. We may make this configurable later or
-               use ses->maxReq */
-
-       /* can not count locking commands against the total since
-               they are allowed to block on server */
-       if(long_op < 3) {
-               /* update # of requests on the wire to this server */
-               atomic_inc(&ses->server->inFlight); 
-       }
-       if(atomic_read(&ses->server->inFlight) > CIFS_MAX_REQ) {
-               wait_event(ses->server->request_q,atomic_read(&ses->server->inFlight) <= CIFS_MAX_REQ);
+          to the same server. We may make this configurable later or
+          use ses->maxReq */
+       if(long_op == -1) {
+               /* oplock breaks must not be held up */
+               atomic_inc(&ses->server->inFlight);
+       } else {
+               spin_lock(&GlobalMid_Lock); 
+               while(1) {        
+                       if(atomic_read(&ses->server->inFlight) >= CIFS_MAX_REQ){
+                               spin_unlock(&GlobalMid_Lock);
+                               wait_event(ses->server->request_q,
+                                       atomic_read(&ses->server->inFlight)
+                                        < CIFS_MAX_REQ);
+                               spin_lock(&GlobalMid_Lock);
+                       } else {
+                               if(ses->server->tcpStatus == CifsExiting) {
+                                       spin_unlock(&GlobalMid_Lock);
+                                       return -ENOENT;
+                               }
+
+                       /* can not count locking commands against total since
+                          they are allowed to block on server */
+                                       
+                               if(long_op < 3) {
+                               /* update # of requests on the wire to server */
+                                       atomic_inc(&ses->server->inFlight);
+                               }
+                               spin_unlock(&GlobalMid_Lock);
+                               break;
+                       }
+               }
        }
-
        /* make sure that we sign in the same order that we send on this socket 
-               and avoid races inside tcp sendmsg code that could cause corruption
-               of smb data */
+          and avoid races inside tcp sendmsg code that could cause corruption
+          of smb data */
 
        down(&ses->server->tcpSem);