From d1a3ae1cf4bf3261f6c131af6626b1866638511d Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Fri, 14 Jan 2011 13:54:39 -0500 Subject: [PATCH] cifs: set socket send and receive timeouts before attempting connect Benjamin S. reported that he was unable to suspend his machine while it had a cifs share mounted. The freezer caused this to spew when he tried it: -----------------------[snip]------------------ [347809.421490] PM: Syncing filesystems ... done. [347809.647465] Freezing user space processes ... (elapsed 0.01 seconds) done. [347809.663090] Freezing remaining freezable tasks ... [347829.678854] Freezing of tasks failed after 20.01 seconds (1 tasks refusing to freeze, wq_busy=0): [347829.678873] cifsd S ffff880127f7b1b0 0 1821 2 0x00800000 [347829.678883] ffff880127f7b1b0 0000000000000046 ffff88005fe008a8 ffff8800ffffffff [347829.678890] ffff880127cee6b0 0000000000011100 ffff880127737fd8 0000000000004000 [347829.678897] ffff880127737fd8 0000000000011100 ffff880127f7b1b0 ffff880127736010 [347829.678904] Call Trace: [347829.678915] [] ? sk_reset_timer+0xf/0x19 [347829.678921] [] ? tcp_connect+0x43c/0x445 [347829.678928] [] ? tcp_v4_connect+0x40d/0x47f [347829.678935] [] ? schedule_timeout+0x21/0x1ad [347829.678942] [] ? _raw_spin_lock_bh+0x9/0x1f [347829.678947] [] ? release_sock+0x19/0xef [347829.678953] [] ? inet_stream_connect+0x14c/0x24a [347829.678961] [] ? autoremove_wake_function+0x0/0x2a [347829.678986] [] ? ipv4_connect+0x39c/0x3b5 [cifs] [347829.678991] [] ? cifs_reconnect+0x1fc/0x28a [cifs] [347829.678999] [] ? cifs_demultiplex_thread+0x397/0xb9f [cifs] [347829.679003] [] ? perf_event_exit_task+0xb9/0x1bf [347829.679007] [] ? cifs_demultiplex_thread+0x0/0xb9f [cifs] [347829.679012] [] ? cifs_demultiplex_thread+0x0/0xb9f [cifs] [347829.679014] [] ? kthread+0x7a/0x82 [347829.679018] [] ? kernel_thread_helper+0x4/0x10 [347829.679020] [] ? kthread+0x0/0x82 [347829.679022] [] ? kernel_thread_helper+0x0/0x10 [347829.679036] [347829.679037] Restarting tasks ... done. -----------------------[snip]------------------ We do attempt to perform a try_to_freeze in cifs_reconnect, but the connection attempt itself seems to be taking longer than 20s to time out. The connect timeout is governed by the socket send and receive timeouts, so we can shorten that period by setting those timeouts before attempting the connect instead of after. Thanks to Neil Horman for pointing out the problem... Reported-by: Benjamin S Signed-off-by: Jeff Layton --- fs/cifs/connect.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 99a5f18..32c2f55 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2290,14 +2290,6 @@ generic_ip_connect(struct TCP_Server_Info *server) if (rc < 0) return rc; - rc = socket->ops->connect(socket, saddr, slen, 0); - if (rc < 0) { - cFYI(1, "Error %d connecting to server", rc); - sock_release(socket); - server->ssocket = NULL; - return rc; - } - /* * Eventually check for other socket options to change from * the default. sock_setsockopt not used because it expects @@ -2326,6 +2318,14 @@ generic_ip_connect(struct TCP_Server_Info *server) socket->sk->sk_sndbuf, socket->sk->sk_rcvbuf, socket->sk->sk_rcvtimeo); + rc = socket->ops->connect(socket, saddr, slen, 0); + if (rc < 0) { + cFYI(1, "Error %d connecting to server", rc); + sock_release(socket); + server->ssocket = NULL; + return rc; + } + if (sport == htons(RFC1001_PORT)) rc = ip_rfc1001_connect(server); -- 1.7.3.4