Skip to content

Commit 88675b2

Browse files
sprasad-microsoftSteve French
authored andcommitted
cifs: do not search for channel if server is terminating
In order to scale down the channels, the following sequence of operations happen: 1. server struct is marked for terminate 2. the channel is deallocated in the ses->chans array 3. at a later point the cifsd thread actually terminates the server Between 2 and 3, there can be calls to find the channel for a server struct. When that happens, there can be an ugly warning that's logged. But this is expected. So this change does two things: 1. in cifs_ses_get_chan_index, if server->terminate is set, return 2. always make sure server->terminate is set with chan_lock held Signed-off-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent e77e15f commit 88675b2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

fs/smb/client/sess.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ cifs_ses_get_chan_index(struct cifs_ses *ses,
7575
{
7676
unsigned int i;
7777

78+
/* if the channel is waiting for termination */
79+
if (server->terminate)
80+
return CIFS_INVAL_CHAN_INDEX;
81+
7882
for (i = 0; i < ses->chan_count; i++) {
7983
if (ses->chans[i].server == server)
8084
return i;

fs/smb/client/smb2pdu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,
178178
}
179179

180180
ses->chans[chan_index].server = NULL;
181+
server->terminate = true;
181182
spin_unlock(&ses->chan_lock);
182183

183184
/*
@@ -188,7 +189,6 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,
188189
*/
189190
cifs_put_tcp_session(server, from_reconnect);
190191

191-
server->terminate = true;
192192
cifs_signal_cifsd_for_reconnect(server, false);
193193

194194
/* mark primary server as needing reconnect */

0 commit comments

Comments
 (0)