Skip to content

Commit 3345bb4

Browse files
Paulo Alcantara (SUSE)smfrench
authored andcommitted
cifs: Fix lookup of SMB connections on multichannel
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) <[email protected]> Reviewed-by: Aurelien Aptel <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 43f8a6a commit 3345bb4

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

fs/cifs/cifsglob.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ struct TCP_Server_Info {
777777
*/
778778
int nr_targets;
779779
bool noblockcnt; /* use non-blocking connect() */
780+
bool is_channel; /* if a session channel */
780781
};
781782

782783
struct cifs_credits {

fs/cifs/connect.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2712,7 +2712,11 @@ cifs_find_tcp_session(struct smb_vol *vol)
27122712

27132713
spin_lock(&cifs_tcp_ses_lock);
27142714
list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
2715-
if (!match_server(server, vol))
2715+
/*
2716+
* Skip ses channels since they're only handled in lower layers
2717+
* (e.g. cifs_send_recv).
2718+
*/
2719+
if (server->is_channel || !match_server(server, vol))
27162720
continue;
27172721

27182722
++server->srv_count;

fs/cifs/sess.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
213213
chan->server = NULL;
214214
goto out;
215215
}
216+
spin_lock(&cifs_tcp_ses_lock);
217+
chan->server->is_channel = true;
218+
spin_unlock(&cifs_tcp_ses_lock);
216219

217220
/*
218221
* We need to allocate the server crypto now as we will need

0 commit comments

Comments
 (0)