@@ -310,6 +310,8 @@ cifs_abort_connection(struct TCP_Server_Info *server)
310310 server -> ssocket -> flags );
311311 sock_release (server -> ssocket );
312312 server -> ssocket = NULL ;
313+ } else if (cifs_rdma_enabled (server )) {
314+ smbd_destroy (server );
313315 }
314316 server -> sequence_number = 0 ;
315317 server -> session_estab = false;
@@ -338,12 +340,6 @@ cifs_abort_connection(struct TCP_Server_Info *server)
338340 mid_execute_callback (mid );
339341 release_mid (mid );
340342 }
341-
342- if (cifs_rdma_enabled (server )) {
343- cifs_server_lock (server );
344- smbd_destroy (server );
345- cifs_server_unlock (server );
346- }
347343}
348344
349345static bool cifs_tcp_ses_needs_reconnect (struct TCP_Server_Info * server , int num_targets )
@@ -2015,39 +2011,31 @@ static int match_session(struct cifs_ses *ses,
20152011/**
20162012 * cifs_setup_ipc - helper to setup the IPC tcon for the session
20172013 * @ses: smb session to issue the request on
2018- * @ctx: the superblock configuration context to use for building the
2019- * new tree connection for the IPC (interprocess communication RPC)
2014+ * @seal: if encryption is requested
20202015 *
20212016 * A new IPC connection is made and stored in the session
20222017 * tcon_ipc. The IPC tcon has the same lifetime as the session.
20232018 */
2024- static int
2025- cifs_setup_ipc (struct cifs_ses * ses , struct smb3_fs_context * ctx )
2019+ struct cifs_tcon * cifs_setup_ipc (struct cifs_ses * ses , bool seal )
20262020{
20272021 int rc = 0 , xid ;
20282022 struct cifs_tcon * tcon ;
20292023 char unc [SERVER_NAME_LENGTH + sizeof ("//x/IPC$" )] = {0 };
2030- bool seal = false;
20312024 struct TCP_Server_Info * server = ses -> server ;
20322025
20332026 /*
20342027 * If the mount request that resulted in the creation of the
20352028 * session requires encryption, force IPC to be encrypted too.
20362029 */
2037- if (ctx -> seal ) {
2038- if (server -> capabilities & SMB2_GLOBAL_CAP_ENCRYPTION )
2039- seal = true;
2040- else {
2041- cifs_server_dbg (VFS ,
2042- "IPC: server doesn't support encryption\n" );
2043- return - EOPNOTSUPP ;
2044- }
2030+ if (seal && !(server -> capabilities & SMB2_GLOBAL_CAP_ENCRYPTION )) {
2031+ cifs_server_dbg (VFS , "IPC: server doesn't support encryption\n" );
2032+ return ERR_PTR (- EOPNOTSUPP );
20452033 }
20462034
20472035 /* no need to setup directory caching on IPC share, so pass in false */
20482036 tcon = tcon_info_alloc (false, netfs_trace_tcon_ref_new_ipc );
20492037 if (tcon == NULL )
2050- return - ENOMEM ;
2038+ return ERR_PTR ( - ENOMEM ) ;
20512039
20522040 spin_lock (& server -> srv_lock );
20532041 scnprintf (unc , sizeof (unc ), "\\\\%s\\IPC$" , server -> hostname );
@@ -2057,23 +2045,21 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb3_fs_context *ctx)
20572045 tcon -> ses = ses ;
20582046 tcon -> ipc = true;
20592047 tcon -> seal = seal ;
2060- rc = server -> ops -> tree_connect (xid , ses , unc , tcon , ctx -> local_nls );
2048+ rc = server -> ops -> tree_connect (xid , ses , unc , tcon , ses -> local_nls );
20612049 free_xid (xid );
20622050
20632051 if (rc ) {
2064- cifs_server_dbg (VFS , "failed to connect to IPC (rc=%d)\n" , rc );
2052+ cifs_server_dbg (VFS | ONCE , "failed to connect to IPC (rc=%d)\n" , rc );
20652053 tconInfoFree (tcon , netfs_trace_tcon_ref_free_ipc_fail );
2066- goto out ;
2054+ return ERR_PTR ( rc ) ;
20672055 }
20682056
20692057 cifs_dbg (FYI , "IPC tcon rc=%d ipc tid=0x%x\n" , rc , tcon -> tid );
20702058
20712059 spin_lock (& tcon -> tc_lock );
20722060 tcon -> status = TID_GOOD ;
20732061 spin_unlock (& tcon -> tc_lock );
2074- ses -> tcon_ipc = tcon ;
2075- out :
2076- return rc ;
2062+ return tcon ;
20772063}
20782064
20792065static struct cifs_ses *
@@ -2347,6 +2333,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
23472333{
23482334 struct sockaddr_in6 * addr6 = (struct sockaddr_in6 * )& server -> dstaddr ;
23492335 struct sockaddr_in * addr = (struct sockaddr_in * )& server -> dstaddr ;
2336+ struct cifs_tcon * ipc ;
23502337 struct cifs_ses * ses ;
23512338 unsigned int xid ;
23522339 int retries = 0 ;
@@ -2525,7 +2512,12 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
25252512 list_add (& ses -> smb_ses_list , & server -> smb_ses_list );
25262513 spin_unlock (& cifs_tcp_ses_lock );
25272514
2528- cifs_setup_ipc (ses , ctx );
2515+ ipc = cifs_setup_ipc (ses , ctx -> seal );
2516+ spin_lock (& cifs_tcp_ses_lock );
2517+ spin_lock (& ses -> ses_lock );
2518+ ses -> tcon_ipc = !IS_ERR (ipc ) ? ipc : NULL ;
2519+ spin_unlock (& ses -> ses_lock );
2520+ spin_unlock (& cifs_tcp_ses_lock );
25292521
25302522 free_xid (xid );
25312523
0 commit comments