When determining which lease level to grant, we check for byterange locks on the file and if there are any, we remove R from the requested lease level. If the client requested RH, we remove R leaving H which is invalid according to MS-SMB2. Have patch, need bugnumber.
There are two more minor issues. These are not bugs, we're just returning or breaking to more restrictive lease levels then necessary when compared against Windows server: 1. When truncating a file which has byterange locks to size 0, the client can be granted RH leases. We currently never grant any lease in this case. 2. When a contending open causes a sharing violation, we break not just a H Lease (if any), but also R and W leases.
This bug was referenced in samba master: 9eba1a1423be253216ea862029cee2398961f7d4 196efe52814a24cd4a8c47346226407af17eadbd f26ae02a1bf739f25975143d1e1706d30ff98b2f 0fdd231f80eb9afe783e065c50b0f93c813d0857 debcd77ae7818ec953058e7524642ef76e0e6c7b 1fcc1500eedf4c08d1245c8c71d8002e32d8e40f 215b2c741a93023d13e8a9f82739ac3e91b64a66 b2f7a1c7623248b3a42a0ba3e07ab523403d9f9b 65d86082338c0b46358520ba5134b3f9c39291ee