# Samba Client in FreeBSD is painfully slow. Diagnostics.



## Dragony (May 2, 2020)

Hello!

When we were working with Linux, we had Linux/Windows workstations for every user and a shared Linux server. All files (projects, photos, music, etc.) of all users were stored on the Linux server and mounted via SMB, because backups are made only on the server. Now we have switched every Linux client to FreeBSD and, sorry, but the implemented SMB client is just unusable for today's work load. Everyone is complaining and I don't know what to do to fix that issue.

Here are my diagnostics:

1. The kernel module client ist really really really old and also seems to be no longer maintained.
2. The source does not include any caching at all. Every read request is directly sent to the server and the reply is then sent to the local pid on the client. This means that if a stupid program is reading in 1kb-chunks, the transfer speed goes down to a few 100kb/sec.

Practical example: If you are browing a photo folder with geeqie, it creates one thumb every 3 seconds. On a Linux box it creates 30 thumbs per second. Users just don't accept that.

I have tried the fusefs smb package, but that piece of software is the worst thing I have ever seen. Its equally slow, but its restricted to a single mount and it likes crashing.

Since I am not having the knowledge to code a new kernel module, I am searching for work arounds. So what can I do?

1. Is there something else to use than Samba? The folders need to be shared, so iSCSI isnt useable. NFS does not seem to be very secure to me.
2. If nothing else, how can I implement a read-ahead + caching layer? The SMB client has to use the max. block size and since by doing that it will read more than requested, it must implement a caching layer as well. Any ideas?

PS: Anyone feel free to create a replacement SMB client kernel module!


----------



## D-FENS (May 2, 2020)

Have you checked your basic network speed first? Sometimes the problem can originate at a lower level.
Use benchmarks/iperf - start the server on one machine `iperf -s` then on another machine start the client `iperf -c {server's IP address}`. For a 1Gbps network you should be measuring some speed in the range of 500-800 Mbit/s at least.


----------



## D-FENS (May 2, 2020)

Dragony said:


> 1. Is there something else to use than Samba? The folders need to be shared, so iSCSI isnt useable. NFS does not seem to be very secure to me.


I also had doubts regarding NFS but then I read somewhere in the forum that if configured properly, NFS could be quite secure. Proper configuration is the key.
I myself do not use Samba or NFS. I am a fan of sharing files via SSH, so I use sysutils/fusefs-sshfs.


----------



## Dragony (May 2, 2020)

I tried testing with iperf and the network performance is ~1GBit/s. I also tried out sshfs but it crashes after some experiments. I have aborted a file-copy-process and after that the mounted directory returned zero files. I had to unmount and remount. Not very reliable 

But where is the whole FreeBSD community? Not in this forum I suppose? I doubt no one is using this?


----------



## D-FENS (May 2, 2020)

I am unfamiliar with the SMB implementation so I cannot comment but it seems you've looked into it quite deeply.
Why don't you give NFS a shot? Maybe the security concerns can be put to rest by taking appropriate measures.

Also, if you use ZFS this file system has some really nice SMB and NFS sharing functions that might reduce your configuration effort.


----------

