So I have been testing out a Samba file server on my OpenBSD 6.7 machine. Its read speed from the OpenBSD Samba server to a Windows 10 client was about 100MB/sec, right where I would expect it with Gigabit Ethernet.
However, the write speed was an abysmal 25 MB/sec! On my (much slower hardware) Linux Samba server I get about 100MB/sec in both directions. But with OpenBSD the write is terrible by default. I thought perhaps it could just be Linux file caching and delayed writes were beating the more conservative OpenBSD.
After some experimentation I found that doing two things helped the BSD machine get up to the level of the Linux machine.
So how do you fix the slow data transfer with Samba running on OpenBSD? Like this:
First increase the buffers for OpenBSD:
# sysctl -w net.inet.divert.sendspace=262144
# sysctl -w net.inet.divert.recvspace=262144
# sysctl -w net.inet6.divert.sendspace=262144
# sysctl -w net.inet6.divert.recvspace=262144
These changes to sysctl will not persist after a reboot. So once you are sure it is all working you can add them to /etc/sysctl.conf by adding just the following lines to /etc/sysctl.conf
net.inet.divert.sendspace=262144
net.inet.divert.recvspace=262144
net.inet6.divert.sendspace=262144
net.inet6.divert.recvspace=262144
Next we adjust the buffers in /etc/samba/smb.conf:
[global]
#put right after global
socket options = SO_SNDBUF=262144 SO_RCVBUF=262144
...
#rest of file
Restart Samba:
# rcctl restart smbd
Try out your new faster Samba on OpenBSD!
I experimented with smaller and larger values for these buffers. On my hardware these were the fastest values. YMMV; so perhaps test it out a little bigger or smaller. It’s probably best to keep these powers of two. It will, after all, affect EVERY Samba file transfer. So any improvement is a good thing!
And that is how you fix slow write speeds on Samba smbd for OpenBSD.