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.
Metze, is this a duplicate of: https://bugzilla.samba.org/show_bug.cgi?id=15112
(In reply to Jeremy Allison from comment #1) No it's different...
This bug was referenced in samba master: 7592aad4d7a84d0ac66a156a22af3ad77803e55c 9e5ff607eb1b9c45c8836d3cff9d51b418740b87 96e2a82760ea06a89b7387b5cd3e864732afded3
Created attachment 17485 [details] Patches for v4-15-test
Created attachment 17486 [details] Patches for v4-16-test
Created attachment 17487 [details] Patches for v4-17-test
Pushed to autobuild-v4-{17,16,15}-test.
This bug was referenced in samba v4-15-test: 93febc222bf56f4df7d8a2ca760785620c1abe4c ec1ad34f288526fb965dff14d49b6fccedd2140c 89110595b447729f1d0afa40aa011976943c1186
This bug was referenced in samba v4-16-test: 19f285e080980b0fbac125d3e0877bfe8424ff25 b910d9f6e0077159f44a12437402811337c51533 9cb40437278fb7963f42efe69ce0227aa21303bc
This bug was referenced in samba v4-17-test: 6ac28f4386867455dfcfc669a75e80f8c49a5386 0529214b3cc63f24cb7401360fc0d35b9c18ed49 c4c99397c568e1ebd8c67865147a2b01031d0445
Closing out bug report. Thanks!
This bug was referenced in samba v4-17-stable (Release samba-4.17.0rc3): 6ac28f4386867455dfcfc669a75e80f8c49a5386 0529214b3cc63f24cb7401360fc0d35b9c18ed49 c4c99397c568e1ebd8c67865147a2b01031d0445
This bug was referenced in samba v4-16-stable (Release samba-4.16.5): 19f285e080980b0fbac125d3e0877bfe8424ff25 b910d9f6e0077159f44a12437402811337c51533 9cb40437278fb7963f42efe69ce0227aa21303bc
This bug was referenced in samba v4-15-stable (Release samba-4.15.10): 93febc222bf56f4df7d8a2ca760785620c1abe4c ec1ad34f288526fb965dff14d49b6fccedd2140c 89110595b447729f1d0afa40aa011976943c1186