Browse Source

[CIFS] Free small buffers earlier so we exceed the cifs
small req buffer pool less often.

Signed-off-by: Steve French <sfrench@us.ibm.com>

Steve French 19 years ago
parent
commit
4b8f930ff8
3 changed files with 18 additions and 13 deletions
  1. 3 3
      fs/cifs/cifssmb.c
  2. 1 2
      fs/cifs/ntlmssp.c
  3. 14 8
      fs/cifs/transport.c

+ 3 - 3
fs/cifs/cifssmb.c

@@ -1070,7 +1070,7 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
 		}
 		}
 	}
 	}
 
 
-	cifs_small_buf_release(pSMB);
+/*	cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
 	if(*buf) {
 	if(*buf) {
 		if(resp_buf_type == CIFS_SMALL_BUFFER)
 		if(resp_buf_type == CIFS_SMALL_BUFFER)
 			cifs_small_buf_release(iov[0].iov_base);
 			cifs_small_buf_release(iov[0].iov_base);
@@ -1274,7 +1274,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
 		*nbytes += le16_to_cpu(pSMBr->Count);
 		*nbytes += le16_to_cpu(pSMBr->Count);
 	} 
 	} 
 
 
-	cifs_small_buf_release(pSMB);
+/*	cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
 	if(resp_buf_type == CIFS_SMALL_BUFFER)
 	if(resp_buf_type == CIFS_SMALL_BUFFER)
 		cifs_small_buf_release(iov[0].iov_base);
 		cifs_small_buf_release(iov[0].iov_base);
 	else if(resp_buf_type == CIFS_LARGE_BUFFER)
 	else if(resp_buf_type == CIFS_LARGE_BUFFER)
@@ -2606,7 +2606,7 @@ qsec_out:
 		cifs_small_buf_release(iov[0].iov_base);
 		cifs_small_buf_release(iov[0].iov_base);
 	else if(buf_type == CIFS_LARGE_BUFFER)
 	else if(buf_type == CIFS_LARGE_BUFFER)
 		cifs_buf_release(iov[0].iov_base);
 		cifs_buf_release(iov[0].iov_base);
-	cifs_small_buf_release(pSMB);
+/*	cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
 	return rc;
 	return rc;
 }
 }
 
 

+ 1 - 2
fs/cifs/ntlmssp.c

@@ -122,8 +122,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, const int type,
 
 
 
 
 /*	rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buf_type, 0); */
 /*	rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buf_type, 0); */
-
-	cifs_small_buf_release(smb_buffer);
+	/* SMB request buf freed in SendReceive2 */
 
 
 	return rc;
 	return rc;
 }
 }

+ 14 - 8
fs/cifs/transport.c

@@ -309,17 +309,16 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
 	
 	
 	*pRespBufType = CIFS_NO_BUFFER;  /* no response buf yet */
 	*pRespBufType = CIFS_NO_BUFFER;  /* no response buf yet */
 
 
-	if (ses == NULL) {
-		cERROR(1,("Null smb session"));
-		return -EIO;
-	}
-	if(ses->server == NULL) {
-		cERROR(1,("Null tcp session"));
+	if ((ses == NULL) || (ses->server == NULL)) {
+		cifs_small_buf_release(in_buf);
+		cERROR(1,("Null session"));
 		return -EIO;
 		return -EIO;
 	}
 	}
 
 
-	if(ses->server->tcpStatus == CifsExiting)
+	if(ses->server->tcpStatus == CifsExiting) {
+		cifs_small_buf_release(in_buf);
 		return -ENOENT;
 		return -ENOENT;
+	}
 
 
 	/* Ensure that we do not send more than 50 overlapping requests 
 	/* Ensure that we do not send more than 50 overlapping requests 
 	   to the same server. We may make this configurable later or
 	   to the same server. We may make this configurable later or
@@ -346,6 +345,7 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
 			} else {
 			} else {
 				if(ses->server->tcpStatus == CifsExiting) {
 				if(ses->server->tcpStatus == CifsExiting) {
 					spin_unlock(&GlobalMid_Lock);
 					spin_unlock(&GlobalMid_Lock);
+					cifs_small_buf_release(in_buf);
 					return -ENOENT;
 					return -ENOENT;
 				}
 				}
 
 
@@ -385,6 +385,7 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
 	midQ = AllocMidQEntry(in_buf, ses);
 	midQ = AllocMidQEntry(in_buf, ses);
 	if (midQ == NULL) {
 	if (midQ == NULL) {
 		up(&ses->server->tcpSem);
 		up(&ses->server->tcpSem);
+		cifs_small_buf_release(in_buf);
 		/* If not lock req, update # of requests on wire to server */
 		/* If not lock req, update # of requests on wire to server */
 		if(long_op < 3) {
 		if(long_op < 3) {
 			atomic_dec(&ses->server->inFlight); 
 			atomic_dec(&ses->server->inFlight); 
@@ -408,14 +409,18 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
 	if(rc < 0) {
 	if(rc < 0) {
 		DeleteMidQEntry(midQ);
 		DeleteMidQEntry(midQ);
 		up(&ses->server->tcpSem);
 		up(&ses->server->tcpSem);
+		cifs_small_buf_release(in_buf);
 		/* If not lock req, update # of requests on wire to server */
 		/* If not lock req, update # of requests on wire to server */
 		if(long_op < 3) {
 		if(long_op < 3) {
 			atomic_dec(&ses->server->inFlight); 
 			atomic_dec(&ses->server->inFlight); 
 			wake_up(&ses->server->request_q);
 			wake_up(&ses->server->request_q);
 		}
 		}
 		return rc;
 		return rc;
-	} else
+	} else {
 		up(&ses->server->tcpSem);
 		up(&ses->server->tcpSem);
+		cifs_small_buf_release(in_buf);
+	}
+
 	if (long_op == -1)
 	if (long_op == -1)
 		goto cifs_no_response_exit2;
 		goto cifs_no_response_exit2;
 	else if (long_op == 2) /* writes past end of file can take loong time */
 	else if (long_op == 2) /* writes past end of file can take loong time */
@@ -543,6 +548,7 @@ cifs_no_response_exit2:
 
 
 out_unlock2:
 out_unlock2:
 	up(&ses->server->tcpSem);
 	up(&ses->server->tcpSem);
+	cifs_small_buf_release(in_buf);
 	/* If not lock req, update # of requests on wire to server */
 	/* If not lock req, update # of requests on wire to server */
 	if(long_op < 3) {
 	if(long_op < 3) {
 		atomic_dec(&ses->server->inFlight); 
 		atomic_dec(&ses->server->inFlight);