diff options
author | Shyam Prasad N <sprasad@microsoft.com> | 2021-07-19 13:54:46 +0300 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2021-11-13 01:22:20 +0300 |
commit | 724244cdb3828522109c88e56a0242537aefabe9 (patch) | |
tree | 59f14fbd73adcbb3b89fc822d24b99f47883ea67 /fs/cifs/transport.c | |
parent | 8e07757bece6e81b0b0910358ebceca3032bc6c7 (diff) | |
download | linux-724244cdb3828522109c88e56a0242537aefabe9.tar.xz |
cifs: protect session channel fields with chan_lock
Introducing a new spin lock to protect all the channel related
fields in a cifs_ses struct. This lock should be taken
whenever dealing with the channel fields, and should be held
only for very short intervals which will not sleep.
Currently, all channel related fields in cifs_ses structure
are protected by session_mutex. However, this mutex is held for
long periods (sometimes while waiting for a reply from server).
This makes the codepath quite tricky to change.
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/transport.c')
-rw-r--r-- | fs/cifs/transport.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index b7379329b741..61ea3d3f95b4 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -1044,14 +1044,17 @@ struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses) if (!ses) return NULL; + spin_lock(&ses->chan_lock); if (!ses->binding) { /* round robin */ if (ses->chan_count > 1) { index = (uint)atomic_inc_return(&ses->chan_seq); index %= ses->chan_count; } + spin_unlock(&ses->chan_lock); return ses->chans[index].server; } else { + spin_unlock(&ses->chan_lock); return cifs_ses_server(ses); } } |