From dccff4b290ac05a74e79a13a1117a33f7d06110f Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 27 Oct 2025 15:53:46 +0100 Subject: [PATCH] s3/locking: simplify reset_share_mode_entry() Since 3df388b8f148c00a3ef331d393cea976fb9340b3 we're using the open global_id as share_file_id in the share_mode_entry and we're also not changing it in mark_share_mode_disconnected(). Iow, old_share_file_id is equal to new_share_file_id which and both are equal to open_global_id. Hence replace the two old_share_file_id and new_share_file_id arguments with the single open_global_id argument. Signed-off-by: Ralph Boehme Reviewed-by: Volker Lendecke --- source3/locking/share_mode_lock.c | 22 ++++++++++------------ source3/locking/share_mode_lock.h | 5 ++--- source3/smbd/durable.c | 3 +-- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index 66a7c1b6c04..66af151c7f5 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -2741,8 +2741,7 @@ bool mark_share_mode_disconnected(struct share_mode_lock *lck, messaging_server_id(fsp->conn->sconn->msg_ctx), fsp->op->global->open_persistent_id, disconnected_pid, - UINT64_MAX, - fsp->op->global->open_persistent_id); + UINT64_MAX); return ok; } @@ -2750,10 +2749,9 @@ bool mark_share_mode_disconnected(struct share_mode_lock *lck, bool reset_share_mode_entry( struct share_mode_lock *lck, struct server_id old_pid, - uint64_t old_share_file_id, + uint64_t open_global_id, struct server_id new_pid, - uint64_t new_mid, - uint64_t new_share_file_id) + uint64_t new_mid) { struct file_id id = share_mode_lock_file_id(lck); struct share_mode_data *d = NULL; @@ -2801,7 +2799,7 @@ bool reset_share_mode_entry( ltdb->share_entries, ltdb->num_share_entries, new_pid, - new_share_file_id, + open_global_id, &e, &found); if (found) { @@ -2810,7 +2808,7 @@ bool reset_share_mode_entry( file_id_str_buf(id, &id_buf), ltdb->num_share_entries, server_id_str_buf(new_pid, &pid_buf2), - new_share_file_id); + open_global_id); goto done; } @@ -2818,7 +2816,7 @@ bool reset_share_mode_entry( ltdb->share_entries, ltdb->num_share_entries, old_pid, - old_share_file_id, + open_global_id, &e, &found); if (!found) { @@ -2827,7 +2825,7 @@ bool reset_share_mode_entry( file_id_str_buf(id, &id_buf), ltdb->num_share_entries, server_id_str_buf(old_pid, &pid_buf1), - old_share_file_id); + open_global_id); goto done; } DBG_DEBUG("%s - num_share_modes=%zu " @@ -2836,17 +2834,17 @@ bool reset_share_mode_entry( file_id_str_buf(id, &id_buf), ltdb->num_share_entries, server_id_str_buf(old_pid, &pid_buf1), - old_share_file_id, + open_global_id, old_idx, server_id_str_buf(new_pid, &pid_buf2), - new_share_file_id, + open_global_id, new_idx); e.pid = new_pid; if (new_mid != UINT64_MAX) { e.op_mid = new_mid; } - e.share_file_id = new_share_file_id; + e.share_file_id = open_global_id; ok = share_mode_entry_put(&e, &e_buf); if (!ok) { diff --git a/source3/locking/share_mode_lock.h b/source3/locking/share_mode_lock.h index 82668cd977a..b4f2848d81b 100644 --- a/source3/locking/share_mode_lock.h +++ b/source3/locking/share_mode_lock.h @@ -61,10 +61,9 @@ bool set_share_mode( bool reset_share_mode_entry( struct share_mode_lock *lck, struct server_id old_pid, - uint64_t old_share_file_id, + uint64_t open_global_id, struct server_id new_pid, - uint64_t new_mid, - uint64_t new_share_file_id); + uint64_t new_mid); bool mark_share_mode_disconnected( struct share_mode_lock *lck, struct files_struct *fsp); diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index fe6dd00b64a..41f4aaae1de 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -670,8 +670,7 @@ static void vfs_default_durable_reconnect_fn(struct share_mode_lock *lck, e.pid, e.share_file_id, messaging_server_id(fsp->conn->sconn->msg_ctx), - state->smb1req->mid, - fh_get_gen_id(fsp->fh)); + state->smb1req->mid); if (!ok) { DBG_DEBUG("Could not set new share_mode_entry values\n"); state->status = NT_STATUS_INTERNAL_ERROR; -- 2.47.3