Skip to content

Commit 9e28c7a

Browse files
committed
Merge tag 'v6.8-rc3-smb-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: "Five smb3 client fixes, mostly multichannel related: - four multichannel fixes including fix for channel allocation when multiple inactive channels, fix for unneeded race in channel deallocation, correct redundant channel scaling, and redundant multichannel disabling scenarios - add warning if max compound requests reached" * tag 'v6.8-rc3-smb-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: smb: client: increase number of PDUs allowed in a compound request cifs: failure to add channel on iface should bump up weight cifs: do not search for channel if server is terminating cifs: avoid redundant calls to disable multichannel cifs: make sure that channel scaling is done only once
2 parents fc86e5c + 11d4d1d commit 9e28c7a

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

fs/smb/client/cifsglob.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
#define SMB_INTERFACE_POLL_INTERVAL 600
8888

8989
/* maximum number of PDUs in one compound */
90-
#define MAX_COMPOUND 5
90+
#define MAX_COMPOUND 7
9191

9292
/*
9393
* Default number of credits to keep available for SMB3.
@@ -1032,6 +1032,8 @@ struct cifs_chan {
10321032
__u8 signkey[SMB3_SIGN_KEY_SIZE];
10331033
};
10341034

1035+
#define CIFS_SES_FLAG_SCALE_CHANNELS (0x1)
1036+
10351037
/*
10361038
* Session structure. One of these for each uid session with a particular host
10371039
*/
@@ -1064,6 +1066,7 @@ struct cifs_ses {
10641066
enum securityEnum sectype; /* what security flavor was specified? */
10651067
bool sign; /* is signing required? */
10661068
bool domainAuto:1;
1069+
unsigned int flags;
10671070
__u16 session_flags;
10681071
__u8 smb3signingkey[SMB3_SIGN_KEY_SIZE];
10691072
__u8 smb3encryptionkey[SMB3_ENC_DEC_KEY_SIZE];

fs/smb/client/sess.c

Lines changed: 6 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;
@@ -269,6 +273,8 @@ int cifs_try_adding_channels(struct cifs_ses *ses)
269273
&iface->sockaddr,
270274
rc);
271275
kref_put(&iface->refcount, release_iface);
276+
/* failure to add chan should increase weight */
277+
iface->weight_fulfilled++;
272278
continue;
273279
}
274280

fs/smb/client/smb2pdu.c

Lines changed: 19 additions & 5 deletions
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 */
@@ -399,6 +399,15 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
399399
goto out;
400400
}
401401

402+
spin_lock(&ses->ses_lock);
403+
if (ses->flags & CIFS_SES_FLAG_SCALE_CHANNELS) {
404+
spin_unlock(&ses->ses_lock);
405+
mutex_unlock(&ses->session_mutex);
406+
goto skip_add_channels;
407+
}
408+
ses->flags |= CIFS_SES_FLAG_SCALE_CHANNELS;
409+
spin_unlock(&ses->ses_lock);
410+
402411
if (!rc &&
403412
(server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
404413
mutex_unlock(&ses->session_mutex);
@@ -410,7 +419,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
410419
rc = SMB3_request_interfaces(xid, tcon, false);
411420
free_xid(xid);
412421

413-
if (rc == -EOPNOTSUPP) {
422+
if (rc == -EOPNOTSUPP && ses->chan_count > 1) {
414423
/*
415424
* some servers like Azure SMB server do not advertise
416425
* that multichannel has been disabled with server
@@ -428,17 +437,22 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
428437
if (ses->chan_max > ses->chan_count &&
429438
ses->iface_count &&
430439
!SERVER_IS_CHAN(server)) {
431-
if (ses->chan_count == 1)
440+
if (ses->chan_count == 1) {
432441
cifs_server_dbg(VFS, "supports multichannel now\n");
442+
queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
443+
(SMB_INTERFACE_POLL_INTERVAL * HZ));
444+
}
433445

434446
cifs_try_adding_channels(ses);
435-
queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
436-
(SMB_INTERFACE_POLL_INTERVAL * HZ));
437447
}
438448
} else {
439449
mutex_unlock(&ses->session_mutex);
440450
}
451+
441452
skip_add_channels:
453+
spin_lock(&ses->ses_lock);
454+
ses->flags &= ~CIFS_SES_FLAG_SCALE_CHANNELS;
455+
spin_unlock(&ses->ses_lock);
442456

443457
if (smb2_command != SMB2_INTERNAL_CMD)
444458
mod_delayed_work(cifsiod_wq, &server->reconnect, 0);

fs/smb/client/transport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,8 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
435435
if (!(flags & CIFS_TRANSFORM_REQ))
436436
return __smb_send_rqst(server, num_rqst, rqst);
437437

438-
if (num_rqst > MAX_COMPOUND - 1)
439-
return -ENOMEM;
438+
if (WARN_ON_ONCE(num_rqst > MAX_COMPOUND - 1))
439+
return -EIO;
440440

441441
if (!server->ops->init_transform_rq) {
442442
cifs_server_dbg(VFS, "Encryption requested but transform callback is missing\n");

0 commit comments

Comments
 (0)