Parameterize "smb2 max read", "smb2 max write", "smb2 max trans".
authorJeremy Allison <jra@samba.org>
Tue, 6 Apr 2010 22:43:35 +0000 (15:43 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 6 Apr 2010 22:43:35 +0000 (15:43 -0700)
Set to 64k by default.

Jeremy.

docs-xml/smbdotconf/tuning/smb2maxread.xml [new file with mode: 0644]
docs-xml/smbdotconf/tuning/smb2maxtrans.xml [new file with mode: 0644]
docs-xml/smbdotconf/tuning/smb2maxwrite.xml [new file with mode: 0644]
source3/include/proto.h
source3/param/loadparm.c
source3/smbd/smb2_negprot.c
source3/smbd/smb2_notify.c
source3/smbd/smb2_read.c
source3/smbd/smb2_write.c

diff --git a/docs-xml/smbdotconf/tuning/smb2maxread.xml b/docs-xml/smbdotconf/tuning/smb2maxread.xml
new file mode 100644 (file)
index 0000000..a3abbbc
--- /dev/null
@@ -0,0 +1,13 @@
+<samba:parameter name="smb2 max read"
+               context="G"
+               advanced="1" developer="1"
+               xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+    <para>This sets the maximum read size in bytes for a single SMB2 read request.
+    It exists to allow the Samba developers to experiment with different
+    size requests for tuning purposes.
+    </para>
+</description>
+
+<value type="default">65536</value>
+</samba:parameter>
diff --git a/docs-xml/smbdotconf/tuning/smb2maxtrans.xml b/docs-xml/smbdotconf/tuning/smb2maxtrans.xml
new file mode 100644 (file)
index 0000000..4e6fee0
--- /dev/null
@@ -0,0 +1,13 @@
+<samba:parameter name="smb2 max trans"
+               context="G"
+               advanced="1" developer="1"
+               xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+    <para>This sets the maximum read size in bytes for a single SMB2 transact request.
+    It exists to allow the Samba developers to experiment with different
+    size requests for tuning purposes.
+    </para>
+</description>
+
+<value type="default">65536</value>
+</samba:parameter>
diff --git a/docs-xml/smbdotconf/tuning/smb2maxwrite.xml b/docs-xml/smbdotconf/tuning/smb2maxwrite.xml
new file mode 100644 (file)
index 0000000..5085dba
--- /dev/null
@@ -0,0 +1,13 @@
+<samba:parameter name="smb2 max write"
+               context="G"
+               advanced="1" developer="1"
+               xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+    <para>This sets the maximum read size in bytes for a single SMB2 write request.
+    It exists to allow the Samba developers to experiment with different
+    size requests for tuning purposes.
+    </para>
+</description>
+
+<value type="default">65536</value>
+</samba:parameter>
index 7e45fed76ce1ccafdf3ee14aacd2e68fc9873cc7..7dcdeacb00246804b22d981525022dd1347b88c3 100644 (file)
@@ -4113,6 +4113,9 @@ int lp_lock_spin_time(void);
 int lp_usershare_max_shares(void);
 const char *lp_socket_options(void);
 int lp_config_backend(void);
+int lp_smb2_max_read(void);
+int lp_smb2_max_write(void);
+int lp_smb2_max_trans(void);
 char *lp_preexec(int );
 char *lp_postexec(int );
 char *lp_rootpreexec(int );
index b0f78f98a0d2d87b49702a055b13c8dd344f0617..077fc6355f2a725c04f0db94744f98a3037031d3 100644 (file)
@@ -362,6 +362,9 @@ struct global {
        char *szSMBPerfcountModule;
        bool bMapUntrustedToDomain;
        bool bAsyncSMBEchoHandler;
+       int ismb2_max_read;
+       int ismb2_max_write;
+       int ismb2_max_trans;
 };
 
 static struct global Globals;
@@ -2587,6 +2590,33 @@ static struct parm_struct parm_table[] = {
                .enum_list      = NULL,
                .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
        },
+       {
+               .label          = "smb2 max read",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .ptr            = &Globals.ismb2_max_read,
+               .special        = NULL,
+               .enum_list      = NULL,
+               .flags          = FLAG_ADVANCED,
+       },
+       {
+               .label          = "smb2 max write",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .ptr            = &Globals.ismb2_max_write,
+               .special        = NULL,
+               .enum_list      = NULL,
+               .flags          = FLAG_ADVANCED,
+       },
+       {
+               .label          = "smb2 max trans",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .ptr            = &Globals.ismb2_max_trans,
+               .special        = NULL,
+               .enum_list      = NULL,
+               .flags          = FLAG_ADVANCED,
+       },
 
        {N_("Printing Options"), P_SEP, P_SEPARATOR},
 
@@ -5250,6 +5280,10 @@ static void init_globals(bool first_time_only)
        Globals.iminreceivefile = 0;
 
        Globals.bMapUntrustedToDomain = false;
+
+       Globals.ismb2_max_read = 64*1024;
+       Globals.ismb2_max_write = 64*1024;
+       Globals.ismb2_max_trans = 64*1024;
 }
 
 /*******************************************************************
@@ -5612,6 +5646,9 @@ FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
 FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
+FN_GLOBAL_INTEGER(lp_smb2_max_read, &Globals.ismb2_max_read)
+FN_GLOBAL_INTEGER(lp_smb2_max_write, &Globals.ismb2_max_write)
+FN_GLOBAL_INTEGER(lp_smb2_max_trans, &Globals.ismb2_max_trans)
 
 FN_LOCAL_STRING(lp_preexec, szPreExec)
 FN_LOCAL_STRING(lp_postexec, szPostExec)
index 5b97c65d79c383b363094d83821dd1485d8f3f95..5a216b27e49e4ef0e012f60dc22a1d9de4c486f1 100644 (file)
@@ -164,9 +164,9 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
               negprot_spnego_blob.data, 16);   /* server guid */
        SIVAL(outbody.data, 0x18,
              capabilities);                    /* capabilities */
