cifs: do not negotiate session if session already exists
authorShyam Prasad N <sprasad@microsoft.com>
Mon, 19 Jul 2021 10:03:38 +0000 (10:03 +0000)
committerSteve French <stfrench@microsoft.com>
Fri, 12 Nov 2021 22:21:03 +0000 (16:21 -0600)
In cifs_get_smb_ses, if we find an existing matching session,
we should not send a negotiate request for the session if a
session reconnect is not necessary.

Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/connect.c

index 084605f7ce966f7b6414807f66eb3371883ef45d..498ec05ca10d588d44f199d9c51de94b365a23fe 100644 (file)
@@ -1943,16 +1943,18 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
                         ses->status);
 
                mutex_lock(&ses->session_mutex);
-               rc = cifs_negotiate_protocol(xid, ses);
-               if (rc) {
-                       mutex_unlock(&ses->session_mutex);
-                       /* problem -- put our ses reference */
-                       cifs_put_smb_ses(ses);
-                       free_xid(xid);
-                       return ERR_PTR(rc);
-               }
                if (ses->need_reconnect) {
                        cifs_dbg(FYI, "Session needs reconnect\n");
+
+                       rc = cifs_negotiate_protocol(xid, ses);
+                       if (rc) {
+                               mutex_unlock(&ses->session_mutex);
+                               /* problem -- put our ses reference */
+                               cifs_put_smb_ses(ses);
+                               free_xid(xid);
+                               return ERR_PTR(rc);
+                       }
+
                        rc = cifs_setup_session(xid, ses,
                                                ctx->local_nls);
                        if (rc) {