[linux-cifs-client] [PATCH 7/7] cifs: don't retry on blocking sends

Jeff Layton jlayton at redhat.com
Sun Nov 30 18:40:36 GMT 2008


smb_send2 will attempt to send a message and retry if it doesn't work.
It's rather pointless to do this in the case of blocking sends. We can
just set the socket sndtimeo to a reasonable value and try the send
once.

Why change the timeout to 30s? That seems like a reasonable amount of
time to wait for the send. It's also what sunrpc uses for sndtimeo
with TCP sockets. At some point we might consider making this
tunable, but a generic "timeo" setting similar to what NFS has is
probably more user friendly.

Signed-off-by: Jeff Layton <jlayton at redhat.com>
---
 fs/cifs/connect.c   |    4 ++--
 fs/cifs/transport.c |   12 ++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 8131465..17c4410 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1791,7 +1791,7 @@ ipv4_connect(struct TCP_Server_Info *server)
 	 *  user space buffer
 	 */
 	socket->sk->sk_rcvtimeo = 7 * HZ;
-	socket->sk->sk_sndtimeo = 3 * HZ;
+	socket->sk->sk_sndtimeo = 30 * HZ;
 
 	/* make the bufsizes depend on wsize/rsize and max requests */
 	if (server->noautotune) {
@@ -1942,7 +1942,7 @@ ipv6_connect(struct TCP_Server_Info *server)
 	 * user space buffer
 	 */
 	socket->sk->sk_rcvtimeo = 7 * HZ;
-	socket->sk->sk_sndtimeo = 3 * HZ;
+	socket->sk->sk_sndtimeo = 30 * HZ;
 	server->ssocket = socket;
 
 	return rc;
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 25a4039..6e275b4 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -197,6 +197,18 @@ smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
 	while (total_len) {
 		rc = kernel_sendmsg(ssocket, &smb_msg, &iov[first_vec],
 				    n_vec - first_vec, total_len);
+
+		/*
+		 * blocking send -- just update total_len and break out of
+		 * the loop. No sense in retrying since we've already given
+		 * it a long timeout.
+		 */
+		if (!server->noblocksnd) {
+			if (rc >= 0)
+				total_len -= rc;
+			break;
+		}
+
 		if ((rc == -ENOSPC) || (rc == -EAGAIN)) {
 			i++;
 			if (i >= 14) {
-- 
1.5.5.1



More information about the linux-cifs-client mailing list