diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/librpc/idl/open_files.idl | 33 | ||||
-rw-r--r-- | source3/locking/locking.c | 45 | ||||
-rw-r--r-- | source3/locking/share_mode_lock.c | 1 | ||||
-rw-r--r-- | source3/smbd/open.c | 104 | ||||
-rw-r--r-- | source3/smbd/oplock.c | 27 | ||||
-rw-r--r-- | source3/smbd/proto.h | 5 |
6 files changed, 8 insertions, 207 deletions
diff --git a/source3/librpc/idl/open_files.idl b/source3/librpc/idl/open_files.idl index a474da104c1..2f6f861b5e6 100644 --- a/source3/librpc/idl/open_files.idl +++ b/source3/librpc/idl/open_files.idl @@ -12,41 +12,10 @@ import "misc.idl"; interface open_files { - typedef [public,flag(NDR_PAHEX)] struct { - GUID client_guid; - smb2_lease_key lease_key; - smb2_lease_state current_state; - /* - * 'breaking' indicates that we're waiting - * for a lease break ack from the client - * and breaking_to_requested and breaking_to_required - * have a meaning. - * - * breaking_to_requested is the value already sent to - * the client, the client needs to ack to this (or less). - * - * breaking_to_required is the internal value that needs to - * be reached before we can reset breaking = false, this - * may requires multiple roundtrips to the client, e.g. - * when the lease broken to a more reduced value, while - * the lease break is still in progress. - * - * The following can be assumed (if breaking == true): - * - * current_state > breaking_to_requested >= breaking_to_required - */ - boolean8 breaking; - smb2_lease_state breaking_to_requested; - smb2_lease_state breaking_to_required; - uint16 lease_version; - uint16 epoch; - } share_mode_lease; - typedef [public] struct { server_id pid; hyper op_mid; uint16 op_type; - uint32 lease_idx; GUID client_guid; smb2_lease_key lease_key; uint32 access_mask; @@ -78,8 +47,6 @@ interface open_files [string,charset(UTF8)] char *stream_name; uint32 num_share_modes; [size_is(num_share_modes)] share_mode_entry share_modes[]; - uint32 num_leases; - [size_is(num_leases)] share_mode_lease leases[]; uint32 num_delete_tokens; [size_is(num_delete_tokens)] delete_token delete_tokens[]; timespec old_write_time; diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 7a70c33ed53..10e9606d134 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -672,7 +672,6 @@ static void remove_share_mode_lease(struct share_mode_data *d, struct share_mode_entry *e) { uint16_t op_type; - uint32_t lease_idx; uint32_t i; op_type = e->op_type; @@ -689,9 +688,6 @@ static void remove_share_mode_lease(struct share_mode_data *d, * it, remove it. */ - lease_idx = e->lease_idx; - e->lease_idx = UINT32_MAX; - for (i=0; i<d->num_share_modes; i++) { struct share_mode_entry *e2 = &d->share_modes[i]; @@ -716,18 +712,6 @@ static void remove_share_mode_lease(struct share_mode_data *d, return; } - d->num_leases -= 1; - d->leases[lease_idx] = d->leases[d->num_leases]; - - /* - * We changed the lease array. Fix all references to it. - */ - for (i=0; i<d->num_share_modes; i++) { - if (d->share_modes[i].lease_idx == d->num_leases) { - d->share_modes[i].lease_idx = lease_idx; - } - } - { NTSTATUS status; @@ -853,37 +837,8 @@ bool set_share_mode(struct share_mode_lock *lck, e->op_type = op_type; if (op_type == LEASE_OPLOCK) { - uint32_t i; - e->client_guid = *client_guid; e->lease_key = *lease_key; - - /* - * Need to set lease_idx. This is essentially - * find_share_mode_lease(), but that will go away - * soon. So don't add the dependency here. - */ - - for (i=0; i<d->num_leases; i++) { - struct share_mode_lease *l = &d->leases[i]; - - if (smb2_lease_equal(client_guid, - lease_key, - &l->client_guid, - &l->lease_key)) { - break; - } - } - - if (i == d->num_leases) { - DBG_WARNING("lease not found\n"); - d->num_share_modes -= 1; - return false; - } - - e->lease_idx = i; - } else { - e->lease_idx = UINT32_MAX; } e->time.tv_sec = fsp->open_time.tv_sec; diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index 5d0abfe548c..a20de67b34a 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -1011,7 +1011,6 @@ bool share_mode_cleanup_disconnected(struct file_id fid, open_persistent_id); data->num_share_modes = 0; - data->num_leases = 0; data->modified = true; ret = true; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 837af050df4..d23e8965f63 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1971,81 +1971,6 @@ static bool file_has_brlocks(files_struct *fsp) return (brl_num_locks(br_lck) > 0); } -static int find_share_mode_lease(struct share_mode_data *d, - const struct GUID *client_guid, - const struct smb2_lease_key *key) -{ - uint32_t i; - - for (i=0; i<d->num_leases; i++) { - struct share_mode_lease *l = &d->leases[i]; - - if (smb2_lease_equal(client_guid, - key, - &l->client_guid, - &l->lease_key)) { - return i; - } - } - - return -1; -} - -NTSTATUS update_share_mode_lease_from_db( - struct share_mode_data *d, - const struct GUID *client_guid, - const struct smb2_lease_key *lease_key) -{ - int idx; - struct share_mode_lease *l; - uint32_t current_state, breaking_to_requested, breaking_to_required; - bool breaking; - uint16_t lease_version, epoch; - NTSTATUS status; - - idx = find_share_mode_lease(d, client_guid, lease_key); - if (idx == -1) { - DBG_WARNING("find_share_mode_lease failed\n"); - return NT_STATUS_NOT_FOUND; - } - l = &d->leases[idx]; - - status = leases_db_get(client_guid, - lease_key, - &d->id, - ¤t_state, - &breaking, - &breaking_to_requested, - &breaking_to_required, - &lease_version, - &epoch); - if (!NT_STATUS_IS_OK(status)) { - DBG_WARNING("leases_db_get returned %s\n", - nt_errstr(status)); - return status; - } - - if ((l->current_state == current_state) && - (l->breaking == breaking) && - (l->breaking_to_requested == breaking_to_requested) && - (l->breaking_to_required == breaking_to_required) && - (l->lease_version == lease_version) && - (l->epoch == epoch)) { - return NT_STATUS_OK; - } - - l->current_state = current_state; - l->breaking = breaking; - l->breaking_to_requested = breaking_to_requested; - l->breaking_to_required = breaking_to_required; - l->lease_version = lease_version; - l->epoch = epoch; - - d->modified = true; - - return NT_STATUS_OK; -} - struct fsp_lease *find_fsp_lease(struct files_struct *new_fsp, const struct smb2_lease_key *key, uint32_t current_state, @@ -2100,7 +2025,6 @@ static NTSTATUS try_lease_upgrade(struct files_struct *fsp, const struct smb2_lease *lease, uint32_t granted) { - struct share_mode_data *d = lck->data; bool do_upgrade; uint32_t current_state, breaking_to_requested, breaking_to_required; bool breaking; @@ -2189,14 +2113,6 @@ 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; @@ -2209,19 +2125,8 @@ static NTSTATUS grant_new_fsp_lease(struct files_struct *fsp, uint32_t granted) { struct share_mode_data *d = lck->data; - struct share_mode_lease *tmp; NTSTATUS status; - tmp = talloc_realloc(d, d->leases, struct share_mode_lease, - d->num_leases+1); - if (tmp == NULL) { - /* - * See [MS-SMB2] - */ - return NT_STATUS_INSUFFICIENT_RESOURCES; - } - d->leases = tmp; - fsp->lease = talloc_zero(fsp->conn->sconn, struct fsp_lease); if (fsp->lease == NULL) { return NT_STATUS_INSUFFICIENT_RESOURCES; @@ -2233,14 +2138,6 @@ static NTSTATUS grant_new_fsp_lease(struct files_struct *fsp, fsp->lease->lease.lease_state = granted; fsp->lease->lease.lease_epoch = lease->lease_epoch + 1; - d->leases[d->num_leases] = (struct share_mode_lease) { - .client_guid = *client_guid, - .lease_key = fsp->lease->lease.lease_key, - .current_state = fsp->lease->lease.lease_state, - .lease_version = fsp->lease->lease.lease_version, - .epoch = fsp->lease->lease.lease_epoch, - }; - status = leases_db_add(client_guid, &lease->lease_key, &fsp->file_id, @@ -2257,7 +2154,6 @@ static NTSTATUS grant_new_fsp_lease(struct files_struct *fsp, return NT_STATUS_INSUFFICIENT_RESOURCES; } - d->num_leases += 1; d->modified = true; return NT_STATUS_OK; diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 02ecd539780..22277abab07 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -737,17 +737,17 @@ NTSTATUS downgrade_lease(struct smbXsrv_connection *xconn, } } - status = update_share_mode_lease_from_db(lck->data, client_guid, key); - if (!NT_STATUS_IS_OK(status)) { - DBG_WARNING("update_share_mode_lease_from_db failed: %s\n", - nt_errstr(status)); - TALLOC_FREE(lck); - return status; - } - DEBUG(10, ("%s: Downgrading %s to %x => %s\n", __func__, file_id_string_tos(&id), (unsigned)lease_state, nt_errstr(status))); + /* + * No, we did not modify the share mode array. We did modify + * the leases_db. But without this we don't notify a lease + * break waiter via dbwrap_watch_record. We need to make + * leases_db watched too. + */ + lck->data->modified = true; + { struct downgrade_lease_fsps_state state = { .id = id, .lck = lck, .key = key, @@ -1102,17 +1102,6 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx, } } - status = update_share_mode_lease_from_db( - lck->data, - client_guid, - &fsp->lease->lease.lease_key); - if (!NT_STATUS_IS_OK(status)) { - DBG_WARNING("update_share_mode_lease_from_db " - "failed: %s\n", nt_errstr(status)); - TALLOC_FREE(lck); - return; - } - /* Ensure we're in sync with current lease state. */ fsp_lease_update(lck, fsp_client_guid(fsp), fsp->lease); diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index a5c55c6ec50..68568e1bb3d 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -691,11 +691,6 @@ void msg_file_was_renamed(struct messaging_context *msg, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); -struct share_mode_lease; -NTSTATUS update_share_mode_lease_from_db( - struct share_mode_data *d, - const struct GUID *client_guid, - const struct smb2_lease_key *lease_key); struct fsp_lease *find_fsp_lease(struct files_struct *new_fsp, const struct smb2_lease_key *key, uint32_t current_state, |