* [PATCH v2] Call echo service immediately after socket reconnect
@ 2016-10-20 23:52 Sachin Prabhu
[not found] ` <1477007544-4656-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Sachin Prabhu @ 2016-10-20 23:52 UTC (permalink / raw)
To: linux-cifs, Pavel Shilovskiy
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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
fs/cifs/connect.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index aab5227..4547aed 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -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;
@@ -442,7 +453,7 @@ cifs_echo_request(struct work_struct *work)
server->hostname);
requeue_echo:
- queue_delayed_work(cifsiod_wq, &server->echo, echo_interval);
+ queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval);
}
static bool
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread[parent not found: <1477007544-4656-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH v2] Call echo service immediately after socket reconnect [not found] ` <1477007544-4656-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2016-10-21 1:33 ` Pavel Shilovsky [not found] ` <CAKywueST_Rk3J-L0nMTfZmxhjMa2xdorqT7=Rx5VS0_0wLtx-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2017-04-15 15:38 ` [v2] " Jonathan Liu 1 sibling, 1 reply; 6+ messages in thread From: Pavel Shilovsky @ 2016-10-21 1:33 UTC (permalink / raw) To: Sachin Prabhu; +Cc: linux-cifs, Pavel Shilovskiy 2016-10-20 16:52 GMT-07:00 Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > fs/cifs/connect.c | 25 ++++++++++++++++++------- > 1 file changed, 18 insertions(+), 7 deletions(-) > > diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c > index aab5227..4547aed 100644 > --- a/fs/cifs/connect.c > +++ b/fs/cifs/connect.c > @@ -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; > @@ -442,7 +453,7 @@ cifs_echo_request(struct work_struct *work) > server->hostname); > > requeue_echo: > - queue_delayed_work(cifsiod_wq, &server->echo, echo_interval); > + queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval); > } > > static bool > -- > 2.7.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Pavel Shilovsky <pshilov-0li6OtcxBFHby3iVrkZq2A@public.gmane.org> -- Best regards, Pavel Shilovsky ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAKywueST_Rk3J-L0nMTfZmxhjMa2xdorqT7=Rx5VS0_0wLtx-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH v2] Call echo service immediately after socket reconnect [not found] ` <CAKywueST_Rk3J-L0nMTfZmxhjMa2xdorqT7=Rx5VS0_0wLtx-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2016-10-21 3:40 ` Steve French 0 siblings, 0 replies; 6+ messages in thread From: Steve French @ 2016-10-21 3:40 UTC (permalink / raw) To: Pavel Shilovsky; +Cc: Sachin Prabhu, linux-cifs, Pavel Shilovskiy merged into cifs-2.6.git for-next On Thu, Oct 20, 2016 at 8:33 PM, Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > 2016-10-20 16:52 GMT-07:00 Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: >> 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >> --- >> fs/cifs/connect.c | 25 ++++++++++++++++++------- >> 1 file changed, 18 insertions(+), 7 deletions(-) >> >> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c >> index aab5227..4547aed 100644 >> --- a/fs/cifs/connect.c >> +++ b/fs/cifs/connect.c >> @@ -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; >> @@ -442,7 +453,7 @@ cifs_echo_request(struct work_struct *work) >> server->hostname); >> >> requeue_echo: >> - queue_delayed_work(cifsiod_wq, &server->echo, echo_interval); >> + queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval); >> } >> >> static bool >> -- >> 2.7.4 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in >> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > Reviewed-by: Pavel Shilovsky <pshilov-0li6OtcxBFHby3iVrkZq2A@public.gmane.org> > > -- > Best regards, > Pavel Shilovsky > -- > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Thanks, Steve ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [v2] Call echo service immediately after socket reconnect [not found] ` <1477007544-4656-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2016-10-21 1:33 ` Pavel Shilovsky @ 2017-04-15 15:38 ` Jonathan Liu [not found] ` <CANwerB1NH=D3NKz_A3pxg+aty9U4P66b5Lo3KAqOBTLKDEAkew-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 1 sibling, 1 reply; 6+ messages in thread From: Jonathan Liu @ 2017-04-15 15:38 UTC (permalink / raw) To: Sachin Prabhu; +Cc: linux-cifs, Pavel Shilovskiy Hi Sachin, On 21 October 2016 at 10:52, Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote: > > 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > Reviewed-by: Pavel Shilovsky <pshilov-0li6OtcxBFHby3iVrkZq2A@public.gmane.org> This commit is causing a flood of connections to Samba server as well as high server CPU load when the Samba is restarted while CIFS share is mounted on the client. This can cause the Samba server to become slow or unresponsive resulting in denial of service to other users connected to the Samba server. Bug report: https://bugzilla.kernel.org/show_bug.cgi?id=194531 Could you please have a look? Thanks. Regards, Jonathan ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CANwerB1NH=D3NKz_A3pxg+aty9U4P66b5Lo3KAqOBTLKDEAkew-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [v2] Call echo service immediately after socket reconnect [not found] ` <CANwerB1NH=D3NKz_A3pxg+aty9U4P66b5Lo3KAqOBTLKDEAkew-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2017-04-15 16:06 ` Pavel Shilovsky 2017-04-16 19:43 ` Sachin Prabhu 1 sibling, 0 replies; 6+ messages in thread From: Pavel Shilovsky @ 2017-04-15 16:06 UTC (permalink / raw) To: Jonathan Liu; +Cc: Sachin Prabhu, linux-cifs, Pavel Shilovskiy 2017-04-15 8:38 GMT-07:00 Jonathan Liu <net147-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > Hi Sachin, > > On 21 October 2016 at 10:52, Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote: >> >> 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >> Reviewed-by: Pavel Shilovsky <pshilov-0li6OtcxBFHby3iVrkZq2A@public.gmane.org> > > This commit is causing a flood of connections to Samba server as well > as high server CPU load when the Samba is restarted while CIFS share > is mounted on the client. This can cause the Samba server to become > slow or unresponsive resulting in denial of service to other users > connected to the Samba server. > > Bug report: https://bugzilla.kernel.org/show_bug.cgi?id=194531 > > Could you please have a look? > > Thanks. > > Regards, > Jonathan > -- > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Hi Jonathan, Thanks for reporting this. It seems like we need to make CIFSSMBEcho() call as noop in case of (server->tcpStatus == CifsNeedNegotiate) as we already did for SMB2_echo(). -- Best regards, Pavel Shilovsky ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [v2] Call echo service immediately after socket reconnect [not found] ` <CANwerB1NH=D3NKz_A3pxg+aty9U4P66b5Lo3KAqOBTLKDEAkew-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2017-04-15 16:06 ` Pavel Shilovsky @ 2017-04-16 19:43 ` Sachin Prabhu 1 sibling, 0 replies; 6+ messages in thread From: Sachin Prabhu @ 2017-04-16 19:43 UTC (permalink / raw) To: Jonathan Liu; +Cc: linux-cifs, Pavel Shilovskiy On Sun, 2017-04-16 at 01:38 +1000, Jonathan Liu wrote: > Hi Sachin, > > On 21 October 2016 at 10:52, Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > wrote: > > > > 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > > Reviewed-by: Pavel Shilovsky <pshilov-0li6OtcxBFHby3iVrkZq2A@public.gmane.org> > > This commit is causing a flood of connections to Samba server as well > as high server CPU load when the Samba is restarted while CIFS share > is mounted on the client. This can cause the Samba server to become > slow or unresponsive resulting in denial of service to other users > connected to the Samba server. > > Bug report: https://bugzilla.kernel.org/show_bug.cgi?id=194531 > > Could you please have a look? > > Thanks. > > Regards, > Jonathan Hello Jonathan, Thanks for bringing this to my attention. I've posted a patch to the list. I've tested it out with the reproducer. Can you please test it out in your setup and let me know if it works for you. Sachin Prabhu ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-04-16 19:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-20 23:52 [PATCH v2] Call echo service immediately after socket reconnect Sachin Prabhu
[not found] ` <1477007544-4656-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-21 1:33 ` Pavel Shilovsky
[not found] ` <CAKywueST_Rk3J-L0nMTfZmxhjMa2xdorqT7=Rx5VS0_0wLtx-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-21 3:40 ` Steve French
2017-04-15 15:38 ` [v2] " Jonathan Liu
[not found] ` <CANwerB1NH=D3NKz_A3pxg+aty9U4P66b5Lo3KAqOBTLKDEAkew-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-15 16:06 ` Pavel Shilovsky
2017-04-16 19:43 ` Sachin Prabhu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox