Skip to content

Commit 2ba464a

Browse files
spuiukgregkh
authored andcommitted
Call echo service immediately after socket reconnect
commit b8c600120fc87d53642476f48c8055b38d6e14c7 upstream. 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. Signed-off-by: Sachin Prabhu <sprabhu@redhat.com> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com> Signed-off-by: Steve French <smfrench@gmail.com> Acked-by: Sachin Prabhu <sprabhu@redhat.com> Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 691fe56 commit 2ba464a

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

fs/cifs/connect.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ cifs_reconnect(struct TCP_Server_Info *server)
412412
}
413413
} while (server->tcpStatus == CifsNeedReconnect);
414414

415+
if (server->tcpStatus == CifsNeedNegotiate)
416+
mod_delayed_work(cifsiod_wq, &server->echo, 0);
417+
415418
return rc;
416419
}
417420

@@ -421,18 +424,27 @@ cifs_echo_request(struct work_struct *work)
421424
int rc;
422425
struct TCP_Server_Info *server = container_of(work,
423426
struct TCP_Server_Info, echo.work);
427+
unsigned long echo_interval;
428+
429+
/*
430+
* If we need to renegotiate, set echo interval to zero to
431+
* immediately call echo service where we can renegotiate.
432+
*/
433+
if (server->tcpStatus == CifsNeedNegotiate)
434+
echo_interval = 0;
435+
else
436+
echo_interval = SMB_ECHO_INTERVAL;
424437

425438
/*
426-
* We cannot send an echo if it is disabled or until the
427-
* NEGOTIATE_PROTOCOL request is done, which is indicated by
428-
* server->ops->need_neg() == true. Also, no need to ping if
429-
* we got a response recently.
439+
* We cannot send an echo if it is disabled.
440+
* Also, no need to ping if we got a response recently.
430441
*/
431442

432443
if (server->tcpStatus == CifsNeedReconnect ||
433-
server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew ||
444+
server->tcpStatus == CifsExiting ||
445+
server->tcpStatus == CifsNew ||
434446
(server->ops->can_echo && !server->ops->can_echo(server)) ||
435-
time_before(jiffies, server->lstrp + SMB_ECHO_INTERVAL - HZ))
447+
time_before(jiffies, server->lstrp + echo_interval - HZ))
436448
goto requeue_echo;
437449

438450
rc = server->ops->echo ? server->ops->echo(server) : -ENOSYS;

0 commit comments

Comments
 (0)