Skip to content

Commit c1604da

Browse files
sprasad-microsoftSteve French
authored andcommitted
cifs: make status checks in version independent callers
The status of tcp session, smb session and tcon have the same flow, irrespective of the SMB version used. Hence these status checks and updates should happen in the version independent callers of these commands. Signed-off-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent ece0767 commit c1604da

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

fs/cifs/connect.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3770,10 +3770,6 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
37703770
if (rc == 0) {
37713771
bool is_unicode;
37723772

3773-
spin_lock(&cifs_tcp_ses_lock);
3774-
tcon->tidStatus = CifsGood;
3775-
spin_unlock(&cifs_tcp_ses_lock);
3776-
tcon->need_reconnect = false;
37773773
tcon->tid = smb_buffer_response->Tid;
37783774
bcc_ptr = pByteArea(smb_buffer_response);
37793775
bytes_left = get_bcc(smb_buffer_response);
@@ -3949,7 +3945,14 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
39493945
spin_lock(&cifs_tcp_ses_lock);
39503946
if (server->tcpStatus == CifsInSessSetup)
39513947
server->tcpStatus = CifsGood;
3948+
/* Even if one channel is active, session is in good state */
3949+
if (ses->status == CifsInSessSetup)
3950+
ses->status = CifsGood;
39523951
spin_unlock(&cifs_tcp_ses_lock);
3952+
3953+
spin_lock(&ses->chan_lock);
3954+
cifs_chan_clear_need_reconnect(ses, server);
3955+
spin_unlock(&ses->chan_lock);
39533956
}
39543957

39553958
return rc;
@@ -4461,8 +4464,15 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
44614464

44624465
if (rc) {
44634466
spin_lock(&cifs_tcp_ses_lock);
4464-
tcon->tidStatus = CifsNeedTcon;
4467+
if (tcon->tidStatus == CifsInTcon)
4468+
tcon->tidStatus = CifsNeedTcon;
4469+
spin_unlock(&cifs_tcp_ses_lock);
4470+
} else {
4471+
spin_lock(&cifs_tcp_ses_lock);
4472+
if (tcon->tidStatus == CifsInTcon)
4473+
tcon->tidStatus = CifsGood;
44654474
spin_unlock(&cifs_tcp_ses_lock);
4475+
tcon->need_reconnect = false;
44664476
}
44674477

44684478
return rc;
@@ -4487,8 +4497,15 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
44874497
rc = ops->tree_connect(xid, tcon->ses, tcon->treeName, tcon, nlsc);
44884498
if (rc) {
44894499
spin_lock(&cifs_tcp_ses_lock);
4490-
tcon->tidStatus = CifsNeedTcon;
4500+
if (tcon->tidStatus == CifsInTcon)
4501+
tcon->tidStatus = CifsNeedTcon;
44914502
spin_unlock(&cifs_tcp_ses_lock);
4503+
} else {
4504+
spin_lock(&cifs_tcp_ses_lock);
4505+
if (tcon->tidStatus == CifsInTcon)
4506+
tcon->tidStatus = CifsGood;
4507+
spin_unlock(&cifs_tcp_ses_lock);
4508+
tcon->need_reconnect = false;
44924509
}
44934510

44944511
return rc;

fs/cifs/sess.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,15 +1052,6 @@ sess_establish_session(struct sess_data *sess_data)
10521052
mutex_unlock(&server->srv_mutex);
10531053

10541054
cifs_dbg(FYI, "CIFS session established successfully\n");
1055-
spin_lock(&ses->chan_lock);
1056-
cifs_chan_clear_need_reconnect(ses, server);
1057-
spin_unlock(&ses->chan_lock);
1058-
1059-
/* Even if one channel is active, session is in good state */
1060-
spin_lock(&cifs_tcp_ses_lock);
1061-
ses->status = CifsGood;
1062-
spin_unlock(&cifs_tcp_ses_lock);
1063-
10641055
return 0;
10651056
}
10661057

fs/cifs/smb2pdu.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,16 +1386,6 @@ SMB2_sess_establish_session(struct SMB2_sess_data *sess_data)
13861386
mutex_unlock(&server->srv_mutex);
13871387

13881388
cifs_dbg(FYI, "SMB2/3 session established successfully\n");
1389-
1390-
spin_lock(&ses->chan_lock);
1391-
cifs_chan_clear_need_reconnect(ses, server);
1392-
spin_unlock(&ses->chan_lock);
1393-
1394-
/* Even if one channel is active, session is in good state */
1395-
spin_lock(&cifs_tcp_ses_lock);
1396-
ses->status = CifsGood;
1397-
spin_unlock(&cifs_tcp_ses_lock);
1398-
13991389
return rc;
14001390
}
14011391

@@ -1923,10 +1913,6 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
19231913
tcon->share_flags = le32_to_cpu(rsp->ShareFlags);
19241914
tcon->capabilities = rsp->Capabilities; /* we keep caps little endian */
19251915
tcon->maximal_access = le32_to_cpu(rsp->MaximalAccess);
1926-
spin_lock(&cifs_tcp_ses_lock);
1927-
tcon->tidStatus = CifsGood;
1928-
spin_unlock(&cifs_tcp_ses_lock);
1929-
tcon->need_reconnect = false;
19301916
tcon->tid = le32_to_cpu(rsp->hdr.Id.SyncId.TreeId);
19311917
strlcpy(tcon->treeName, tree, sizeof(tcon->treeName));
19321918

0 commit comments

Comments
 (0)