Skip to content

Commit

Permalink
cifs: Fix lookup of SMB connections on multichannel
Browse files Browse the repository at this point in the history
With the addition of SMB session channels, we introduced new TCP
server pointers that have no sessions or tcons associated with them.

In this case, when we started looking for TCP connections, we might
end up picking session channel rather than the master connection,
hence failing to get either a session or a tcon.

In order to fix that, this patch introduces a new "is_channel" field
to TCP_Server_Info structure so we can skip session channels during
lookup of connections.

Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Paulo Alcantara (SUSE) authored and Steve French committed Dec 4, 2019
1 parent 43f8a6a commit 3345bb4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ struct TCP_Server_Info {
*/
int nr_targets;
bool noblockcnt; /* use non-blocking connect() */
bool is_channel; /* if a session channel */
};

struct cifs_credits {
Expand Down
6 changes: 5 additions & 1 deletion fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,11 @@ cifs_find_tcp_session(struct smb_vol *vol)

spin_lock(&cifs_tcp_ses_lock);
list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
if (!match_server(server, vol))
/*
* Skip ses channels since they're only handled in lower layers
* (e.g. cifs_send_recv).
*/
if (server->is_channel || !match_server(server, vol))
continue;

++server->srv_count;
Expand Down
3 changes: 3 additions & 0 deletions fs/cifs/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
chan->server = NULL;
goto out;
}
spin_lock(&cifs_tcp_ses_lock);
chan->server->is_channel = true;
spin_unlock(&cifs_tcp_ses_lock);

/*
* We need to allocate the server crypto now as we will need
Expand Down

0 comments on commit 3345bb4

Please sign in to comment.