]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/locking: add reset_delete_on_close_lck_open_id()
authorRalph Boehme <slow@samba.org>
Tue, 2 Dec 2025 14:12:18 +0000 (15:12 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 17 Jul 2026 10:18:37 +0000 (10:18 +0000)
Factor out reset_delete_on_close_lck_internal() and then make the
existing reset_delete_on_close_lck() a wrapper around it.

No change in behaviour for reset_delete_on_close_lck().

reset_delete_on_close_lck_open_id() receives the open_persistent_id from the
smbXsrv_open_global.tdb as an additional parameter

A later commit will use reset_delete_on_close_lck_open_id() in the open
scavenging code to ensure the delete token is only removed if the open-id
matches.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/locking/locking.c
source3/locking/proto.h

index 22691896bda5232548cc953e50694c062f836a2a..2f53a320a9322d252a6a4df51d4d683391e90c81 100644 (file)
@@ -800,8 +800,10 @@ static bool add_delete_on_close_token(struct share_mode_data *d,
        return true;
 }
 
-void reset_delete_on_close_lck(struct share_mode_lock *lck,
-                              uint32_t name_hash)
+static void reset_delete_on_close_lck_internal(struct share_mode_lock *lck,
+                                              uint32_t name_hash,
+                                              bool check_open_id,
+                                              uint64_t open_persistent_id)
 {
        struct share_mode_data *d = NULL;
        NTSTATUS status;
@@ -820,6 +822,11 @@ void reset_delete_on_close_lck(struct share_mode_lock *lck,
                struct delete_token *dt = &d->delete_tokens[i];
 
                if (dt->name_hash == name_hash) {
+                       if (check_open_id &&
+                           (dt->open_persistent_id != open_persistent_id))
+                       {
+                               continue;
+                       }
                        d->modified = true;
 
                        /* Delete this entry. */
@@ -831,6 +838,22 @@ void reset_delete_on_close_lck(struct share_mode_lock *lck,
        }
 }
 
+void reset_delete_on_close_lck(struct share_mode_lock *lck,
+                              uint32_t name_hash)
+{
+       reset_delete_on_close_lck_internal(lck, name_hash, false, 0);
+}
+
+void reset_delete_on_close_lck_open_id(struct share_mode_lock *lck,
+                                      uint32_t name_hash,
+                                      uint64_t open_persistent_id)
+{
+       reset_delete_on_close_lck_internal(lck,
+                                          name_hash,
+                                          true,
+                                          open_persistent_id);
+}
+
 struct set_delete_on_close_state {
        struct messaging_context *msg_ctx;
        DATA_BLOB blob;
index 37eb01dc5ee594936f2830f0dfe6b9b9ed92b610..791d7e6d48f2f1ae808b66737e167d1698f0607b 100644 (file)
@@ -173,6 +173,9 @@ bool get_delete_on_close_token(struct share_mode_lock *lck,
                                struct smb2_lease_key *parent_lease_key);
 void reset_delete_on_close_lck(struct share_mode_lock *lck,
                               uint32_t name_hash);
+void reset_delete_on_close_lck_open_id(struct share_mode_lock *lck,
+                                      uint32_t name_hash,
+                                      uint64_t open_persistent_id);
 void set_delete_on_close_lck(files_struct *fsp,
                        struct share_mode_lock *lck,
                        const struct security_token *nt_tok,