]> git.infradead.org Git - nvme.git/commitdiff
Merge tag 'v6.8-rc3-smb-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 4 Feb 2024 07:26:19 +0000 (07:26 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 4 Feb 2024 07:26:19 +0000 (07:26 +0000)
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

fs/smb/client/cifsglob.h
fs/smb/client/sess.c
fs/smb/client/smb2pdu.c
fs/smb/client/transport.c

index 16befff4cbb47c9ac104b052401a490398d0fac9..c86a72c9d9ecd4268481a4caa29e58004cb7d6b9 100644 (file)
@@ -87,7 +87,7 @@
 #define SMB_INTERFACE_POLL_INTERVAL    600
 
 /* maximum number of PDUs in one compound */
-#define MAX_COMPOUND 5
+#define MAX_COMPOUND 7
 
 /*
  * Default number of credits to keep available for SMB3.
@@ -1032,6 +1032,8 @@ struct cifs_chan {
        __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
  */
@@ -1064,6 +1066,7 @@ struct cifs_ses {
        enum securityEnum sectype; /* what security flavor was specified? */
        bool sign;              /* is signing required? */
        bool domainAuto:1;
+       unsigned int flags;
        __u16 session_flags;
        __u8 smb3signingkey[SMB3_SIGN_KEY_SIZE];
        __u8 smb3encryptionkey[SMB3_ENC_DEC_KEY_SIZE];
index cde81042bebda6b8f3a454f46eb8b055af8d2f3c..ed4bd88dd528aab05c9594120116303ca35975e0 100644 (file)
@@ -75,6 +75,10 @@ cifs_ses_get_chan_index(struct cifs_ses *ses,
 {
        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++) {
                if (ses->chans[i].server == server)
                        return i;
@@ -269,6 +273,8 @@ int cifs_try_adding_channels(struct cifs_ses *ses)
                                         &iface->sockaddr,
                                         rc);
                                kref_put(&iface->refcount, release_iface);
+                               /* failure to add chan should increase weight */
+                               iface->weight_fulfilled++;
                                continue;
                        }
 
index 86f6f35b7f32e8498e2628350abf43daa0d97f96..c58fa44dd6b06aa76abad19cb432a6ed6f81e13b 100644 (file)
@@ -178,6 +178,7 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,
                }
 
                ses->chans[chan_index].server = NULL;
+               server->terminate = true;
                spin_unlock(&ses->chan_lock);
 
                /*
@@ -188,7 +189,6 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,
                 */
                cifs_put_tcp_session(server, from_reconnect);
 
-               server->terminate = true;
                cifs_signal_cifsd_for_reconnect(server, false);
 
                /* mark primary server as needing reconnect */
@@ -399,6 +399,15 @@ skip_sess_setup:
                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 &&
            (server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
                mutex_unlock(&ses->session_mutex);
@@ -410,7 +419,7 @@ skip_sess_setup:
                rc = SMB3_request_interfaces(xid, tcon, false);
                free_xid(xid);
 
-               if (rc == -EOPNOTSUPP) {
+               if (rc == -EOPNOTSUPP && ses->chan_count > 1) {
                        /*
                         * some servers like Azure SMB server do not advertise
                         * that multichannel has been disabled with server
@@ -428,17 +437,22 @@ skip_sess_setup:
                if (ses->chan_max > ses->chan_count &&
                    ses->iface_count &&
                    !SERVER_IS_CHAN(server)) {
-                       if (ses->chan_count == 1)
+                       if (ses->chan_count == 1) {
                                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);
-                       queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
-                                          (SMB_INTERFACE_POLL_INTERVAL * HZ));
                }
        } else {
                mutex_unlock(&ses->session_mutex);
        }
+
 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)
                mod_delayed_work(cifsiod_wq, &server->reconnect, 0);
index e00278fcfa4fa65f063430001c5506e3a2906358..994d70193432978de213a19a0f9933bd90e63671 100644 (file)
@@ -435,8 +435,8 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
        if (!(flags & CIFS_TRANSFORM_REQ))
                return __smb_send_rqst(server, num_rqst, rqst);
 
-       if (num_rqst > MAX_COMPOUND - 1)
-               return -ENOMEM;
+       if (WARN_ON_ONCE(num_rqst > MAX_COMPOUND - 1))
+               return -EIO;
 
        if (!server->ops->init_transform_rq) {
                cifs_server_dbg(VFS, "Encryption requested but transform callback is missing\n");