-       SIVAL(outbody.data, 0x1C, 0x00010000);  /* max transact size */
-       SIVAL(outbody.data, 0x20, 0x00010000);  /* max read size */
-       SIVAL(outbody.data, 0x24, 0x00010000);  /* max write size */
+       SIVAL(outbody.data, 0x1C, lp_smb2_max_trans()); /* max transact size */
+       SIVAL(outbody.data, 0x20, lp_smb2_max_read());  /* max read size */
+       SIVAL(outbody.data, 0x24, lp_smb2_max_write()); /* max write size */
        SBVAL(outbody.data, 0x28, 0);           /* system time */
        SBVAL(outbody.data, 0x30, 0);           /* server start time */
        SSVAL(outbody.data, 0x38,
index fb465abff9af1c1507a6f5368ff81c090c4d1a98..8fa074431989b91c45b5bddf363da05eba0c6cc2 100644 (file)
@@ -70,7 +70,7 @@ NTSTATUS smbd_smb2_request_process_notify(struct smbd_smb2_request *req)
         * 0x00010000 is what Windows 7 uses,
         * Windows 2008 uses 0x00080000
         */
-       if (in_output_buffer_length > 0x00010000) {
+       if (in_output_buffer_length > lp_smb2_max_trans()) {
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
        }
 
index 674fa2b71f8ec2f45fa7b9bbaf0b5ff81f3ebb1d..aa2805d66af1ef073c5d78441012348a0be9450c 100644 (file)
@@ -75,9 +75,9 @@ NTSTATUS smbd_smb2_request_process_read(struct smbd_smb2_request *req)
        in_remaining_bytes      = IVAL(inbody, 0x28);
 
        /* check the max read size */
-       if (in_length > 0x00010000) {
+       if (in_length > lp_smb2_max_read()) {
                DEBUG(0,("here:%s: 0x%08X: 0x%08X\n",
-                       __location__, in_length, 0x00010000));
+                       __location__, in_length, lp_smb2_max_read()));
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
        }
 
index 17d562affa11971fba043fb39506255ef74df1f5..608cf09e45b9feeaf28717f8888debe7de2bc041 100644 (file)
@@ -81,9 +81,9 @@ NTSTATUS smbd_smb2_request_process_write(struct smbd_smb2_request *req)
        }
 
        /* check the max write size */
-       if (in_data_length > 0x00010000) {
+       if (in_data_length > lp_smb2_max_write()) {
                DEBUG(0,("here:%s: 0x%08X: 0x%08X\n",
-                       __location__, in_data_length, 0x00010000));
+                       __location__, in_data_length, lp_smb2_max_write()));
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
        }