Ksmbd (Samba3/4 alternative, ex cifsd/smbd) package support thread

Yea even changing the 3 settings to 512K each helps speed. Seeing steady 85-90MB/s read, 115 MB/s writes with Ksmbd on my GL-MT6000 which has 1GB RAM too, so plenty of headroom, just increased them a bit to see when speed starts to improve. If I comment them out completely then restart ksmbd I didn't see any faster past 512K so leaving it there for now.

1 Like

That is the right way to do it I guess.
Maybe bigger values (4MB/1MB) would be needed for faster 2.5/5/10G ports and WLAN 5GHz 160MHz - 2400Mbit/s.
But testing is the right way and it's good that we now know the reason for the speed limitation cap that we had.

For my usual usage currently I don't see any memory penalty but of course if I see higher memory usage I'll report it.
Regarding the memory usage this @KONG's post maybe usefull too.

Guys, how much memory does the ksmbd/samba take on your systems?
I have 2 TB SSD connected to the USB3 port of QNAP 301w and shared via ksmbd.
It takes around 200 MB of memory. When the device isn't mounted I have 580 MB free memory. Once it is mounted the free memory drops to 380 MB.
Isn't that too much?

In Windows 11 24H2 tighter security restrictions that were previously only enforced in Enterprise and above are now on by default in Pro. Insecure logins are not allowed by default, you now cannot connect to another PC if you have a local account with no password.
Hence the ksmbd shares with guest only allowed are no longer accessible on Windows 11 24H2.
This can be changed in Group Policies of Windows 11 but I want to ask how we can add users/passwords for ksmbd in latest ksmbd versions.

ksmbd.adduser

1 Like

Thanks.
I've added users and passwords and it's working. I added the info to the ksmbd wiki.

But although I disabled Allow guests Windows 11 24H2 is still unable to access the share without changes in Group Policies.
image
I cannot logon unless I enable below policy.

Hello. I have an iomega ix2 with openwrt version 22.03.7 and I have installed ksmbd. It works correctly for me on a mac with a version of macOS High Sierra and on Windows 10 but if I connect from an ipad with ios 18 from the Files app, it only lets me access as a read-only. I've tried adding the parameter vfs = streams_xattr and with it if it lets me write but when I copy a file, it is copied and then disappears. I have not been able to activate logs where you can see any errors. Does anyone know where the error can come from?

@linkinjeon or anyone else, do you happen to know what caused this error.

