s3:smbd: only clear LEASE_READ if there's no read lease is left (bug #15148)
Imagine a file is opened by ClientA, with FileHandleA using LeaseKeyA and ClientB, with FileHandleB using LeaseKeyB, both having an "R" lease.
Then ClientA sends a SMB2_write(FileHandleA), which triggers a lease break to NONE for LeaseKeyB. While LeaseKeyA doesn't get the break because it's used for FileHandleA. It means we only have a single "R" lease left, which is hold under LeaseKeyA.
Now ClientA sends a SMB2_write(FileHandleA) again, we'll see no lease break, but the logic in contend_level2_oplocks_begin_default() will hit the if (state.num_broken == 0) case and clears SHARE_MODE_LEASE_READ in share_mode_data->flags, while the "R" lease for LeaseKeyA is still there.
Now ClientB sends a SMB2_write(FileHandleB), and we won't see a lease break to NONE for LeaseKeyA, because the logic in contend_level2_oplocks_begin_default() detects that file_has_read_lease() returns false because SHARE_MODE_LEASE_READ was already cleared.
https://bugzilla.samba.org/show_bug.cgi?id=15148
Checklist
-
Commits have Signed-off-by:
with name/author being identical to the commit author -
(optional) This MR is just one part towards a larger feature. -
(optional, if backport required) Bugzilla bug filed and BUG:
tag added -
Test suite updated with functionality tests -
Test suite updated with negative tests -
Documentation updated -
CI timeout is 3h or higher (see Settings/CICD/General pipelines/ Timeout)
Reviewer's checklist:
-
There is a test suite reasonably covering new functionality or modifications -
Function naming, parameters, return values, types, etc., are consistent and according to README.Coding.md
-
This feature/change has adequate documentation added -
No obvious mistakes in the code