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)
committerJeremy Allison <jra@samba.org>
Thu, 18 Aug 2022 19:41:33 +0000 (19:41 +0000)
commit96e2a82760ea06a89b7387b5cd3e864732afded3
treed305fbbc88f6a8cc30f0486fdc68e0e353a41bec
parent9e5ff607eb1b9c45c8836d3cff9d51b418740b87
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
selftest/knownfail.d/lease_bug_15148 [deleted file]
source3/smbd/smb2_oplock.c