All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 12/13] cifs: reconnect unresponsive servers
Date: Fri, 10 Dec 2010 10:44:36 -0500	[thread overview]
Message-ID: <1291995877-2276-13-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1291995877-2276-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

If the server isn't responding to echoes, we don't want to leave tasks
hung waiting for it to reply. At that point, we'll want to reconnect
so that soft mounts can return an error to userspace quickly.

If the client hasn't received a reply after 3 echo intervals, assume
that the transport is down and attempt to reconnect the socket.

Signed-off-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 fs/cifs/connect.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 98e1d38..c596515 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -55,6 +55,9 @@
 /* SMB echo "timeout" -- FIXME: tunable? */
 #define SMB_ECHO_INTERVAL (30 * HZ)
 
+/* reconnect if no response from server in this time period */
+#define UNRESPONSIVE_SERVER_TIMEOUT (3 * SMB_ECHO_INTERVAL)
+
 extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
 			 unsigned char *p24);
 
@@ -187,6 +190,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);
 
 	/*
@@ -442,7 +446,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? */);
@@ -603,6 +619,8 @@ incomplete_rcv:
 		}
 
 		mid_entry = NULL;
+		server->lstrp = jiffies;
+
 		spin_lock(&GlobalMid_Lock);
 		list_for_each(tmp, &server->pending_mid_q) {
 			mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
@@ -653,10 +671,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;
 			}
 next_mid:
@@ -1724,6 +1738,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);
-- 
1.7.3.2

  parent reply	other threads:[~2010-12-10 15:44 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-10 15:44 [PATCH 00/14] cifs: overhaul request timeout behavior in CIFS (try #2) Jeff Layton
     [not found] ` <1291995877-2276-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-10 15:44   ` [PATCH 01/13] cifs: don't fail writepages on -EAGAIN errors Jeff Layton
     [not found]     ` <1291995877-2276-2-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-10 22:14       ` [PATCH 00/13] cifs: don't fail writepages on -EAGAIN errors (try #2) Jeff Layton
     [not found]         ` <1292019275-7248-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-13 20:17           ` Pavel Shilovsky
2010-12-13 20:01       ` [PATCH 01/13] cifs: don't fail writepages on -EAGAIN errors Pavel Shilovsky
     [not found]         ` <AANLkTinzyPMq79aXmzARLpm1+X_GZho38AYR=zuyXKCi-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-13 20:05           ` Jeff Layton
     [not found]             ` <20101213150556.7f0cf2f1-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-12-13 20:10               ` Pavel Shilovsky
2010-12-14  9:26       ` Suresh Jayaraman
     [not found]         ` <4D07383A.6000400-l3A5Bk7waGM@public.gmane.org>
2010-12-14 12:18           ` Jeff Layton
     [not found]             ` <20101214071820.2aa4936b-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-12-16 16:35               ` Steve French
     [not found]                 ` <AANLkTi=soXxgZMXoWrbx2_eJtGQR5iHncXtDO_dbWRX7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-16 17:08                   ` Jeff Layton
2010-12-10 15:44   ` [PATCH 02/13] cifs: make wait_for_free_request take a TCP_Server_Info pointer Jeff Layton
     [not found]     ` <1291995877-2276-3-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-13 20:03       ` Pavel Shilovsky
2010-12-10 15:44   ` [PATCH 03/13] cifs: move mid result processing into common function Jeff Layton
     [not found]     ` <1291995877-2276-4-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-12 23:29       ` Shirish Pargaonkar
     [not found]         ` <AANLkTimGiESxGU4qnQ2fX+xTJw94BR5PspMp981VKKe--JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-13  0:17           ` Jeff Layton
2010-12-14  7:34       ` Pavel Shilovsky
2010-12-10 15:44   ` [PATCH 04/13] cifs: wait indefinitely for responses Jeff Layton
     [not found]     ` <1291995877-2276-5-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-13 20:04       ` Pavel Shilovsky
2010-12-10 15:44   ` [PATCH 05/13] cifs: don't reconnect server when we don't get a response Jeff Layton
     [not found]     ` <1291995877-2276-6-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-13 20:06       ` Pavel Shilovsky
2010-12-10 15:44   ` [PATCH 06/13] cifs: clean up handle_mid_response Jeff Layton
     [not found]     ` <1291995877-2276-7-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-12 23:52       ` Shirish Pargaonkar
     [not found]         ` <AANLkTi=j8j=OxUxJcwn4h6EqvHSH2vrhQkzRxYjAerzi-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-13  0:21           ` Jeff Layton
     [not found]             ` <20101212192152.0c75c5ce-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2010-12-14  7:33               ` Pavel Shilovsky
2010-12-10 15:44   ` [PATCH 07/13] cifs: allow for different handling of received response Jeff Layton
     [not found]     ` <1291995877-2276-8-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-13 20:21       ` Pavel Shilovsky
2010-12-10 15:44   ` [PATCH 08/13] cifs: handle cancelled requests better Jeff Layton
     [not found]     ` <1291995877-2276-9-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-14  7:24       ` Pavel Shilovsky
     [not found]         ` <AANLkTinU19tUL-6uwYN64dfE1Rsa+uSiC2fkeBHV+XOS-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-14 11:59           ` Jeff Layton
     [not found]             ` <20101214065935.50a0bdf0-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-12-14 20:40               ` Pavel Shilovsky
     [not found]                 ` <AANLkTi=mFXsJd55CzebrKO24ALnwmduBnFLyYZCRVdP4-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-14 21:33                   ` Steve French
     [not found]                     ` <AANLkTinSC4WKa4ZBeEOWkSQmy6wBhU8=cO09EKy2Qda2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-14 21:44                       ` Jeff Layton
     [not found]                         ` <20101214164407.377304e0-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-12-14 22:22                           ` Steve French
     [not found]                             ` <AANLkTimFQSeMk8ZCbAud+RdU5WQcGrDnKz+dAC_UFzNM-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-14 23:18                               ` Jeff Layton
     [not found]                                 ` <20101214181829.0075c6c6-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-12-15  4:05                                   ` Steve French
2010-12-15 11:37                                     ` Jeff Layton
2010-12-10 15:44   ` [PATCH 09/13] cifs: add cifs_call_async Jeff Layton
     [not found]     ` <1291995877-2276-10-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-14  6:52       ` Pavel Shilovsky
2010-12-10 15:44   ` [PATCH 10/13] cifs: add ability to send an echo request Jeff Layton
     [not found]     ` <1291995877-2276-11-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-14  7:15       ` Pavel Shilovsky
2010-12-10 15:44   ` [PATCH 11/13] cifs: set up recurring workqueue job to do SMB echo requests Jeff Layton
     [not found]     ` <1291995877-2276-12-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-14  6:57       ` Pavel Shilovsky
2010-12-10 15:44   ` Jeff Layton [this message]
     [not found]     ` <1291995877-2276-13-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-14  6:57       ` [PATCH 12/13] cifs: reconnect unresponsive servers Pavel Shilovsky
2010-12-10 15:44   ` [PATCH 13/13] cifs: remove code for setting timeouts on requests Jeff Layton
     [not found]     ` <1291995877-2276-14-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-12-14  7:25       ` Pavel Shilovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291995877-2276-13-git-send-email-jlayton@redhat.com \
    --to=jlayton-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.