From: Volker Lendecke Date: Fri, 9 Aug 2019 14:27:48 +0000 (+0200) Subject: smbd: Add share mode flags X-Git-Tag: talloc-2.3.1~775 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac85ec5ed855d8d0bc2564cbd33a580a8db6818e;p=thirdparty%2Fsamba.git smbd: Add share mode flags This will contain a summary of the "most restrictive" share mode and lease, i.e. intersection of all share_access entries and the union of all access_mask and leases in the share mode array. This way open_mode_check in the non-conflicting case will only have to look at the summary and not walk the share mode array. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/librpc/idl/open_files.idl b/source3/librpc/idl/open_files.idl index e1c8a01afd3..d3e537a9d42 100644 --- a/source3/librpc/idl/open_files.idl +++ b/source3/librpc/idl/open_files.idl @@ -41,7 +41,15 @@ interface open_files } delete_token; typedef [public,bitmap16bit] bitmap { - SHARE_MODE_HAS_READ_LEASE = 0x01 + SHARE_MODE_SHARE_DELETE = 0x100, + SHARE_MODE_SHARE_WRITE = 0x080, + SHARE_MODE_SHARE_READ = 0x040, + SHARE_MODE_ACCESS_DELETE = 0x020, + SHARE_MODE_ACCESS_WRITE = 0x010, + SHARE_MODE_ACCESS_READ = 0x008, + SHARE_MODE_LEASE_HANDLE = 0x004, + SHARE_MODE_LEASE_WRITE = 0x002, + SHARE_MODE_LEASE_READ = 0x001 } share_mode_flags; typedef [public] struct { diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index 3c91a25948d..abd911f4be2 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -275,7 +275,7 @@ bool file_has_read_lease(struct files_struct *fsp) return true; } - return (fsp->share_mode_flags & SHARE_MODE_HAS_READ_LEASE) != 0; + return (fsp->share_mode_flags & SHARE_MODE_LEASE_READ) != 0; } static int share_mode_data_nofree_destructor(struct share_mode_data *d) @@ -2005,7 +2005,7 @@ bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp) return false; } - lck->data->flags |= SHARE_MODE_HAS_READ_LEASE; + lck->data->flags |= SHARE_MODE_LEASE_READ; lck->data->modified = true; return true; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index d9146f0582d..bb497adbd69 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2417,7 +2417,7 @@ grant: } if (granted & SMB2_LEASE_READ) { - lck->data->flags |= SHARE_MODE_HAS_READ_LEASE; + lck->data->flags |= SHARE_MODE_LEASE_READ; } DBG_DEBUG("oplock type 0x%x on file %s\n", diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 44aeaf48a63..b3da84b1269 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -1319,7 +1319,7 @@ static void contend_level2_oplocks_begin_default(files_struct *fsp, * Lazy update here. It might be that the read lease * has gone in the meantime. */ - d->flags &= ~SHARE_MODE_HAS_READ_LEASE; + d->flags &= ~SHARE_MODE_LEASE_READ; d->modified = true; }