From patchwork Fri Dec 17 15:08:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 416101 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 oBHF8NET000693 for ; Fri, 17 Dec 2010 15:08:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755214Ab0LQPIj (ORCPT ); Fri, 17 Dec 2010 10:08:39 -0500 Received: from mail-yw0-f46.google.com ([209.85.213.46]:57817 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755134Ab0LQPIj (ORCPT ); Fri, 17 Dec 2010 10:08:39 -0500 Received: by mail-yw0-f46.google.com with SMTP id 5so354408ywl.19 for ; Fri, 17 Dec 2010 07:08:39 -0800 (PST) Received: by 10.147.170.19 with SMTP id x19mr1767330yao.3.1292598519244; Fri, 17 Dec 2010 07:08:39 -0800 (PST) Received: from salusa.poochiereds.net (cpe-071-070-153-003.nc.res.rr.com [71.70.153.3]) by mx.google.com with ESMTPS id 2sm4330382anw.38.2010.12.17.07.08.38 (version=SSLv3 cipher=RC4-MD5); Fri, 17 Dec 2010 07:08:38 -0800 (PST) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH 15/18] cifs: reconnect unresponsive servers Date: Fri, 17 Dec 2010 10:08:14 -0500 Message-Id: <1292598497-29796-16-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.3.3 In-Reply-To: <1292598497-29796-1-git-send-email-jlayton@redhat.com> References: <1292598497-29796-1-git-send-email-jlayton@redhat.com> 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.3 (demeter1.kernel.org [140.211.167.41]); Fri, 17 Dec 2010 15:08:45 +0000 (UTC) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 20f6eda..2ad3c67 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -55,6 +55,9 @@ /* SMB echo "timeout" -- FIXME: tunable? */ #define SMB_ECHO_INTERVAL (60 * HZ) +/* reconnect if no response from server in this time period */ +#define UNRESPONSIVE_SERVER_TIMEOUT (5 * SMB_ECHO_INTERVAL) + extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24); @@ -186,6 +189,7 @@ cifs_reconnect(struct TCP_Server_Info *server) kfree(server->session_key.response); server->session_key.response = NULL; server->session_key.len = 0; + server->lstrp = jiffies; mutex_unlock(&server->srv_mutex); /* @@ -423,7 +427,19 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) smb_msg.msg_control = NULL; smb_msg.msg_controllen = 0; pdu_length = 4; /* enough to get RFC1001 header */ + incomplete_rcv: + if (time_after(jiffies, + server->lstrp + UNRESPONSIVE_SERVER_TIMEOUT)) { + cERROR(1, "Server %s has not responded in %d seconds. " + "Reconnecting...", server->hostname, + UNRESPONSIVE_SERVER_TIMEOUT / HZ); + cifs_reconnect(server); + csocket = server->ssocket; + wake_up(&server->response_q); + continue; + } + length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, pdu_length, 0 /* BB other flags? */); @@ -584,6 +600,8 @@ incomplete_rcv: } mid_entry = NULL; + server->lstrp = jiffies; + spin_lock(&GlobalMid_Lock); list_for_each_safe(tmp, tmp2, &server->pending_mid_q) { mid_entry = list_entry(tmp, struct mid_q_entry, qhead); @@ -632,10 +650,6 @@ multi_t2_fnd: #ifdef CONFIG_CIFS_STATS2 mid_entry->when_received = jiffies; #endif - /* so we do not time out requests to server - which is still responding (since server could - be busy but not dead) */ - server->lstrp = jiffies; break; } mid_entry = NULL; @@ -1685,6 +1699,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) volume_info->target_rfc1001_name, RFC1001_NAME_LEN_WITH_NULL); tcp_ses->session_estab = false; tcp_ses->sequence_number = 0; + tcp_ses->lstrp = jiffies; INIT_LIST_HEAD(&tcp_ses->tcp_ses_list); INIT_LIST_HEAD(&tcp_ses->smb_ses_list); INIT_DELAYED_WORK(&tcp_ses->echo, cifs_echo_request);