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

Ralph Boehme slow at samba.org
Fri Jan 20 14:06:50 UTC 2023


On 1/20/23 14:50, Michael Tokarev via samba wrote:
>> 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".
> And SMB1 oplocks does not work when SMB2+ protocol is negotiated/used, 
> right?

No, they work just fine even with SMB2 and newer. Leases just offer a 
richer set of caching operations and are thus more efficient for certain 
workloads. Enabling "kernel oplocks" makes it worse as they don't work 
with shared/read oplocks, only for exclusive/read+write ones.

> But the lease which is granted to windows on that file.. stays. And it 
> is even
> funnier - I open this file in a text viewer (read-only), win asks shared 
> lease
> for it, next I modify the file on linux, close it on windows and re-open 
> it on
> windows. And it shows me the old cached contents of this file, while in the
> directory listing which windows displayed already even before second open,
> this file has zero size.

As said, change notify is something else entirely then caching via 
oplocks or leases. Change notify is a pure notification system while 
oplocks requires blocking oplock contenders from accessing a file until 
the client holding the oplock downgrades his oplock or times out.

> It is either that samba does not try to break this lease even if it 
> detects the
> file change (ie, change notify isn't hooked into the file lease code), 

Enable "kernel oplocks", then it should work.

> And it deserves a separate wiki page too, at least :)

That would be awesome! Contributions welcome! :)


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/3deaeeeb/OpenPGP_signature.sig>

More information about the samba mailing list