Jeremy Allison
2023-Jan-24 21:39 UTC
[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?
On Wed, Jan 25, 2023 at 12:33:57AM +0300, Michael Tokarev wrote:>>@Michael: move the kernel oplocks setting to the global section, then things may start to work as expected. > >With kernel oplocks = yes in [global] but without mentioning >smb2 leases, this thing behaves in a way similar to when setting >smb2 leases to no (also globally, as it is a global parameter), -- >I see the original NONE/BATCH/LEVEL_II oplocks in there as in the >old good times. > >So looks like Ralph is correct here. Effectively, kernel oplocks >turn smb2 leases off, and work on the global level, not on a share >level.Easiest fix is to just change the docs here :-).>It looks like this needs some more experiments on my side though, >I'm not sure if it actually works and the cache is being invalidated >properly. Also from my own description of whole thing, it looks >like there's no way to do anything when the file is actually locked.Locking and share modes have bugger-all to do with leases and oplocks. Please separate the two in your mind, things will make much more sense when you do :-).>Why inotify can't be used instead of F_SETLEASE here?Because the local unix process *must* be blocked from doing *anything* to the file until the SMB client has flushed all changes back to the file. inotify just notifies, it doesn't stop any local client doing anything.
Jeremy Allison
2023-Jan-24 21:43 UTC
[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?
On Tue, Jan 24, 2023 at 01:39:34PM -0800, Jeremy Allison via samba wrote:> >Locking and share modes have bugger-all to do with leases and oplocks. > >Please separate the two in your mind, things will make >much more sense when you do :-).Actually, separate the three :-). Locking: Byte-ranges that control access to *parts* of a file. Mandatory on Windows, advisory on Linux. Samba maps Mandatory Windows byte-range locks to advisory locks on Linux so it works smbd -> smbd, but not if local processes ignore the locks (they are advisory on Linux). Share modes: Controls on how a file may be opened simultaneously. Windows-only, no analogue in Linux at all. Leases and Oplocks: Windows only (although NFSv4 has leases also). Controls client side caching of file data. No analogue in local processes on Linux.