ksmbd-tools: adjust smb2 max read/write/trans and cache
authorAndrea Pesaresi <andreapesaresi82@gmail.com>
Sun, 8 Dec 2024 13:04:06 +0000 (14:04 +0100)
committerRosen Penev <rosenp@gmail.com>
Tue, 10 Dec 2024 00:13:34 +0000 (16:13 -0800)
Now for all devices with every size of RAM it is set to:
`smb2 max read = 64K`
`smb2 max write = 64K`
`smb2 max trans = 64K`

Instead of fixed value to 64K is better to check RAM size and adjust to:

32 ~ 64MB RAM, set the value to 64K
64 ~ 128MB, set it to 128KB
128 ~ 256MB, set it to 1MB
More than 256MB leave default size to 4MB

With 64MB and 128MB is better also to disable the read/write cache
`cache read buffers = no`
`cache write buffers = no`

Signed-off-by: Andrea Pesaresi <andreapesaresi82@gmail.com>
net/ksmbd-tools/Makefile
net/ksmbd-tools/files/ksmbd.conf.template
net/ksmbd-tools/files/ksmbd.init

index a08fe368cbce843ab090990de8231d44636c8bbe..9150acf93d4d274dccf76199d11277d74925117c 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ksmbd-tools
 PKG_VERSION:=3.5.3
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/cifsd-team/ksmbd-tools/releases/download/$(PKG_VERSION)
index 4cb7be3c07fc0dfa7bdcf93ccf0f7b48e92d6988..2da98b16e2b6b1c0a8e3bc787aa4365621f9e15e 100644 (file)
@@ -7,8 +7,3 @@
        ipc timeout = 20
        deadtime = 15
        map to guest = Bad User
-       smb2 max read = 64K
-       smb2 max write = 64K
-       smb2 max trans = 64K
-       cache read buffers = no
-       cache trans buffers = no
index a14183d58573d878cc0df233d264ff003ff54edd..1a43d9953736740afe5a38b923a79b03fd22176a 100644 (file)
@@ -12,6 +12,28 @@ config_get_sane()
        set -- "$(echo "$1" | tr -d '<>[]{};%?=#\n')"
 }
 
+config_get_ram()
+{
+       ramsize=$(grep MemTotal /proc/meminfo | awk '{print $2}')
+       if [ "$ramsize" -lt 65537 ];then
+               printf "\tsmb2 max read = 64K\n"
+               printf "\tsmb2 max write = 64K\n"
+               printf "\tsmb2 max trans = 64K\n"
+               printf "\tcache read buffers = no\n"
+               printf "\tcache trans buffers = no\n"
+       elif [ "$ramsize" -lt 134073 ];then
+               printf "\tsmb2 max read = 128K\n"
+               printf "\tsmb2 max write = 128K\n"
+               printf "\tsmb2 max trans = 128K\n"
+               printf "\tcache read buffers = no\n"
+               printf "\tcache trans buffers = no\n"
+       elif [ "$ramsize" -lt 262146 ];then
+               printf "\tsmb2 max read = 1M\n"
+               printf "\tsmb2 max write = 1M\n"
+               printf "\tsmb2 max trans = 1M\n"
+       fi
+}
+
 smb_header()
 {
        config_get_sane SMBD_IFACE "$1" interface "lan"
@@ -41,6 +63,8 @@ smb_header()
            /etc/ksmbd/ksmbd.conf.template > /var/etc/ksmbd/ksmbd.conf
                
        {
+               config_get_ram
+               
                printf "\n######### Dynamic written config options #########\n"
 
                if [ "$ALLOW_LEGACY_PROTOCOLS" -eq 1 ]; then