s3:smbd: only clear LEASE_READ if there's no read lease is left
authorStefan Metzmacher <metze@samba.org>
Mon, 15 Aug 2022 20:45:17 +0000 (22:45 +0200)
committerJule Anger <janger@samba.org>
Tue, 23 Aug 2022 07:45:16 +0000 (07:45 +0000)
commit9cb40437278fb7963f42efe69ce0227aa21303bc
tree73669485f4e2b6f262af8af01b3fbbebc5120ad9
parentb910d9f6e0077159f44a12437402811337c51533
s3:smbd: only clear LEASE_READ if there's no read lease is left

If contend_level2_oplocks_begin_default() skips break it's
own lease, we should not clear SHARE_MODE_LEASE_READ
in share_mode_data->flags.

Otherwise that lease won't see any lease break notifications
for writes from other clients (file handles not using the same lease
key).

So we need to count the number existing read leases (including
the one with the same lease key) in order to know it's
safe to clear SMB2_LEASE_READ/SHARE_MODE_LEASE_READ.

Otherwise the next run (likely from another client)
will get the wrong result from file_has_read_lease().

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15148

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Aug 18 19:41:33 UTC 2022 on sn-devel-184

(cherry picked from commit 96e2a82760ea06a89b7387b5cd3e864732afded3)
selftest/knownfail.d/lease_bug_15148 [deleted file]
source3/smbd/oplock.c