[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?

Ralph Boehme slow at samba.org
Fri Jan 20 11:49:34 UTC 2023


I don't have that much time to explain this in glory detail, but here 
are a few pointers.

There are three different apsects:

- locking in the Windows sharemode flavor
- file change notify
- client side caching via oplocks/leases

File change notify is fully supported and will detect local changes via 
inotify on Linux. Iirc there are some caveats like recursive change 
notify but that doesn't seem to be a production problem as Windows 
clients typically don't make use of this feature.

Client side caching (oplocks/leases): somewhat limitted support by 
enabled "kernel oplocks". Kernel oplocks don't work with SMB2 Leases, so 
you're restricted to SMB1 oplocks. Cf man smb.conf "kernel oplocks".

Locking (sharemodes): we used to leverage Linux support for mandatory 
flock() locks (LOCK_MAND) to "store" and let the kernel enforce access 
restrictions for local access, but unfortunately the kernel support got 
removed because it was buggy:

<https://github.com/torvalds/linux/commit/f7e33bdbd6d1bdf9c3df8bba5abcf3399f957ac3>

We still have VFS hooks for this but iirc the only filesystem that 
supports this via the VFS interface is GPFS.

Hope this helps somewhat.
-slow

-- 
Ralph Boehme, Samba Team                 https://samba.org/
SerNet Samba Team Lead      https://sernet.de/en/team-samba
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba/attachments/20230120/8ff07613/OpenPGP_signature.sig>


More information about the samba mailing list