From 2e00feb278e174fd28d003c4d5a576f91c0bd7d0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 14 Mar 2017 13:34:07 -0700 Subject: [PATCH] s3: locking: Update oplock optimization for the leases era ! MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=12628 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Wed Mar 15 20:04:32 CET 2017 on sn-devel-144 (cherry picked from commit 1c4b15aa5f6707e7bcfc21435e26929fb7f45c0f) Autobuild-User(v4-4-test): Karolin Seeger Autobuild-Date(v4-4-test): Fri Mar 24 12:35:06 CET 2017 on sn-devel-144 --- source3/locking/locking.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 5a9746094ba..e6d3918db79 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; } } -- 2.47.2