s3:smbd: only clear share_mode lease state... contend_level2_oplocks_begin_default...
authorStefan Metzmacher <metze@samba.org>
Mon, 15 Aug 2022 20:45:17 +0000 (22:45 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 17 Aug 2022 15:23:08 +0000 (17:23 +0200)
current state...

source3/smbd/smb2_oplock.c

index a555d3ae4fe2e53d618e70fb786c23950338e8db..59013fbca5aaa6ca60786978a6c4de9b4540be4d 100644 (file)
@@ -1141,6 +1141,7 @@ struct break_to_none_state {
        struct file_id id;
        struct smb2_lease_key lease_key;
        struct GUID client_guid;
+       size_t num_kept;
        size_t num_broken;
 };
 
@@ -1181,6 +1182,7 @@ static bool do_break_lease_to_none(struct share_mode_entry *e,
                                   &e->lease_key);
        if (our_own) {
                DEBUG(10, ("Don't break our own lease\n"));
+               state->num_kept += 1;
                return false;
        }
 
@@ -1303,14 +1305,14 @@ static void contend_level2_oplocks_begin_default(files_struct *fsp,
                DBG_WARNING("share_mode_forall_entries failed\n");
        }
 
-       if (state.num_broken == 0) {
+       if (state.num_broken == 0 && state.num_kept == 0) {
                /*
-                * Lazy update here. It might be that the read lease
-                * has gone in the meantime.
+                * Lazy update here. It might be that all leases
+                * have gone in the meantime.
                 */
                uint32_t acc, sh, ls;
                share_mode_flags_get(lck, &acc, &sh, &ls);
-               ls &= ~SMB2_LEASE_READ;
+               ls &= ~(SMB2_LEASE_READ|SMB2_LEASE_WRITE|SMB2_LEASE_HANDLE);
                share_mode_flags_set(lck, acc, sh, ls, NULL);
        }