From: Volker Lendecke Date: Fri, 24 May 2019 13:58:09 +0000 (+0200) Subject: smbd: Simplify fsp_lease_update() X-Git-Tag: ldb-2.0.5~602 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9891a44fd7fc7f2b3a177d5f220cf21dd48b18b0;p=thirdparty%2Fsamba.git smbd: Simplify fsp_lease_update() We don't need a share mode lock from a data dependency point of view anymore, the leases data moved to leases.tdb. However, from a coherency point of view it's probably wise to do this under a share mode lock. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 8e9de5e11b4..dc8003c6dd6 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2108,7 +2108,7 @@ static NTSTATUS try_lease_upgrade(struct files_struct *fsp, } } - fsp_lease_update(lck, fsp_client_guid(fsp), fsp->lease); + fsp_lease_update(fsp); return NT_STATUS_OK; } diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 1c7a4c8d29d..ba5db38daef 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -391,7 +391,7 @@ static void lease_timeout_handler(struct tevent_context *ctx, return; } - fsp_lease_update(lck, fsp_client_guid(fsp), fsp->lease); + fsp_lease_update(fsp); if (lease->lease.lease_epoch != old_epoch) { /* @@ -426,18 +426,18 @@ static void lease_timeout_handler(struct tevent_context *ctx, TALLOC_FREE(lck); } -bool fsp_lease_update(struct share_mode_lock *lck, - const struct GUID *client_guid, - struct fsp_lease *lease) +bool fsp_lease_update(struct files_struct *fsp) { + const struct GUID *client_guid = fsp_client_guid(fsp); + struct fsp_lease *lease = fsp->lease; uint32_t current_state; bool breaking; uint16_t lease_version, epoch; NTSTATUS status; status = leases_db_get(client_guid, - &lease->lease.lease_key, - &lck->data->id, + &fsp->lease->lease.lease_key, + &fsp->file_id, ¤t_state, &breaking, NULL, /* breaking_to_requested */ @@ -545,7 +545,7 @@ static struct files_struct *downgrade_lease_fsps(struct files_struct *fsp, return NULL; } - fsp_lease_update(state->lck, fsp_client_guid(fsp), fsp->lease); + fsp_lease_update(fsp); return NULL; } @@ -1110,7 +1110,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx, } /* Ensure we're in sync with current lease state. */ - fsp_lease_update(lck, fsp_client_guid(fsp), fsp->lease); + fsp_lease_update(fsp); TALLOC_FREE(lck); } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 7d4f7757ec3..7b2a752d2fd 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -733,9 +733,7 @@ NTSTATUS set_file_oplock(files_struct *fsp); bool remove_oplock_under_lock(files_struct *fsp, struct share_mode_lock *lck); bool remove_oplock(files_struct *fsp); bool downgrade_oplock(files_struct *fsp); -bool fsp_lease_update(struct share_mode_lock *lck, - const struct GUID *client_guid, - struct fsp_lease *lease); +bool fsp_lease_update(struct files_struct *fsp); NTSTATUS downgrade_lease(struct smbXsrv_connection *xconn, uint32_t num_file_ids, const struct file_id *ids,