From: Volker Lendecke Date: Tue, 11 Sep 2018 14:13:24 +0000 (+0200) Subject: leases_db: Add share_mode_lease info to leases.tdb X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=f46023ed7021880612150d762540fda656c89b74;p=ira%2Fsamba-autobuild%2F.git leases_db: Add share_mode_lease info to leases.tdb This is the data stored in share_mode_lease inside the leases[] array in locking.tdb. This and all the following patches move all leases array to looking at the leases.tdb. Signed-off-by: Volker Lendecke Reviewed-by: Christof Schmitt --- diff --git a/source3/librpc/idl/leases_db.idl b/source3/librpc/idl/leases_db.idl index d0218756ade..ed9f27643ab 100644 --- a/source3/librpc/idl/leases_db.idl +++ b/source3/librpc/idl/leases_db.idl @@ -22,6 +22,32 @@ interface leases_db } leases_db_file; typedef [public] struct { + 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; + uint32 num_files; [size_is(num_files)] leases_db_file files[]; } leases_db_value; diff --git a/source3/locking/leases_db.c b/source3/locking/leases_db.c index 3893841b172..658d1ea4ffb 100644 --- a/source3/locking/leases_db.c +++ b/source3/locking/leases_db.c @@ -196,6 +196,9 @@ static NTSTATUS leases_db_do_locked( struct leases_db_add_state { const struct file_id *id; + uint32_t current_state; + uint16_t lease_version; + uint16_t epoch; const char *servicepath; const char *base_name; const char *stream_name; @@ -217,6 +220,13 @@ static void leases_db_add_fn( } } + if (value->num_files == 0) { + /* new record */ + value->current_state = state->current_state; + value->lease_version = state->lease_version; + value->epoch = state->epoch; + } + tmp = talloc_realloc( value, value->files, @@ -242,12 +252,18 @@ static void leases_db_add_fn( NTSTATUS leases_db_add(const struct GUID *client_guid, const struct smb2_lease_key *lease_key, const struct file_id *id, + uint32_t current_state, + uint16_t lease_version, + uint16_t epoch, const char *servicepath, const char *base_name, const char *stream_name) { struct leases_db_add_state state = { .id = id, + .current_state = current_state, + .lease_version = lease_version, + .epoch = epoch, .servicepath = servicepath, .base_name = base_name, .stream_name = stream_name, diff --git a/source3/locking/leases_db.h b/source3/locking/leases_db.h index 383575a2d88..db08c61c609 100644 --- a/source3/locking/leases_db.h +++ b/source3/locking/leases_db.h @@ -30,6 +30,9 @@ bool leases_db_init(bool read_only); NTSTATUS leases_db_add(const struct GUID *client_guid, const struct smb2_lease_key *lease_key, const struct file_id *id, + uint32_t current_state, + uint16_t lease_version, + uint16_t epoch, const char *servicepath, const char *filename, const char *stream_name); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index f8833df5745..3791df4d509 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2142,6 +2142,9 @@ static NTSTATUS grant_fsp_lease(struct files_struct *fsp, status = leases_db_add(client_guid, &lease->lease_key, &fsp->file_id, + fsp->lease->lease.lease_state, + fsp->lease->lease.lease_version, + fsp->lease->lease.lease_epoch, fsp->conn->connectpath, fsp->fsp_name->base_name, fsp->fsp_name->stream_name);