Skip to content

Commit 1a6a41d

Browse files
sprasad-microsoftSteve French
authored and
Steve French
committed
cifs: do not use tcpStatus after negotiate completes
Recent changes to multichannel to allow channel reconnects to work in parallel and independent of each other did so by making use of tcpStatus for the connection, and status for the session. However, this did not take into account the multiuser scenario, where same connection is used by multiple connections. However, tcpStatus should be tracked only till the end of negotiate exchange, and not used for session setup. This change fixes this. Signed-off-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 5283225 commit 1a6a41d

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

fs/cifs/connect.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3973,7 +3973,7 @@ cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses,
39733973
if (rc == 0) {
39743974
spin_lock(&cifs_tcp_ses_lock);
39753975
if (server->tcpStatus == CifsInNegotiate)
3976-
server->tcpStatus = CifsNeedSessSetup;
3976+
server->tcpStatus = CifsGood;
39773977
else
39783978
rc = -EHOSTDOWN;
39793979
spin_unlock(&cifs_tcp_ses_lock);
@@ -3996,19 +3996,18 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
39963996
bool is_binding = false;
39973997

39983998
/* only send once per connect */
3999+
spin_lock(&ses->chan_lock);
4000+
is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT(ses);
4001+
spin_unlock(&ses->chan_lock);
4002+
39994003
spin_lock(&cifs_tcp_ses_lock);
4000-
if ((server->tcpStatus != CifsNeedSessSetup) &&
4001-
(ses->status == CifsGood)) {
4004+
if (ses->status == CifsExiting) {
40024005
spin_unlock(&cifs_tcp_ses_lock);
40034006
return 0;
40044007
}
4005-
server->tcpStatus = CifsInSessSetup;
4008+
ses->status = CifsInSessSetup;
40064009
spin_unlock(&cifs_tcp_ses_lock);
40074010

4008-
spin_lock(&ses->chan_lock);
4009-
is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT(ses);
4010-
spin_unlock(&ses->chan_lock);
4011-
40124011
if (!is_binding) {
40134012
ses->capabilities = server->capabilities;
40144013
if (!linuxExtEnabled)
@@ -4032,13 +4031,13 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
40324031
if (rc) {
40334032
cifs_server_dbg(VFS, "Send error in SessSetup = %d\n", rc);
40344033
spin_lock(&cifs_tcp_ses_lock);
4035-
if (server->tcpStatus == CifsInSessSetup)
4036-
server->tcpStatus = CifsNeedSessSetup;
4034+
if (ses->status == CifsInSessSetup)
4035+
ses->status = CifsNeedSessSetup;
40374036
spin_unlock(&cifs_tcp_ses_lock);
40384037
} else {
40394038
spin_lock(&cifs_tcp_ses_lock);
4040-
if (server->tcpStatus == CifsInSessSetup)
4041-
server->tcpStatus = CifsGood;
4039+
if (ses->status == CifsInSessSetup)
4040+
ses->status = CifsGood;
40424041
/* Even if one channel is active, session is in good state */
40434042
ses->status = CifsGood;
40444043
spin_unlock(&cifs_tcp_ses_lock);

fs/cifs/smb2pdu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3899,7 +3899,8 @@ SMB2_echo(struct TCP_Server_Info *server)
38993899
cifs_dbg(FYI, "In echo request for conn_id %lld\n", server->conn_id);
39003900

39013901
spin_lock(&cifs_tcp_ses_lock);
3902-
if (server->tcpStatus == CifsNeedNegotiate) {
3902+
if (server->ops->need_neg &&
3903+
server->ops->need_neg(server)) {
39033904
spin_unlock(&cifs_tcp_ses_lock);
39043905
/* No need to send echo on newly established connections */
39053906
mod_delayed_work(cifsiod_wq, &server->reconnect, 0);

fs/cifs/smb2transport.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,8 @@ smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server)
641641
if (!is_signed)
642642
return 0;
643643
spin_lock(&cifs_tcp_ses_lock);
644-
if (server->tcpStatus == CifsNeedNegotiate) {
644+
if (server->ops->need_neg &&
645+
server->ops->need_neg(server)) {
645646
spin_unlock(&cifs_tcp_ses_lock);
646647
return 0;
647648
}

0 commit comments

Comments
 (0)