[33286.523905] kworker/3:2 invoked oom-killer: gfp_mask=0xcc0(GFP_KERNEL), order=0, oom_score_adj=0
[33286.523966] CPU: 3 PID: 22031 Comm: kworker/3:2 Tainted: G           O       6.6.61 #0
[33286.531791] Hardware name: QNAP 301w (DT)
[33286.539495] Workqueue: ksmbd-io ksmbd_exit_file_cache [ksmbd]
[33286.543578] Call trace:
[33286.549314]  dump_backtrace+0xb0/0x10c
[33286.551555]  show_stack+0x18/0x24
[33286.555375]  dump_stack_lvl+0x48/0x60
[33286.558760]  dump_stack+0x18/0x24
[33286.562421]  dump_header+0x44/0x1ac
[33286.565704]  oom_kill_process+0x16c/0x284
[33286.569021]  out_of_memory+0xc8/0x2fc
[33286.573171]  __alloc_pages+0x814/0xc80
[33286.576816]  skb_page_frag_refill+0xf8/0x11c
[33286.580483]  sk_page_frag_refill+0x20/0xa8
[33286.584905]  tcp_sendmsg_locked+0x1b4/0xadc
[33286.588798]  tcp_sendmsg+0x38/0x60
[33286.592875]  inet6_sendmsg+0x44/0x70
[33286.596347]  sock_sendmsg+0x7c/0xd8
[33286.600097]  kernel_sendmsg+0x30/0x40
[33286.603294]  smb_map_generic_desired_access+0xc4/0xbf0 [ksmbd]
[33286.607137]  ksmbd_conn_write+0x78/0xd0 [ksmbd]
[33286.612845]  ksmbd_exit_file_cache+0x6dc/0xad8 [ksmbd]
[33286.617292]  process_one_work+0x178/0x2d0
[33286.622478]  worker_thread+0x2f8/0x4e0
[33286.626574]  kthread+0xdc/0xe0
[33286.630201]  ret_from_fork+0x10/0x20
[33286.634076] Mem-Info:
[33286.636992] active_anon:54346 inactive_anon:31604 isolated_anon:0
[33286.636992]  active_file:775 inactive_file:45 isolated_file:0
[33286.636992]  unevictable:0 dirty:50 writeback:0
[33286.636992]  slab_reclaimable:4304 slab_unreclaimable:59216
[33286.636992]  mapped:209 shmem:3288 pagetables:496
[33286.636992]  sec_pagetables:0 bounce:0
[33286.636992]  kernel_misc_reclaimable:0
[33286.636992]  free:5094 free_pcp:206 free_cma:0
[33286.655682] Node 0 active_anon:217384kB inactive_anon:126416kB active_file:3000kB inactive_file:180kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:1036kB dirty:200kB writeback:0kB shmem:13152kB writeback_tmp:0kB kernel_stack:2784kB pagetables:1984kB sec_pagetables:0kB all_unreclaimable? yes
[33286.682508] DMA free:20124kB boost:0kB min:16384kB low:20480kB high:24576kB reserved_highatomic:0KB active_anon:217384kB inactive_anon:126416kB active_file:3244kB inactive_file:780kB unevictable:0kB writepending:200kB present:1048576kB managed:885276kB mlocked:0kB bounce:0kB free_pcp:812kB local_pcp:100kB free_cma:0kB
[33286.710687] lowmem_reserve[]: 0 0 0 0
[33286.732800] DMA: 95*4kB (UE) 54*8kB (UE) 158*16kB (UME) 167*32kB (UME) 68*64kB (UME) 18*128kB (UME) 5*256kB (U) 3*512kB (U) 1*1024kB (U) 0*2048kB 0*4096kB = 19180kB
[33286.736518] 4441 total pagecache pages
[33286.751554] 0 pages in swap cache
[33286.754815] Free swap  = 0kB
[33286.758168] Total swap = 0kB
[33286.761117] 262144 pages RAM
[33286.764011] 0 pages HighMem/MovableOnly
[33286.766845] 40825 pages reserved
[33286.770404] Tasks state (memory values in pages):
[33286.773924] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[33286.778539] [   1099]    81  1099      462        0    32768        0             0 ubusd
[33286.787015] [   1100]     0  1100      249       32    36864        0             0 askfirst
[33286.795256] [   1141]     0  1141      315        0    36864        0             0 urngd
[33286.803849] [   1931]   514  1931     1081      212    40960        0             0 logd
[33286.811830] [   1985]     0  1985     1408      267    45056        0             0 rpcd
[33286.820014] [   2338]     0  2338      370       32    28672        0             0 dropbear
[33286.828316] [   2500]     0  2500      834        0    40960        0             0 hostapd
[33286.836536] [   2501]     0  2501      834       64    32768        0             0 wpa_supplicant
[33286.844581] [   2557]   101  2557     2845      192    53248        0             0 wpa_supplicant
[33286.853585] [   2558]   101  2558     3101      639    57344        0             0 hostapd
[33286.862532] [   2565]     0  2565      855      128    40960        0             0 netifd
[33286.870901] [   3156]     0  3156      543       95    36864        0             0 odhcpd
[33286.879238] [   3445]     0  3445      363       64    28672        0             0 crond
[33286.887394] [   3613]     0  3613     2192      284    53248        0             0 uhttpd
[33286.895613] [   3708]     0  3708      568       32    32768        0             0 dbus-daemon
[33286.903809] [   3906] 65534  3906      746       32    40960        0             0 avahi-daemon
[33286.912351] [   4173]     0  4173     1622      189    40960        0             0 collectd
[33286.921430] [   5545]     0  5545      362        0    32768        0             0 udhcpc
[33286.929817] [   5551]     0  5551      314       32    28672        0             0 odhcp6c
[33286.937950] [   6422]     0  6422      476      192    36864        0             0 dynamic_dns_upd
[33286.946339] [   8788]     0  8788      476      160    36864        0             0 dynamic_dns_upd
[33286.955154] [  10392]     0 10392      376        0    32768        0             0 watchcat.sh
[33286.964311] [  10965]     0 10965      482       32    28672        0             0 ksmbd.mountd
[33286.972857] [  11083]     0 11083      558       64    28672        0             0 ksmbd.mountd
[33286.981929] [  11115]     0 11115      834       17    40960        0             0 ntpd
[33286.990781] [  11186]   123 11186      362        0    32768        0             0 ntpd
[33286.998745] [  12796] 65534 12796    75300    73267   634880        0             0 https-dns-proxy
[33287.006811] [  13845]     0 13845      253        0    32768        0             0 wsdd2
[33287.015574] [  16207]     0 16207      454       64    32768        0             0 nlbwmon
[33287.023989] [  26266]     0 26266      594      160    36864        0             0 banip-service.s
[33287.032080] [  27164]     0 27164      414        0    36864        0             0 sleep
[33287.041108] [  28044]     0 28044      834       16    40960        0             0 dnsmasq
[33287.049426] [  28082]   453 28082     8397     7040    98304        0             0 dnsmasq
[33287.057794] [  21730]     0 21730      362        0    32768        0             0 sleep
[33287.065922] [  23024]     0 23024      364        0    28672        0             0 sleep
[33287.074247] [  23025]     0 23025      364       32    36864        0             0 sleep
[33287.082404] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/,task=https-dns-proxy,pid=12796,uid=65534
[33287.090624] Out of memory: Killed process 12796 (https-dns-proxy) total-vm:301200kB, anon-rss:292300kB, file-rss:768kB, shmem-rss:0kB, UID:65534 pgtables:620kB oom_score_adj:0

