diff options
author | Jeff Layton <jlayton@redhat.com> | 2011-10-11 06:41:32 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2011-10-12 23:41:59 -0500 |
commit | ba749e6d5227de22e442c6088cc7dc1f0c5c68bf (patch) | |
tree | fef72676f66e01ae22e61a27d7e70345ca9e539e | |
parent | e831e6cf3acb058d898411367a582deef80e32f8 (diff) | |
download | linux-ba749e6d5227de22e442c6088cc7dc1f0c5c68bf.tar.gz linux-ba749e6d5227de22e442c6088cc7dc1f0c5c68bf.tar.bz2 linux-ba749e6d5227de22e442c6088cc7dc1f0c5c68bf.zip |
cifs: check for unresponsive server every time we call kernel_recvmsg
If the server stops sending data while in the middle of sending a
response then we still want to reconnect it if it doesn't come back.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
-rw-r--r-- | fs/cifs/connect.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index ed969fd5f7cc..abbc6c3fe3f1 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -358,6 +358,23 @@ allocate_buffers(char **bigbuf, char **smallbuf, unsigned int size, return true; } +static bool +server_unresponsive(struct TCP_Server_Info *server) +{ + 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. " + "Reconnecting...", server->hostname, + (echo_retries * SMB_ECHO_INTERVAL / HZ)); + cifs_reconnect(server); + wake_up(&server->response_q); + return true; + } + + return false; +} + static int read_from_socket(struct TCP_Server_Info *server, struct kvec *iov, unsigned int to_read, @@ -372,6 +389,11 @@ read_from_socket(struct TCP_Server_Info *server, smb_msg.msg_controllen = 0; for (total_read = 0; total_read < to_read; total_read += length) { + if (server_unresponsive(server)) { + rc = 1; + break; + } + length = kernel_recvmsg(server->ssocket, &smb_msg, iov, 1, to_read - total_read, 0); if (server->tcpStatus == CifsExiting) { @@ -669,17 +691,6 @@ cifs_demultiplex_thread(void *p) pdu_length = 4; /* enough to get RFC1001 header */ incomplete_rcv: - 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. " - "Reconnecting...", server->hostname, - (echo_retries * SMB_ECHO_INTERVAL / HZ)); - cifs_reconnect(server); - wake_up(&server->response_q); - continue; - } - rc = read_from_socket(server, &iov, pdu_length, &total_read, true /* header read */); if (rc == 3) |