Skip to contentSkip to conversation

Call echo service immediately after socket reconnect

PATCH Superseded Sachin Prabhu 2 participants 3 messages Oct 20, 2016 2 messages not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Call echo service immediately after socket reconnect

Commit 4fcd1813e640 ("Fix reconnect to not defer smb3 session reconnect long after socket reconnect") changes the behaviour of the SMB2 echo service and causes it to renegotiate after a socket reconnect. However under default settings, the echo service could take up to 120 seconds to be scheduled.

The patch forces the echo service to be called immediately resulting a negotiate call being made immediately on reconnect.

---
 fs/cifs/connect.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
fs/cifs/connect.c +17 -6
index aab5227..43fd838 100644
@@ -412,6 +412,9 @@ cifs_reconnect(struct TCP_Server_Info *server)
 		}
 	} while (server->tcpStatus == CifsNeedReconnect);
 
+	if (server->tcpStatus == CifsNeedNegotiate)
+		mod_delayed_work(cifsiod_wq, &server->echo, 0);
+
 	return rc;
 }
 
@@ -421,17 +424,25 @@ cifs_echo_request(struct work_struct *work)
 	int rc;
 	struct TCP_Server_Info *server = container_of(work,
 					struct TCP_Server_Info, echo.work);
-	unsigned long echo_interval = server->echo_interval;
+	unsigned long echo_interval;
+
+	/*
+	 * If we need to renegotiate, set echo interval to zero to
+	 * immediately call echo service where we can renegotiate.
+	 */
+	if (server->tcpStatus == CifsNeedNegotiate)
+		echo_interval = 0;
+	else
+		echo_interval = server->echo_interval;
 
 	/*
-	 * We cannot send an echo if it is disabled or until the
-	 * NEGOTIATE_PROTOCOL request is done, which is indicated by
-	 * server->ops->need_neg() == true. Also, no need to ping if
-	 * we got a response recently.
+	 * We cannot send an echo if it is disabled.
+	 * Also, no need to ping if we got a response recently.
 	 */
 
 	if (server->tcpStatus == CifsNeedReconnect ||
-	    server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew ||
+	    server->tcpStatus == CifsExiting ||
+	    server->tcpStatus == CifsNew ||
 	    (server->ops->can_echo && !server->ops->can_echo(server)) ||
 	    time_before(jiffies, server->lstrp + echo_interval - HZ))
 		goto requeue_echo;
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): 1476969267-22325-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

2016-10-20 6:14 GMT-07:00 Sachin Prabhu <[email protected]>:

Quoted 8 lines

Commit 4fcd1813e640 ("Fix reconnect to not defer smb3 session reconnect long after socket reconnect") changes the behaviour of the SMB2 echo service and causes it to renegotiate after a socket reconnect. However under default settings, the echo service could take up to 120 seconds to be scheduled.

The patch forces the echo service to be called immediately resulting a negotiate call being made immediately on reconnect.

Looks like a right thing to do. Comments are inlined below:

Quoted 23 lines
---
 fs/cifs/connect.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
fs/cifs/connect.c +3 -0
index aab5227..43fd838 100644
@@ -412,6 +412,9 @@ cifs_reconnect(struct TCP_Server_Info *server)
                }
        } while (server->tcpStatus == CifsNeedReconnect);
 
+       if (server->tcpStatus == CifsNeedNegotiate)
+               mod_delayed_work(cifsiod_wq, &server->echo, 0);
+
        return rc;
 }
 
@@ -421,17 +424,25 @@ cifs_echo_request(struct work_struct *work)
        int rc;
        struct TCP_Server_Info *server = container_of(work,

fs/cifs/connect.c cifs_echo_request(struct work_struct *work) · line 434

Quoted 10 lines
fs/cifs/connect.c +8 -1
                                        struct TCP_Server_Info, echo.work);
-       unsigned long echo_interval = server->echo_interval;
+       unsigned long echo_interval;
+
+       /*
+        * If we need to renegotiate, set echo interval to zero to
+        * immediately call echo service where we can renegotiate.
+        */
+       if (server->tcpStatus == CifsNeedNegotiate)
+               echo_interval = 0;

Suppose we are setting echo_interval to 0 above

Quoted 9 lines
fs/cifs/connect.c +3 -4
+       else
+               echo_interval = server->echo_interval;
 
        /*
-        * We cannot send an echo if it is disabled or until the
-        * NEGOTIATE_PROTOCOL request is done, which is indicated by
-        * server->ops->need_neg() == true. Also, no need to ping if
-        * we got a response recently.
+        * We cannot send an echo if it is disabled.

fs/cifs/connect.c cifs_echo_request(struct work_struct *work) · line 448

Quoted 10 lines
fs/cifs/connect.c +3 -1
+        * Also, no need to ping if we got a response recently.
         */
 
        if (server->tcpStatus == CifsNeedReconnect ||
-           server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew ||
+           server->tcpStatus == CifsExiting ||
+           server->tcpStatus == CifsNew ||
            (server->ops->can_echo && !server->ops->can_echo(server)) ||
            time_before(jiffies, server->lstrp + echo_interval - HZ))
                goto requeue_echo;

then we are sending an echo message and re-queue the echo work with echo_interval==0:

rc = server->ops->echo ? server->ops->echo(server) : -ENOSYS;
....
queue_delayed_work(cifsiod_wq, &server->echo, echo_interval);

Shouldn't we queue the echo work with server->echo_interval (not 0) here?

Signature · 2 lines
Best regards,
Pavel Shilovsky

A message that is not in the archive (sent off-list or not yet received): CAKywueQ=L5MunfYLGJ6NqBUq5fLbLuM5A7f93Kym+u7sqdm0OQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 27 lines · Pavel Shilovsky

2016-10-20 6:14 GMT-07:00 Sachin Prabhu <[email protected]>:

Quoted 11 lines

Commit 4fcd1813e640 ("Fix reconnect to not defer smb3 session reconnect
long after socket reconnect") changes the behaviour of the SMB2 echo
service and causes it to renegotiate after a socket reconnect. However
under default settings, the echo service could take up to 120 seconds to
be scheduled.

Quoted 3 lines

The patch forces the echo service to be called immediately resulting a
negotiate call being made immediately on reconnect.

Looks like a right thing to do. Comments are inlined below:

Quoted 4 lines


..
+       if (server->tcpStatus == CifsNeedNegotiate) +               echo_interval = 0;

Suppose we are setting echo_interval to 0 above

Quoted 2 lines

..

Quoted 10 lines

then we are sending an echo message and re-queue the echo work with echo_interval==0:

rc = server->ops->echo ? server->ops->echo(server) : -ENOSYS;
....
queue_delayed_work(cifsiod_wq, &server->echo, echo_interval);

Shouldn't we queue the echo work with server->echo_interval (not 0) here?

Hello Pavel,

Yes, you are right. I had overlooked the second echo_interval in the function. I've sent a version 2 of the patch.

Sachin Prabhu