summaryrefslogtreecommitdiff
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
authorPavel Shilovsky <piastry@etersoft.ru>2012-02-06 15:59:18 +0400
committerSteve French <sfrench@us.ibm.com>2012-03-21 20:35:03 +0400
commit2d86dbc97094ea4cfc2204fdefd7d07685496189 (patch)
tree9aee614e155fd837c78ded2cd083dead1a9d4a3f /fs/cifs/connect.c
parentfc40f9cf828908e91d9af820e9300a9d42fbbd72 (diff)
downloadlinux-2d86dbc97094ea4cfc2204fdefd7d07685496189.tar.xz
CIFS: Introduce credit-based flow control
and send no more than credits value requests at once. For SMB/CIFS it's trivial: increment this value by receiving any message and decrement by sending one. Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index ed91abcce8a9..1d489010615b 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -642,14 +642,10 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)
spin_unlock(&GlobalMid_Lock);
wake_up_all(&server->response_q);
- /* Check if we have blocked requests that need to free. */
+ /* check if we have blocked requests that need to free */
spin_lock(&server->req_lock);
- if (server->in_flight >= server->maxReq)
- server->in_flight = server->maxReq - 1;
- /*
- * We do not want to set the max_pending too low or we could end up
- * with the counter going negative.
- */
+ if (server->credits <= 0)
+ server->credits = 1;
spin_unlock(&server->req_lock);
/*
* Although there should not be any requests blocked on this queue it
@@ -1906,7 +1902,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
tcp_ses->noautotune = volume_info->noautotune;
tcp_ses->tcp_nodelay = volume_info->sockopt_tcp_nodelay;
tcp_ses->in_flight = 0;
- tcp_ses->maxReq = 1; /* enough to send negotiate request */
+ tcp_ses->credits = 1;
init_waitqueue_head(&tcp_ses->response_q);
init_waitqueue_head(&tcp_ses->request_q);
INIT_LIST_HEAD(&tcp_ses->pending_mid_q);
@@ -3757,9 +3753,11 @@ int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses)
if (server->maxBuf != 0)
return 0;
+ cifs_set_credits(server, 1);
rc = CIFSSMBNegotiate(xid, ses);
if (rc == -EAGAIN) {
/* retry only once on 1st time connection */
+ cifs_set_credits(server, 1);
rc = CIFSSMBNegotiate(xid, ses);
if (rc == -EAGAIN)
rc = -EHOSTDOWN;