Commit 9e28c7a2 authored by Linus Torvalds's avatar Linus Torvalds

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
parents fc86e5c9 11d4d1db
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
#define SMB_INTERFACE_POLL_INTERVAL 600 #define SMB_INTERFACE_POLL_INTERVAL 600
/* maximum number of PDUs in one compound */ /* maximum number of PDUs in one compound */
#define MAX_COMPOUND 5 #define MAX_COMPOUND 7
/* /*
* Default number of credits to keep available for SMB3. * Default number of credits to keep available for SMB3.
...@@ -1032,6 +1032,8 @@ struct cifs_chan { ...@@ -1032,6 +1032,8 @@ struct cifs_chan {
__u8 signkey[SMB3_SIGN_KEY_SIZE]; __u8 signkey[SMB3_SIGN_KEY_SIZE];
}; };
#define CIFS_SES_FLAG_SCALE_CHANNELS (0x1)
/* /*
* Session structure. One of these for each uid session with a particular host * Session structure. One of these for each uid session with a particular host
*/ */
...@@ -1064,6 +1066,7 @@ struct cifs_ses { ...@@ -1064,6 +1066,7 @@ struct cifs_ses {
enum securityEnum sectype; /* what security flavor was specified? */ enum securityEnum sectype; /* what security flavor was specified? */
bool sign; /* is signing required? */ bool sign; /* is signing required? */
bool domainAuto:1; bool domainAuto:1;
unsigned int flags;
__u16 session_flags; __u16 session_flags;
__u8 smb3signingkey[SMB3_SIGN_KEY_SIZE]; __u8 smb3signingkey[SMB3_SIGN_KEY_SIZE];
__u8 smb3encryptionkey[SMB3_ENC_DEC_KEY_SIZE]; __u8 smb3encryptionkey[SMB3_ENC_DEC_KEY_SIZE];
......
...@@ -75,6 +75,10 @@ cifs_ses_get_chan_index(struct cifs_ses *ses, ...@@ -75,6 +75,10 @@ cifs_ses_get_chan_index(struct cifs_ses *ses,
{ {
unsigned int i; 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++) { for (i = 0; i < ses->chan_count; i++) {
if (ses->chans[i].server == server) if (ses->chans[i].server == server)
return i; return i;
...@@ -269,6 +273,8 @@ int cifs_try_adding_channels(struct cifs_ses *ses) ...@@ -269,6 +273,8 @@ int cifs_try_adding_channels(struct cifs_ses *ses)
&iface->sockaddr, &iface->sockaddr,
rc); rc);
kref_put(&iface->refcount, release_iface); kref_put(&iface->refcount, release_iface);
/* failure to add chan should increase weight */
iface->weight_fulfilled++;
continue; continue;
} }
......
...@@ -178,6 +178,7 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses, ...@@ -178,6 +178,7 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,
} }
ses->chans[chan_index].server = NULL; ses->chans[chan_index].server = NULL;
server->terminate = true;
spin_unlock(&ses->chan_lock); spin_unlock(&ses->chan_lock);
/* /*
...@@ -188,7 +189,6 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses, ...@@ -188,7 +189,6 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,
*/ */
cifs_put_tcp_session(server, from_reconnect); cifs_put_tcp_session(server, from_reconnect);
server->terminate = true;
cifs_signal_cifsd_for_reconnect(server, false); cifs_signal_cifsd_for_reconnect(server, false);
/* mark primary server as needing reconnect */ /* mark primary server as needing reconnect */
...@@ -399,6 +399,15 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, ...@@ -399,6 +399,15 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
goto out; goto out;
} }
spin_lock(&ses->ses_lock);
if (ses->flags & CIFS_SES_FLAG_SCALE_CHANNELS) {
spin_unlock(&ses->ses_lock);
mutex_unlock(&ses->session_mutex);
goto skip_add_channels;
}
ses->flags |= CIFS_SES_FLAG_SCALE_CHANNELS;
spin_unlock(&ses->ses_lock);
if (!rc && if (!rc &&
(server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) { (server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
mutex_unlock(&ses->session_mutex); mutex_unlock(&ses->session_mutex);
...@@ -410,7 +419,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, ...@@ -410,7 +419,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
rc = SMB3_request_interfaces(xid, tcon, false); rc = SMB3_request_interfaces(xid, tcon, false);
free_xid(xid); free_xid(xid);
if (rc == -EOPNOTSUPP) { if (rc == -EOPNOTSUPP && ses->chan_count > 1) {
/* /*
* some servers like Azure SMB server do not advertise * some servers like Azure SMB server do not advertise
* that multichannel has been disabled with server * that multichannel has been disabled with server
...@@ -428,17 +437,22 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, ...@@ -428,17 +437,22 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
if (ses->chan_max > ses->chan_count && if (ses->chan_max > ses->chan_count &&
ses->iface_count && ses->iface_count &&
!SERVER_IS_CHAN(server)) { !SERVER_IS_CHAN(server)) {
if (ses->chan_count == 1) if (ses->chan_count == 1) {
cifs_server_dbg(VFS, "supports multichannel now\n"); cifs_server_dbg(VFS, "supports multichannel now\n");
queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
(SMB_INTERFACE_POLL_INTERVAL * HZ));
}
cifs_try_adding_channels(ses); cifs_try_adding_channels(ses);
queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
(SMB_INTERFACE_POLL_INTERVAL * HZ));
} }
} else { } else {
mutex_unlock(&ses->session_mutex); mutex_unlock(&ses->session_mutex);
} }
skip_add_channels: skip_add_channels:
spin_lock(&ses->ses_lock);
ses->flags &= ~CIFS_SES_FLAG_SCALE_CHANNELS;
spin_unlock(&ses->ses_lock);
if (smb2_command != SMB2_INTERNAL_CMD) if (smb2_command != SMB2_INTERNAL_CMD)
mod_delayed_work(cifsiod_wq, &server->reconnect, 0); mod_delayed_work(cifsiod_wq, &server->reconnect, 0);
......
...@@ -435,8 +435,8 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, ...@@ -435,8 +435,8 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
if (!(flags & CIFS_TRANSFORM_REQ)) if (!(flags & CIFS_TRANSFORM_REQ))
return __smb_send_rqst(server, num_rqst, rqst); return __smb_send_rqst(server, num_rqst, rqst);
if (num_rqst > MAX_COMPOUND - 1) if (WARN_ON_ONCE(num_rqst > MAX_COMPOUND - 1))
return -ENOMEM; return -EIO;
if (!server->ops->init_transform_rq) { if (!server->ops->init_transform_rq) {
cifs_server_dbg(VFS, "Encryption requested but transform callback is missing\n"); cifs_server_dbg(VFS, "Encryption requested but transform callback is missing\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment