cifs: do not negotiate session if session already exists

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>
This commit is contained in:
Shyam Prasad N 2021-07-19 10:03:38 +00:00 committed by Steve French
parent 02102744d3
commit 8e07757bec

View File

@ -1943,6 +1943,9 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
ses->status); ses->status);
mutex_lock(&ses->session_mutex); mutex_lock(&ses->session_mutex);
if (ses->need_reconnect) {
cifs_dbg(FYI, "Session needs reconnect\n");
rc = cifs_negotiate_protocol(xid, ses); rc = cifs_negotiate_protocol(xid, ses);
if (rc) { if (rc) {
mutex_unlock(&ses->session_mutex); mutex_unlock(&ses->session_mutex);
@ -1951,8 +1954,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
free_xid(xid); free_xid(xid);
return ERR_PTR(rc); return ERR_PTR(rc);
} }
if (ses->need_reconnect) {
cifs_dbg(FYI, "Session needs reconnect\n");
rc = cifs_setup_session(xid, ses, rc = cifs_setup_session(xid, ses,
ctx->local_nls); ctx->local_nls);
if (rc) { if (rc) {