summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-09-18 13:51:01 +0200
committerChristof Schmitt <cs@samba.org>2019-04-14 04:01:32 +0000
commit7fc76c47867460a29ef82b65052a47b13c530a17 (patch)
treee7c878bd36e257e98ee51e3c049b165d2e2527a6
parent7cc9b426a44b1e12c6261836d0a86eabb7c92c34 (diff)
downloadsamba-7fc76c47867460a29ef82b65052a47b13c530a17.tar.gz
smbd: Use leases_db in try_lease_upgrade()
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
-rw-r--r--source3/smbd/open.c60
1 files changed, 38 insertions, 22 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 1ad4596cff7..a543ba3e037 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2101,23 +2101,33 @@ static NTSTATUS try_lease_upgrade(struct files_struct *fsp,
uint32_t granted)
{
struct share_mode_data *d = lck->data;
- int idx;
- struct share_mode_lease *l = NULL;
bool do_upgrade;
+ uint32_t current_state, breaking_to_requested, breaking_to_required;
+ bool breaking;
+ uint16_t lease_version, epoch;
uint32_t existing, requested;
+ NTSTATUS status;
- idx = find_share_mode_lease(d, client_guid, &lease->lease_key);
- if (idx == -1) {
- return NT_STATUS_NOT_FOUND;
+ status = leases_db_get(
+ client_guid,
+ &lease->lease_key,
+ &fsp->file_id,
+ &current_state,
+ &breaking,
+ &breaking_to_requested,
+ &breaking_to_required,
+ &lease_version,
+ &epoch);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- l = &d->leases[idx];
fsp->lease = find_fsp_lease(
fsp,
&lease->lease_key,
- l->current_state,
- l->lease_version,
- l->epoch);
+ current_state,
+ lease_version,
+ epoch);
if (fsp->lease == NULL) {
DEBUG(1, ("Did not find existing lease for file %s\n",
fsp_str_dbg(fsp)));
@@ -2127,7 +2137,7 @@ static NTSTATUS try_lease_upgrade(struct files_struct *fsp,
/*
* Upgrade only if the requested lease is a strict upgrade.
*/
- existing = l->current_state;
+ existing = current_state;
requested = lease->lease_state;
/*
@@ -2150,29 +2160,27 @@ static NTSTATUS try_lease_upgrade(struct files_struct *fsp,
/*
* only upgrade if we are not in breaking state
*/
- do_upgrade &= !l->breaking;
+ do_upgrade &= !breaking;
DEBUG(10, ("existing=%"PRIu32", requested=%"PRIu32", "
"granted=%"PRIu32", do_upgrade=%d\n",
existing, requested, granted, (int)do_upgrade));
if (do_upgrade) {
- l->current_state = granted;
- l->epoch += 1;
- }
-
- {
NTSTATUS set_status;
+ current_state = granted;
+ epoch += 1;
+
set_status = leases_db_set(
client_guid,
&lease->lease_key,
- l->current_state,
- l->breaking,
- l->breaking_to_requested,
- l->breaking_to_required,
- l->lease_version,
- l->epoch);
+ current_state,
+ breaking,
+ breaking_to_requested,
+ breaking_to_required,
+ lease_version,
+ epoch);
if (!NT_STATUS_IS_OK(set_status)) {
DBG_DEBUG("leases_db_set failed: %s\n",
@@ -2181,6 +2189,14 @@ static NTSTATUS try_lease_upgrade(struct files_struct *fsp,
}
}
+ status = update_share_mode_lease_from_db(
+ d, client_guid, &lease->lease_key);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_WARNING("update_share_mode_lease_from_db failed: %s\n",
+ nt_errstr(status));
+ return status;
+ }
+
fsp_lease_update(lck, fsp_client_guid(fsp), fsp->lease);
return NT_STATUS_OK;