Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <sprasad@microsoft.com>
Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Shyam Prasad N and committed by
Steve French
2f0e4f03 38e04b3e

+19 -11
+7 -3
fs/cifs/connect.c
··· 4036 4036 4037 4037 /* only send once per connect */ 4038 4038 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) { 4042 4046 spin_unlock(&tcon->tc_lock); 4043 4047 return 0; 4044 4048 }
+7 -3
fs/cifs/dfs.c
··· 502 502 503 503 /* only send once per connect */ 504 504 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) { 508 512 spin_unlock(&tcon->tc_lock); 509 513 return 0; 510 514 }
+1 -1
fs/cifs/dfs_cache.c
··· 1191 1191 } 1192 1192 1193 1193 spin_lock(&ipc->tc_lock); 1194 - if (ses->ses_status != SES_GOOD || ipc->status != TID_GOOD) { 1194 + if (ipc->status != TID_GOOD) { 1195 1195 spin_unlock(&ipc->tc_lock); 1196 1196 cifs_dbg(FYI, "%s: skip cache refresh due to disconnected ipc\n", __func__); 1197 1197 goto out;
+4 -4
fs/cifs/file.c
··· 174 174 struct list_head *tmp1; 175 175 176 176 /* 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); 180 180 return; 181 181 } 182 182 tcon->status = TID_IN_FILES_INVALIDATE; 183 - spin_unlock(&tcon->ses->ses_lock); 183 + spin_unlock(&tcon->tc_lock); 184 184 185 185 /* list all files open on tree connection and mark them invalid */ 186 186 spin_lock(&tcon->open_file_lock);