aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2011-10-11 06:41:32 -0400
committerSteve French <smfrench@gmail.com>2011-10-13 00:41:59 -0400
commitba749e6d5227de22e442c6088cc7dc1f0c5c68bf (patch)
treefef72676f66e01ae22e61a27d7e70345ca9e539e /fs
parente831e6cf3acb058d898411367a582deef80e32f8 (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/connect.c33
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,
358 return true; 358 return true;
359} 359}
360 360
361static bool
362server_unresponsive(struct TCP_Server_Info *server)
363{
364 if (echo_retries > 0 && server->tcpStatus == CifsGood &&
365 time_after(jiffies, server->lstrp +
366 (echo_retries * SMB_ECHO_INTERVAL))) {
367 cERROR(1, "Server %s has not responded in %d seconds. "
368 "Reconnecting...", server->hostname,
369 (echo_retries * SMB_ECHO_INTERVAL / HZ));
370 cifs_reconnect(server);
371 wake_up(&server->response_q);
372 return true;
373 }
374
375 return false;
376}
377
361static int 378static int
362read_from_socket(struct TCP_Server_Info *server, 379read_from_socket(struct TCP_Server_Info *server,
363 struct kvec *iov, unsigned int to_read, 380 struct kvec *iov, unsigned int to_read,
@@ -372,6 +389,11 @@ read_from_socket(struct TCP_Server_Info *server,
372 smb_msg.msg_controllen = 0; 389 smb_msg.msg_controllen = 0;
373 390
374 for (total_read = 0; total_read < to_read; total_read += length) { 391 for (total_read = 0; total_read < to_read; total_read += length) {
392 if (server_unresponsive(server)) {
393 rc = 1;
394 break;
395 }
396
375 length = kernel_recvmsg(server->ssocket, &smb_msg, iov, 1, 397 length = kernel_recvmsg(server->ssocket, &smb_msg, iov, 1,
376 to_read - total_read, 0); 398 to_read - total_read, 0);
377 if (server->tcpStatus == CifsExiting) { 399 if (server->tcpStatus == CifsExiting) {
@@ -669,17 +691,6 @@ cifs_demultiplex_thread(void *p)
669 pdu_length = 4; /* enough to get RFC1001 header */ 691 pdu_length = 4; /* enough to get RFC1001 header */
670 692
671incomplete_rcv: 693incomplete_rcv:
672 if (echo_retries > 0 && server->tcpStatus == CifsGood &&
673 time_after(jiffies, server->lstrp +
674 (echo_retries * SMB_ECHO_INTERVAL))) {
675 cERROR(1, "Server %s has not responded in %d seconds. "
676 "Reconnecting...", server->hostname,
677 (echo_retries * SMB_ECHO_INTERVAL / HZ));
678 cifs_reconnect(server);
679 wake_up(&server->response_q);
680 continue;
681 }
682
683 rc = read_from_socket(server, &iov, pdu_length, 694 rc = read_from_socket(server, &iov, pdu_length,
684 &total_read, true /* header read */); 695 &total_read, true /* header read */);
685 if (rc == 3) 696 if (rc == 3)