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

Rowland Penny rpenny at samba.org
Tue Jan 24 21:44:48 UTC 2023



On 24/01/2023 21:36, Jeremy Allison wrote:
> On Tue, Jan 24, 2023 at 09:32:09PM +0000, Rowland Penny via samba wrote:
>>
>> 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 ;-)
> 
> Ah, that code has gone through so many engineers and changes,
> who knows who originally added the bug :-) :-) :-).
> 
> Probably me though :-).

See: 
https://git.samba.org/?p=samba.git;a=commitdiff;h=556bf2ee006d14eb206c701bd8d375efb940140b

Rowland



More information about the samba mailing list