Skip to content

Commit c6c0199

Browse files
Paulo Alcantarajohn-cabaj
authored andcommitted
cifs: force new session setup and tcon for dfs
BugLink: https://bugs.launchpad.net/bugs/1970977 Do not reuse existing sessions and tcons in DFS failover as it might connect to different servers and shares. Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Cc: stable@vger.kernel.org Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de> Signed-off-by: Steve French <stfrench@microsoft.com> (cherry picked from commit fb39d30) Signed-off-by: Tim Gardner <tim.gardner@canonical.com> Acked-by: Philip Cox <philip.cox@canonical.com> Acked-by: Joseph Salisbury <joseph.salisbury@canonical.com> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
1 parent 181eddd commit c6c0199

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fs/cifs/connect.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,7 @@ static int reconnect_target_unlocked(struct TCP_Server_Info *server, struct dfs_
453453
return rc;
454454
}
455455

456-
static int
457-
reconnect_dfs_server(struct TCP_Server_Info *server,
458-
bool mark_smb_session)
456+
static int reconnect_dfs_server(struct TCP_Server_Info *server)
459457
{
460458
int rc = 0;
461459
const char *refpath = server->current_fullpath + 1;
@@ -479,7 +477,12 @@ reconnect_dfs_server(struct TCP_Server_Info *server,
479477
if (!cifs_tcp_ses_needs_reconnect(server, num_targets))
480478
return 0;
481479

482-
cifs_mark_tcp_ses_conns_for_reconnect(server, mark_smb_session);
480+
/*
481+
* Unconditionally mark all sessions & tcons for reconnect as we might be connecting to a
482+
* different server or share during failover. It could be improved by adding some logic to
483+
* only do that in case it connects to a different server or share, though.
484+
*/
485+
cifs_mark_tcp_ses_conns_for_reconnect(server, true);
483486

484487
cifs_abort_connection(server);
485488

@@ -537,7 +540,7 @@ int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session)
537540
}
538541
spin_unlock(&cifs_tcp_ses_lock);
539542

540-
return reconnect_dfs_server(server, mark_smb_session);
543+
return reconnect_dfs_server(server);
541544
}
542545
#else
543546
int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session)

0 commit comments

Comments
 (0)