@@ -181,17 +181,16 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
181
181
server -> maxBuf = 0 ;
182
182
server -> max_read = 0 ;
183
183
184
- cifs_dbg (FYI , "Mark tcp session as need reconnect\n" );
185
- trace_smb3_reconnect (server -> CurrentMid , server -> conn_id , server -> hostname );
186
184
/*
187
185
* before reconnecting the tcp session, mark the smb session (uid) and the tid bad so they
188
186
* are not used until reconnected.
189
187
*/
190
- cifs_dbg (FYI , "%s: marking sessions and tcons for reconnect\n" , __func__ );
188
+ cifs_dbg (FYI , "%s: marking necessary sessions and tcons for reconnect\n" , __func__ );
191
189
192
190
/* If server is a channel, select the primary channel */
193
191
pserver = CIFS_SERVER_IS_CHAN (server ) ? server -> primary_server : server ;
194
192
193
+
195
194
spin_lock (& cifs_tcp_ses_lock );
196
195
list_for_each_entry (ses , & pserver -> smb_ses_list , smb_ses_list ) {
197
196
spin_lock (& ses -> chan_lock );
@@ -218,13 +217,8 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
218
217
}
219
218
spin_unlock (& cifs_tcp_ses_lock );
220
219
221
- /*
222
- * before reconnecting the tcp session, mark the smb session (uid)
223
- * and the tid bad so they are not used until reconnected
224
- */
225
- cifs_dbg (FYI , "%s: marking sessions and tcons for reconnect and tearing down socket\n" ,
226
- __func__ );
227
220
/* do not want to be sending data on a socket we are freeing */
221
+ cifs_dbg (FYI , "%s: tearing down socket\n" , __func__ );
228
222
mutex_lock (& server -> srv_mutex );
229
223
if (server -> ssocket ) {
230
224
cifs_dbg (FYI , "State: 0x%x Flags: 0x%lx\n" , server -> ssocket -> state ,
@@ -280,7 +274,12 @@ static bool cifs_tcp_ses_needs_reconnect(struct TCP_Server_Info *server, int num
280
274
wake_up (& server -> response_q );
281
275
return false;
282
276
}
277
+
278
+ cifs_dbg (FYI , "Mark tcp session as need reconnect\n" );
279
+ trace_smb3_reconnect (server -> CurrentMid , server -> conn_id ,
280
+ server -> hostname );
283
281
server -> tcpStatus = CifsNeedReconnect ;
282
+
284
283
spin_unlock (& cifs_tcp_ses_lock );
285
284
return true;
286
285
}
@@ -634,7 +633,6 @@ cifs_readv_from_socket(struct TCP_Server_Info *server, struct msghdr *smb_msg)
634
633
635
634
if (server -> tcpStatus == CifsNeedReconnect ) {
636
635
spin_unlock (& cifs_tcp_ses_lock );
637
- cifs_reconnect (server , false);
638
636
return - ECONNABORTED ;
639
637
}
640
638
spin_unlock (& cifs_tcp_ses_lock );
@@ -3885,6 +3883,11 @@ cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses,
3885
3883
else
3886
3884
rc = - EHOSTDOWN ;
3887
3885
spin_unlock (& cifs_tcp_ses_lock );
3886
+ } else {
3887
+ spin_lock (& cifs_tcp_ses_lock );
3888
+ if (server -> tcpStatus == CifsInNegotiate )
3889
+ server -> tcpStatus = CifsNeedNegotiate ;
3890
+ spin_unlock (& cifs_tcp_ses_lock );
3888
3891
}
3889
3892
3890
3893
return rc ;
@@ -3931,8 +3934,18 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
3931
3934
if (server -> ops -> sess_setup )
3932
3935
rc = server -> ops -> sess_setup (xid , ses , server , nls_info );
3933
3936
3934
- if (rc )
3937
+ if (rc ) {
3935
3938
cifs_server_dbg (VFS , "Send error in SessSetup = %d\n" , rc );
3939
+ spin_lock (& cifs_tcp_ses_lock );
3940
+ if (server -> tcpStatus == CifsInSessSetup )
3941
+ server -> tcpStatus = CifsNeedSessSetup ;
3942
+ spin_unlock (& cifs_tcp_ses_lock );
3943
+ } else {
3944
+ spin_lock (& cifs_tcp_ses_lock );
3945
+ if (server -> tcpStatus == CifsInSessSetup )
3946
+ server -> tcpStatus = CifsGood ;
3947
+ spin_unlock (& cifs_tcp_ses_lock );
3948
+ }
3936
3949
3937
3950
return rc ;
3938
3951
}
@@ -4279,9 +4292,8 @@ static int __tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *t
4279
4292
4280
4293
/* only send once per connect */
4281
4294
spin_lock (& cifs_tcp_ses_lock );
4282
- if (tcon -> ses -> status != CifsGood ||
4283
- (tcon -> tidStatus != CifsNew &&
4284
- tcon -> tidStatus != CifsNeedTcon )) {
4295
+ if (tcon -> tidStatus != CifsNew &&
4296
+ tcon -> tidStatus != CifsNeedTcon ) {
4285
4297
spin_unlock (& cifs_tcp_ses_lock );
4286
4298
return 0 ;
4287
4299
}
0 commit comments