Skip to content

Commit

Permalink
cifs: change tcon status when need_reconnect is set on it
Browse files Browse the repository at this point in the history
[ Upstream commit c6e02ee ]

When a tcon is marked for need_reconnect, the intention
is to have it reconnected.

This change adjusts tcon->status in cifs_tree_connect
when need_reconnect is set. Also, this change has a minor
correction in resetting need_reconnect on success. It makes
sure that it is done with tc_lock held.

Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
sprasad-microsoft authored and gregkh committed Mar 1, 2024
1 parent 8946924 commit cd743cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions fs/smb/client/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -4226,6 +4226,11 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru

/* only send once per connect */
spin_lock(&tcon->tc_lock);

/* if tcon is marked for needing reconnect, update state */
if (tcon->need_reconnect)
tcon->status = TID_NEED_TCON;

if (tcon->status == TID_GOOD) {
spin_unlock(&tcon->tc_lock);
return 0;
Expand Down
7 changes: 6 additions & 1 deletion fs/smb/client/dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,11 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru

/* only send once per connect */
spin_lock(&tcon->tc_lock);

/* if tcon is marked for needing reconnect, update state */
if (tcon->need_reconnect)
tcon->status = TID_NEED_TCON;

if (tcon->status == TID_GOOD) {
spin_unlock(&tcon->tc_lock);
return 0;
Expand Down Expand Up @@ -625,8 +630,8 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
spin_lock(&tcon->tc_lock);
if (tcon->status == TID_IN_TCON)
tcon->status = TID_GOOD;
spin_unlock(&tcon->tc_lock);
tcon->need_reconnect = false;
spin_unlock(&tcon->tc_lock);
}

return rc;
Expand Down
3 changes: 3 additions & 0 deletions fs/smb/client/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ cifs_mark_open_files_invalid(struct cifs_tcon *tcon)

/* only send once per connect */
spin_lock(&tcon->tc_lock);
if (tcon->need_reconnect)
tcon->status = TID_NEED_RECON;

if (tcon->status != TID_NEED_RECON) {
spin_unlock(&tcon->tc_lock);
return;
Expand Down

0 comments on commit cd743cf

Please sign in to comment.