[SCM] Samba Shared Repository - branch v4-6-test updated
Karolin Seeger
kseeger at samba.org
Mon Mar 27 14:20:04 UTC 2017
The branch, v4-6-test has been updated
via 705149d s3: locking: Update oplock optimization for the leases era !
via a619054 s3: locking: Move two leases functions into a new file.
from 32f7ba9 Changes to make the Solaris C compiler happy.
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-6-test
- Log -----------------------------------------------------------------
commit 705149d93b2ce380945aa776a9f1e431181e457b
Author: Jeremy Allison <jra at samba.org>
Date: Tue Mar 14 13:34:07 2017 -0700
s3: locking: Update oplock optimization for the leases era !
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12628
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
Autobuild-User(master): Ralph Böhme <slow at samba.org>
Autobuild-Date(master): Wed Mar 15 20:04:32 CET 2017 on sn-devel-144
(cherry picked from commit 1c4b15aa5f6707e7bcfc21435e26929fb7f45c0f)
Autobuild-User(v4-6-test): Karolin Seeger <kseeger at samba.org>
Autobuild-Date(v4-6-test): Mon Mar 27 16:19:12 CEST 2017 on sn-devel-144
commit a619054b4b210433df44b0d1852ee57e90b35318
Author: Jeremy Allison <jra at samba.org>
Date: Tue Mar 14 13:23:13 2017 -0700
s3: locking: Move two leases functions into a new file.
map_oplock_to_lease_type(), fsp_lease_type().
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12628
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
(cherry picked from commit 125c78ad0b8f9caaef1ba2f1aeb5ec593375fccd)
-----------------------------------------------------------------------
Summary of changes:
source3/locking/leases_util.c | 55 +++++++++++++++++++++++++++++++++++++++++++
source3/locking/locking.c | 22 ++++++++++-------
source3/locking/proto.h | 4 ++++
source3/smbd/files.c | 8 -------
source3/smbd/oplock.c | 22 -----------------
source3/smbd/proto.h | 2 --
source3/wscript_build | 6 +++++
7 files changed, 78 insertions(+), 41 deletions(-)
create mode 100644 source3/locking/leases_util.c
Changeset truncated at 500 lines:
diff --git a/source3/locking/leases_util.c b/source3/locking/leases_util.c
new file mode 100644
index 0000000..cb307c8
--- /dev/null
+++ b/source3/locking/leases_util.c
@@ -0,0 +1,55 @@
+/*
+ Unix SMB/CIFS implementation.
+ Lease utility functions
+
+ Copyright (C) Jeremy Allison 2017.
+ Copyright (C) Stefan (metze) Metzmacher 2017.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#define DBGC_CLASS DBGC_LOCKING
+#include "includes.h"
+#include "../librpc/gen_ndr/open_files.h"
+#include "locking/proto.h"
+
+uint32_t map_oplock_to_lease_type(uint16_t op_type)
+{
+ uint32_t ret;
+
+ switch(op_type) {
+ case BATCH_OPLOCK:
+ case BATCH_OPLOCK|EXCLUSIVE_OPLOCK:
+ ret = SMB2_LEASE_READ|SMB2_LEASE_WRITE|SMB2_LEASE_HANDLE;
+ break;
+ case EXCLUSIVE_OPLOCK:
+ ret = SMB2_LEASE_READ|SMB2_LEASE_WRITE;
+ break;
+ case LEVEL_II_OPLOCK:
+ ret = SMB2_LEASE_READ;
+ break;
+ default:
+ ret = SMB2_LEASE_NONE;
+ break;
+ }
+ return ret;
+}
+
+uint32_t fsp_lease_type(struct files_struct *fsp)
+{
+ if (fsp->oplock_type == LEASE_OPLOCK) {
+ return fsp->lease->lease.lease_state;
+ }
+ return map_oplock_to_lease_type(fsp->oplock_type);
+}
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 5a97460..e6d3918 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -118,17 +118,21 @@ bool strict_lock_default(files_struct *fsp, struct lock_struct *plock)
}
if (strict_locking == Auto) {
- if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) &&
- (plock->lock_type == READ_LOCK ||
- plock->lock_type == WRITE_LOCK)) {
- DEBUG(10, ("is_locked: optimisation - exclusive oplock "
- "on file %s\n", fsp_str_dbg(fsp)));
+ uint32_t lease_type = fsp_lease_type(fsp);
+
+ if ((lease_type & SMB2_LEASE_READ) &&
+ (plock->lock_type == READ_LOCK))
+ {
+ DBG_DEBUG("optimisation - read lease on file %s\n",
+ fsp_str_dbg(fsp));
return true;
}
- if ((fsp->oplock_type == LEVEL_II_OPLOCK) &&
- (plock->lock_type == READ_LOCK)) {
- DEBUG(10, ("is_locked: optimisation - level II oplock "
- "on file %s\n", fsp_str_dbg(fsp)));
+
+ if ((lease_type & SMB2_LEASE_WRITE) &&
+ (plock->lock_type == WRITE_LOCK))
+ {
+ DBG_DEBUG("optimisation - write lease on file %s\n",
+ fsp_str_dbg(fsp));
return true;
}
}
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index 13499cf..17cb1cd 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -248,4 +248,8 @@ bool release_posix_lock_posix_flavour(files_struct *fsp,
const struct lock_struct *plocks,
int num_locks);
+/* The following definitions come from locking/leases_util.c */
+uint32_t map_oplock_to_lease_type(uint16_t op_type);
+uint32_t fsp_lease_type(struct files_struct *fsp);
+
#endif /* _LOCKING_PROTO_H_ */
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 1ef1bc9..6d0f05b 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -785,14 +785,6 @@ const struct GUID *fsp_client_guid(const files_struct *fsp)
return &fsp->conn->sconn->client->connections->smb2.client.guid;
}
-uint32_t fsp_lease_type(struct files_struct *fsp)
-{
- if (fsp->oplock_type == LEASE_OPLOCK) {
- return fsp->lease->lease.lease_state;
- }
- return map_oplock_to_lease_type(fsp->oplock_type);
-}
-
size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen)
{
int len;
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 6d7d17f..57b53f8 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -149,28 +149,6 @@ static void downgrade_file_oplock(files_struct *fsp)
TALLOC_FREE(fsp->oplock_timeout);
}
-uint32_t map_oplock_to_lease_type(uint16_t op_type)
-{
- uint32_t ret;
-
- switch(op_type) {
- case BATCH_OPLOCK:
- case BATCH_OPLOCK|EXCLUSIVE_OPLOCK:
- ret = SMB2_LEASE_READ|SMB2_LEASE_WRITE|SMB2_LEASE_HANDLE;
- break;
- case EXCLUSIVE_OPLOCK:
- ret = SMB2_LEASE_READ|SMB2_LEASE_WRITE;
- break;
- case LEVEL_II_OPLOCK:
- ret = SMB2_LEASE_READ;
- break;
- default:
- ret = SMB2_LEASE_NONE;
- break;
- }
- return ret;
-}
-
uint32_t get_lease_type(const struct share_mode_data *d,
const struct share_mode_entry *e)
{
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 9301c78..277dc6e 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -409,7 +409,6 @@ NTSTATUS file_name_hash(connection_struct *conn,
NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
const struct smb_filename *smb_fname_in);
const struct GUID *fsp_client_guid(const files_struct *fsp);
-uint32_t fsp_lease_type(struct files_struct *fsp);
size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen);
/* The following definitions come from smbd/ipc.c */
@@ -703,7 +702,6 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn,
/* The following definitions come from smbd/oplock.c */
-uint32_t map_oplock_to_lease_type(uint16_t op_type);
uint32_t get_lease_type(const struct share_mode_data *d,
const struct share_mode_entry *e);
bool update_num_read_oplocks(files_struct *fsp, struct share_mode_lock *lck);
diff --git a/source3/wscript_build b/source3/wscript_build
index c736176..92b9584 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -749,6 +749,7 @@ bld.SAMBA3_LIBRARY('smbd_base',
RPC_SERVICE
NDR_SMBXSRV
LEASES_DB
+ LEASES_UTIL
sysquotas
NDR_SMB_ACL
netapi
@@ -771,6 +772,7 @@ bld.SAMBA3_SUBSYSTEM('LOCKING',
tdb
talloc
LEASES_DB
+ LEASES_UTIL
NDR_OPEN_FILES
FNAME_UTIL
''')
@@ -779,6 +781,10 @@ bld.SAMBA3_SUBSYSTEM('LEASES_DB',
source='locking/leases_db.c',
deps='NDR_LEASES_DB')
+bld.SAMBA3_SUBSYSTEM('LEASES_UTIL',
+ source='locking/leases_util.c',
+ deps='NDR_OPEN_FILES')
+
if bld.CONFIG_GET("WITH_PROFILE"):
bld.SAMBA3_SUBSYSTEM('PROFILE',
source='profile/profile.c',
--
Samba Shared Repository
More information about the samba-cvs
mailing list