Ralph Boehme
2023-Jan-24 21:19 UTC
[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?
On 1/24/23 22:12, Jeremy Allison wrote:> On Wed, Jan 25, 2023 at 12:00:09AM +0300, Michael Tokarev wrote: >> 24.01.2023 23:23, Jeremy Allison ?????: >> .. >>> which means you end up with LEASE_OPLOCK, granted=SMB2_LEASE_NONE >>> which is what you see with smbstatus. >>> >>> If you turn on kernel oplocks = yes, I think you must also >>> set smb2 leases = no in order for this to work. >> >> I've set smb2 leases = no (to global). I don't see these LEASE() anymore, >> I see "NONE", "BATCH" and "LEVEL_II" now, like in old good times :) > > Oh, very interesting. Something is wrong in our code then, as Ralph > already mentioned we have: > > ??????? capabilities = 0; > ??????? if (lp_host_msdfs()) { > ??????????????? capabilities |= SMB2_CAP_DFS; > ??????? } > > ??????? if (protocol >= PROTOCOL_SMB2_10 && > ??????????? lp_smb2_leases() && > ??????????? lp_oplocks(GLOBAL_SECTION_SNUM) && > ??????????? !lp_kernel_oplocks(GLOBAL_SECTION_SNUM)) > ??????? { > ??????????????? capabilities |= SMB2_CAP_LEASING; > ??????? } > > 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. -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/20230124/2a43abb5/OpenPGP_signature.sig>
Jeremy Allison
2023-Jan-24 21:29 UTC
[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?
On Tue, Jan 24, 2023 at 10:19:58PM +0100, Ralph Boehme wrote:>On 1/24/23 22:12, Jeremy Allison wrote: >>Oh, very interesting. Something is wrong in our code then, as Ralph >>already mentioned we have: >> >> ??????? capabilities = 0; >> ??????? if (lp_host_msdfs()) { >> ??????????????? capabilities |= SMB2_CAP_DFS; >> ??????? } >> >> ??????? if (protocol >= PROTOCOL_SMB2_10 && >> ??????????? lp_smb2_leases() && >> ??????????? lp_oplocks(GLOBAL_SECTION_SNUM) && >> ??????????? !lp_kernel_oplocks(GLOBAL_SECTION_SNUM)) >> ??????? { >> ??????????????? capabilities |= SMB2_CAP_LEASING; >> ??????? } >> >>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.Oh, great catch Ralph ! Once we've told the client we will handle leases we don't have a way to map the requested lease type to an oplock type if "kernel oplocks = yes" is set.
Rowland Penny
2023-Jan-24 21:32 UTC
[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?
On 24/01/2023 21:19, Ralph Boehme via samba wrote:> On 1/24/23 22:12, Jeremy Allison wrote: >> On Wed, Jan 25, 2023 at 12:00:09AM +0300, Michael Tokarev wrote: >>> 24.01.2023 23:23, Jeremy Allison ?????: >>> .. >>>> which means you end up with LEASE_OPLOCK, granted=SMB2_LEASE_NONE >>>> which is what you see with smbstatus. >>>> >>>> If you turn on kernel oplocks = yes, I think you must also >>>> set smb2 leases = no in order for this to work. >>> >>> I've set smb2 leases = no (to global). I don't see these LEASE() >>> anymore, >>> I see "NONE", "BATCH" and "LEVEL_II" now, like in old good times :) >> >> Oh, very interesting. Something is wrong in our code then, as Ralph >> already mentioned we have: >> >> ???????? capabilities = 0; >> ???????? if (lp_host_msdfs()) { >> ???????????????? capabilities |= SMB2_CAP_DFS; >> ???????? } >> >> ???????? if (protocol >= PROTOCOL_SMB2_10 && >> ???????????? lp_smb2_leases() && >> ???????????? lp_oplocks(GLOBAL_SECTION_SNUM) && >> ???????????? !lp_kernel_oplocks(GLOBAL_SECTION_SNUM)) >> ???????? { >> ???????????????? capabilities |= SMB2_CAP_LEASING; >> ???????? } >> >> 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. >You could try asking the person who wrote that bit of the code, a certain Jeremy Allison ;-) Rowland
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
Ralph Boehme
2023-Jan-25 06:44 UTC
[Samba] oplocks, kernel oplocks, kernel share modes, .. - how it all works?
On 1/24/23 22:19, Ralph Boehme via samba wrote:> 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.indeed: https://bugzilla.samba.org/show_bug.cgi?id=12783 :))) -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/20230125/47e72ad2/OpenPGP_signature.sig>