Skip to content

Commit 705fc52

Browse files
sprasad-microsoftSteve French
authored andcommitted
cifs: handle when server starts supporting multichannel
When the user mounts with multichannel option, but the server does not support it, there can be a time in future where it can be supported. With this change, such a case is handled. Signed-off-by: Shyam Prasad N <[email protected]>
1 parent 784e0e2 commit 705fc52

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

fs/smb/client/cifsproto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ extern int SendReceiveBlockingLock(const unsigned int xid,
132132
struct smb_hdr *in_buf,
133133
struct smb_hdr *out_buf,
134134
int *bytes_returned);
135+
135136
void
136137
cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
137138
bool all_channels);

fs/smb/client/connect.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ static void smb2_query_server_interfaces(struct work_struct *work)
132132
free_xid(xid);
133133

134134
if (rc) {
135+
if (rc == -EOPNOTSUPP)
136+
return;
137+
135138
cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n",
136139
__func__, rc);
137140
}

fs/smb/client/smb2pdu.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
163163
int rc = 0;
164164
struct nls_table *nls_codepage = NULL;
165165
struct cifs_ses *ses;
166+
int xid;
166167

167168
/*
168169
* SMB2s NegProt, SessSetup, Logoff do not have tcon yet so
@@ -307,17 +308,44 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
307308
tcon->need_reopen_files = true;
308309

309310
rc = cifs_tree_connect(0, tcon, nls_codepage);
310-
mutex_unlock(&ses->session_mutex);
311311

312312
cifs_dbg(FYI, "reconnect tcon rc = %d\n", rc);
313313
if (rc) {
314314
/* If sess reconnected but tcon didn't, something strange ... */
315+
mutex_unlock(&ses->session_mutex);
315316
cifs_dbg(VFS, "reconnect tcon failed rc = %d\n", rc);
316317
goto out;
317318
}
318319

320+
if (!rc &&
321+
(server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
322+
mutex_unlock(&ses->session_mutex);
323+
324+
/*
325+
* query server network interfaces, in case they change
326+
*/
327+
xid = get_xid();
328+
rc = SMB3_request_interfaces(xid, tcon, false);
329+
free_xid(xid);
330+
331+
if (rc)
332+
cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n",
333+
__func__, rc);
334+
335+
if (ses->chan_max > ses->chan_count &&
336+
!SERVER_IS_CHAN(server)) {
337+
if (ses->chan_count == 1)
338+
cifs_server_dbg(VFS, "supports multichannel now\n");
339+
340+
cifs_try_adding_channels(ses);
341+
}
342+
} else {
343+
mutex_unlock(&ses->session_mutex);
344+
}
345+
319346
if (smb2_command != SMB2_INTERNAL_CMD)
320-
mod_delayed_work(cifsiod_wq, &server->reconnect, 0);
347+
if (mod_delayed_work(cifsiod_wq, &server->reconnect, 0))
348+
cifs_put_tcp_session(server, false);
321349

322350
atomic_inc(&tconInfoReconnectCount);
323351
out:

0 commit comments

Comments
 (0)