From patchwork Wed Mar 16 19:15:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 639561 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2GJMkVo030448 for ; Wed, 16 Mar 2011 19:23:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753516Ab1CPTXF (ORCPT ); Wed, 16 Mar 2011 15:23:05 -0400 Received: from mail-vx0-f174.google.com ([209.85.220.174]:48545 "EHLO mail-vx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753514Ab1CPTXE (ORCPT ); Wed, 16 Mar 2011 15:23:04 -0400 Received: by mail-vx0-f174.google.com with SMTP id 39so1965965vxi.19 for ; Wed, 16 Mar 2011 12:23:04 -0700 (PDT) Received: by 10.52.175.134 with SMTP id ca6mr501010vdc.110.1300302940584; Wed, 16 Mar 2011 12:15:40 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-075-177-180-210.nc.res.rr.com [75.177.180.210]) by mx.google.com with ESMTPS id eh10sm873050vbb.2.2011.03.16.12.15.38 (version=SSLv3 cipher=OTHER); Wed, 16 Mar 2011 12:15:39 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH 1/3] cifs: clarify the meaning of tcpStatus == CifsGood Date: Wed, 16 Mar 2011 15:15:29 -0400 Message-Id: <1300302931-13830-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.4 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 16 Mar 2011 19:23:06 +0000 (UTC) difference between these two states, and we need to know this in order to know whether we can send an echo or not. Resolve this by adding a new statusEnum value -- CifsNeedNegotiate. When the socket has been connected but has not yet had a NEGOTIATE_PROTOCOL request done, set it to this value. Once the NEGOTIATE is done, cifs_negotiate_protocol will set tcpStatus to CifsGood. This also fixes and cleans the logic in cifs_reconnect and cifs_reconnect_tcon. The old code checked for specific states when what it really wants to know is whether the state has actually changed from CifsNeedReconnect. Reported-and-Tested-by: JG Signed-off-by: Jeff Layton --- fs/cifs/cifsglob.h | 3 ++- fs/cifs/cifssmb.c | 4 ++-- fs/cifs/connect.c | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 398f596..62b7388 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -94,7 +94,8 @@ enum statusEnum { CifsNew = 0, CifsGood, CifsExiting, - CifsNeedReconnect + CifsNeedReconnect, + CifsNeedNegotiate }; enum securityEnum { diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 3c72e66..fc1dafd 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -142,9 +142,9 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command) */ while (server->tcpStatus == CifsNeedReconnect) { wait_event_interruptible_timeout(server->response_q, - (server->tcpStatus == CifsGood), 10 * HZ); + (server->tcpStatus != CifsNeedReconnect), 10 * HZ); - /* is TCP session is reestablished now ?*/ + /* are we still trying to reconnect? */ if (server->tcpStatus != CifsNeedReconnect) break; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 4066e3e..32347ff 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -203,8 +203,7 @@ cifs_reconnect(struct TCP_Server_Info *server) } spin_unlock(&GlobalMid_Lock); - while ((server->tcpStatus != CifsExiting) && - (server->tcpStatus != CifsGood)) { + while (server->tcpStatus == CifsNeedReconnect) { try_to_freeze(); /* we should try only the port we connected to before */ @@ -216,7 +215,7 @@ cifs_reconnect(struct TCP_Server_Info *server) atomic_inc(&tcpSesReconnectCount); spin_lock(&GlobalMid_Lock); if (server->tcpStatus != CifsExiting) - server->tcpStatus = CifsGood; + server->tcpStatus = CifsNeedNegotiate; spin_unlock(&GlobalMid_Lock); } } @@ -425,7 +424,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) pdu_length = 4; /* enough to get RFC1001 header */ incomplete_rcv: - if (echo_retries > 0 && + if (echo_retries > 0 && server->tcpStatus == CifsGood && time_after(jiffies, server->lstrp + (echo_retries * SMB_ECHO_INTERVAL))) { cERROR(1, "Server %s has not responded in %d seconds. " @@ -1781,6 +1780,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) cERROR(1, "Error connecting to socket. Aborting operation"); goto out_err_crypto_release; } + tcp_ses->tcpStatus = CifsNeedNegotiate; #ifdef CONFIG_CIFS_SMB2 if (volume_info->use_smb2)