Skip to content

Commit 2f0e4f0

Browse files
sprasad-microsoftsmfrench
authored andcommitted
cifs: check only tcon status on tcon related functions
We had a couple of checks for session in cifs_tree_connect and cifs_mark_open_files_invalid, which were unnecessary. And that was done with ses_lock. Changed that to tc_lock too. Signed-off-by: Shyam Prasad N <[email protected]> Reviewed-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 38e04b3 commit 2f0e4f0

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

fs/cifs/connect.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4036,9 +4036,13 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
40364036

40374037
/* only send once per connect */
40384038
spin_lock(&tcon->tc_lock);
4039-
if (tcon->ses->ses_status != SES_GOOD ||
4040-
(tcon->status != TID_NEW &&
4041-
tcon->status != TID_NEED_TCON)) {
4039+
if (tcon->status != TID_NEW &&
4040+
tcon->status != TID_NEED_TCON) {
4041+
spin_unlock(&tcon->tc_lock);
4042+
return -EHOSTDOWN;
4043+
}
4044+
4045+
if (tcon->status == TID_GOOD) {
40424046
spin_unlock(&tcon->tc_lock);
40434047
return 0;
40444048
}

fs/cifs/dfs.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,13 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
502502

503503
/* only send once per connect */
504504
spin_lock(&tcon->tc_lock);
505-
if (tcon->ses->ses_status != SES_GOOD ||
506-
(tcon->status != TID_NEW &&
507-
tcon->status != TID_NEED_TCON)) {
505+
if (tcon->status != TID_NEW &&
506+
tcon->status != TID_NEED_TCON) {
507+
spin_unlock(&tcon->tc_lock);
508+
return -EHOSTDOWN;
509+
}
510+
511+
if (tcon->status == TID_GOOD) {
508512
spin_unlock(&tcon->tc_lock);
509513
return 0;
510514
}

fs/cifs/dfs_cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ static int __refresh_tcon(const char *path, struct cifs_tcon *tcon, bool force_r
11911191
}
11921192

11931193
spin_lock(&ipc->tc_lock);
1194-
if (ses->ses_status != SES_GOOD || ipc->status != TID_GOOD) {
1194+
if (ipc->status != TID_GOOD) {
11951195
spin_unlock(&ipc->tc_lock);
11961196
cifs_dbg(FYI, "%s: skip cache refresh due to disconnected ipc\n", __func__);
11971197
goto out;

fs/cifs/file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ cifs_mark_open_files_invalid(struct cifs_tcon *tcon)
174174
struct list_head *tmp1;
175175

176176
/* only send once per connect */
177-
spin_lock(&tcon->ses->ses_lock);
178-
if ((tcon->ses->ses_status != SES_GOOD) || (tcon->status != TID_NEED_RECON)) {
179-
spin_unlock(&tcon->ses->ses_lock);
177+
spin_lock(&tcon->tc_lock);
178+
if (tcon->status != TID_NEED_RECON) {
179+
spin_unlock(&tcon->tc_lock);
180180
return;
181181
}
182182
tcon->status = TID_IN_FILES_INVALIDATE;
183-
spin_unlock(&tcon->ses->ses_lock);
183+
spin_unlock(&tcon->tc_lock);
184184

185185
/* list all files open on tree connection and mark them invalid */
186186
spin_lock(&tcon->open_file_lock);

0 commit comments

Comments
 (0)