Linux Kernel Server
<Placeholder for documentation on building, testing, developing and using the SMB3 kernel server, fs/cifsd/ksmbd.ko>
What is SMB ?
The SMB ("Server Message Block") family of protocols is the most widely deployed network filesystem protocol, the default on Windows and Macs (and even on many phones and tablets), with clients and servers on all major operating systems, but lacked a kernel server for Linux. For many cases the current userspace server choices were suboptimal either due to memory footprint, performance or difficulty integrating well with advanced Linux features.
What is "ksmbd"?
ksmbd is a new kernel module which implements the server-side of the SMB3 protocol. The target is to provide optimized performance, GPLv2 SMB server, better lease handling (distributed caching). The bigger goal is to add new features more rapidly (e.g. RDMA aka "smbdirect", and recent encryption and signing improvements to the protocol) which are easier to develop on a smaller, more tightly optimized kernel server than for example in Samba. The Samba project is much broader in scope (tools, security services, LDAP, Active Directory Domain Controller, and a cross platform file server for a wider variety of purposes) but the user space file server portion of Samba has proved hard to optimize for some Linux workloads, including for smaller devices. This is not meant to replace Samba, but rather be an extension to allow better optimizing for Linux, and will continue to integrate well with Samba user space tools and libraries where appropriate. Working with the Samba team we have already made sure that the configuration files and xattrs are in a compatible format between the kernel and user space server.
Setting up the Kernel Server
To download the kernel server source code:
git clone -b ksmbd-next git://git.samba.org/sfrench/kernel-smb3
a. download the corequisite userspace utilities that manage the kernel server module and compile them (see ksmbd-tools/README):
b. Create user/password for SMB share.
# mkdir /etc/ksmbd/ # ksmbd.adduser -a <Enter USERNAME for SMB share access>
c. Create /etc/ksmbd/smb.conf file, add SMB share in smb.conf file - Refer smb.conf.example and Documentation/configuration.txt in ksmbd-tools
d. Insert ksmbd.ko module
# insmod ksmbd.ko
e. Start ksmbd user space daemon # ksmbd.mountd
f. Access share from Windows or Linux using SMB e.g. "mount -t cifs //server/share /mnt ..."
<TBD - Needs to be updated to be current>
|--- ... --------|--- ksmbd/3 - Client 3 |-------|--- ksmbd/2 - Client 2 | | ____________________________________________________ | | |- Client 1 |
<--- Socket ---|--- ksmbd/1 <<= Authentication : NTLM/NTLM2, Kerberos |
| | | | <<= SMB engine : SMB2, SMB2.1, SMB3, SMB3.0.2, | | | | | SMB3.1.1 | | | | |____________________________________________________| | | | | | |--- VFS --- Local Filesystem | |
KERNEL |--- ksmbd/0(forker kthread)
|| communication using NETLINK || ______________________________________________ || | | ksmbd.mountd <<= DCE/RPC(srvsvc, wkssvc, samr, lsarpc) | ^ | <<= configure shares setting, user accounts | | |______________________________________________| | |------ smb.conf(config file) | |------ ksmbdpwd.db(user account/password file) ^ ksmbd.adduser ------------|
The subset of performance related operations(open/read/write/close etc.) belong in kernelspace(ksmbd) and the other subset which belong to operations(DCE/RPC, user account/share database) which are not really related with performance are handled in userspace(ksmbd.mountd).
When the ksmbd.mountd is started, It starts up a forker thread at initialization time and opens a dedicated port 445 for listening to SMB requests. Whenever new clients make request, Forker thread will accept the client connection and fork a new thread for dedicated communication channel between the client and the server.
Mailing lists: - email@example.com - firstname.lastname@example.org
Wikipedia articles on CIFSD