OOM happened. You need to check what process(or ksmbd) has leakage.

Is ksmbd used in QNAP instead of samba ?

Yep it is ksmbd that is used.

Can you reproduce this ? Let me know what ksmbd are you using ? e.g. If you use ksmbd in linux kernel, let me know kernel version.

1 Like

root@QNAP:~# nss_diag
     MODEL: QNAP 301w
   OPENWRT: r28273-819787fd3b
IPQ BRANCH: qualcommax-6.x-nss-wifi
IPQ COMMIT: 819787fd3b
  IPQ DATE: 2024-11-17
    NSS FW: NSS.FW.12.2-161-HK.R
  MAC80211: v6.11.2-0-g7aa21fec187b
 ATH11K FW: WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
 INTERFACE: br-lan     tx-checksumming: on  rx-gro-list: off
            10g-1      tx-checksumming: on  rx-gro-list: off
            10g-2      tx-checksumming: on  rx-gro-list: off
            lan1       tx-checksumming: on  rx-gro-list: off
            lan2       tx-checksumming: on  rx-gro-list: off
            lan3       tx-checksumming: on  rx-gro-list: off
            lan4       tx-checksumming: on  rx-gro-list: off
            phy0-ap0   tx-checksumming: on  rx-gro-list: off
            phy1-ap0   tx-checksumming: on  rx-gro-list: off

  NSS PKGS: kmod-qca-nss-dp-6.6.61.2024.04.16~5bf8b91e-r1 aarch64_cortex-a53 {feeds/base/kernel/qca-nss-dp} () [installed]
            kmod-qca-nss-drv-6.6.61.12.5.2024.04.06~53a0dc1-r15 aarch64_cortex-a53 {feeds/nss_packages/qca-nss-drv} () [installed]
            kmod-qca-nss-drv-bridge-mgr-6.6.61.12.5.2024.06.12~1bcef16-r7 aarch64_cortex-a53 {feeds/nss_packages/qca-nss-clients} () [installed]
            kmod-qca-nss-drv-igs-6.6.61.12.5.2024.06.12~1bcef16-r7 aarch64_cortex-a53 {feeds/nss_packages/qca-nss-clients} () [installed]
            kmod-qca-nss-drv-qdisc-6.6.61.12.5.2024.06.12~1bcef16-r7 aarch64_cortex-a53 {feeds/nss_packages/qca-nss-clients} () [installed]
            kmod-qca-nss-drv-vlan-mgr-6.6.61.12.5.2024.06.12~1bcef16-r7 aarch64_cortex-a53 {feeds/nss_packages/qca-nss-clients} () [installed]
            kmod-qca-nss-ecm-6.6.61.12.5.5.2024.09.02~bd5057b-r3 aarch64_cortex-a53 {feeds/nss_packages/qca-nss-ecm} () [installed]
            nss-firmware-default-2024.08.04~794fe373-r1 aarch64_cortex-a53 {feeds/nss_packages/firmware/nss-firmware} () [installed]
            nss-firmware-ipq8074-2024.08.04~794fe373-r1 aarch64_cortex-a53 {feeds/nss_packages/firmware/nss-firmware} () [installed]

This is the first time I see that error so will see if I can reproduce this as it happend when I wasn't at home.

New version 3.5.3 available. PR by @pesa1234.
I tested it and LGTM.

2 Likes

I have tried to set up these changes on the above pull request.

3 Likes

Thanks it works OK.
I've added the relevant info to the ksmbd wiki.

1 Like

@linkinjeon
Can you look at this issue please.
Do you think it may be related with ksmbd somehow.
It is very specific involving F2FS file system, ksmbd network shares, qbittorent and started (at least I think so) with kernel 6.6.54 where a lot of changes for F2FS were committed.
Before that kernel everything was OK.
Summarizing - qbittorent when running on Windows cannot create folders on a F2FS NAS device.

6.6.65 version is is the latest. Problem could be reproduced with the latest 6.6.65 version ?

I will report in a few days when I compile a build with newer kernel. I'm on 6.6.63 currently.

When I have tested "creating directory" using mkdir on linux-6.6.65 kernel(the latest), It work fine on share ksmbd & f2fs. Can you reproduce the problem using mkdir when mounting cifs client ?