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

Michael Tokarev mjt at tls.msk.ru
Fri Jan 20 15:14:57 UTC 2023


20.01.2023 17:06, Ralph Boehme wrote:
> Howdy



>> 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.

Aha. That makes sense. Somehow it looked like anything SMB1 is bad and must
be avoided at all costs :)

>> 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.

It's been enabled for this share for a few days already.
But it looks like it is not sufficient to just reload-config
for this change to actually take effect, - I just restarted
smbd and voila, it all finally seems to be working fine,
including all the right oplock breaks when rsyncing many
files which are open on the client.

As you might imagine, it's been several days I'm trying to collect
some info about this (doing it in background but still) - and to me
it *looks* like it should work, - sure thing, I enabled kernel oplocks
for a reason! - but it doesn't. This is why I wrote the email which
started this thread, - because I wanted to understand where things
actually *are* in samba these days, before concluding something's
not working.

(and received reply from Rowland telling whole world is wrong
and use samba incorrectly :) ).

Samba is excellent software. It has quit some unknowns, but the
design seems to be exactly right!

Thank you very much for all this info. It definitely should become
a more wider knowledge! :) (I'm working on this)

/mjt




More information about the samba mailing list