Skip to content

Commit

Permalink
cifs: do not search for channel if server is terminating
Browse files Browse the repository at this point in the history
[ Upstream commit 88675b2 ]

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 <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
sprasad-microsoft authored and gregkh committed Mar 1, 2024
1 parent fad689f commit 2b1f28e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions fs/smb/client/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ cifs_ses_get_chan_index(struct cifs_ses *ses,
{
unsigned int i;

/* if the channel is waiting for termination */
if (server->terminate)
return CIFS_INVAL_CHAN_INDEX;

for (i = 0; i < ses->chan_count; i++) {
if (ses->chans[i].server == server)
return i;
Expand Down
2 changes: 1 addition & 1 deletion fs/smb/client/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,
}

ses->chans[chan_index].server = NULL;
server->terminate = true;
spin_unlock(&ses->chan_lock);

/*
Expand All @@ -188,7 +189,6 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,
*/
cifs_put_tcp_session(server, from_reconnect);

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

/* mark primary server as needing reconnect */
Expand Down

0 comments on commit 2b1f28e

Please sign in to comment.