Michael Tokarev
2023-Jan-24 21:33 UTC
[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?
25.01.2023 00:19, Ralph Boehme via samba ?????: ..>> so setting "kernel oplocks = yes" should prevent SMB2_CAP_LEASING >> being returned to the client. A wireshark trace when you remove >> the "smb2 leases = no" line would be good to look at. > > oh! That is the only place where we treat kernel oplocks as a global option. The docs and the rest of the code allow this as a per share option. Looks > like we have a problem here. > > @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. Hmm.. 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. Why inotify can't be used instead of F_SETLEASE here? Thanks! /mjt
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.
Reasonably Related Threads
- oplocks, kernel oplocks, kernel share modes, .. - how it all works?
- oplocks, kernel oplocks, kernel share modes, .. - how it all works?
- oplocks, kernel oplocks, kernel share modes, .. - how it all works?
- Oplocks
- linux_set_kernel_oplock: Refused oplock on file. F_SETLEASE semantic problem ?