Ralph Boehme
2023-Jan-20 14:06 UTC
[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?
Howdy! 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! :) -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/3deaeeeb/OpenPGP_signature.sig>
Michael Tokarev
2023-Jan-20 15:14 UTC
[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?
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
Michael Tokarev
2023-Jan-20 18:40 UTC
[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?
20.01.2023 17:06, Ralph Boehme via samba wrote: ..>> And it deserves a separate wiki page too, at least :) > > That would be awesome! Contributions welcome! :)I tried to create a new page, here: https://wiki.samba.org/index.php?title=Editing_files_locally_on_server:_interoperability but I can't, because I don't have permission to create new page on the samba wiki. Can someone please grant me such permission? Thanks, /mjt