From: Ralph Boehme Date: Tue, 2 Dec 2025 14:12:18 +0000 (+0100) Subject: s3/locking: add reset_delete_on_close_lck_open_id() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd7d6487f33a30622f12356ee61946f145df139d;p=thirdparty%2Fsamba.git s3/locking: add reset_delete_on_close_lck_open_id() 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 Reviewed-by: Anoop C S --- diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 22691896bda..2f53a320a93 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -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; diff --git a/source3/locking/proto.h b/source3/locking/proto.h index 37eb01dc5ee..791d7e6d48f 100644 --- a/source3/locking/proto.h +++ b/source3/locking/proto.h @@ -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,