Skip to content

Commit

Permalink
cifs: check for unresponsive server every time we call kernel_recvmsg
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff Layton authored and Steve French committed Oct 13, 2011
1 parent e831e6c commit ba749e6
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ba749e6

Please sign in to comment.