summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-12-09 22:10:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:35 -0500
commit822fcec39d6597524a94b0e8b9c244d5eb62b972 (patch)
treea93ea0fc38e30b2211940b01e599ede3faceeff7
parente53d78062878940d43526c2ef0fff3030fb64983 (diff)
downloadsamba-822fcec39d6597524a94b0e8b9c244d5eb62b972.tar.gz
samba-822fcec39d6597524a94b0e8b9c244d5eb62b972.tar.bz2
samba-822fcec39d6597524a94b0e8b9c244d5eb62b972.zip
r4121: Optimisation from Nadav Danieli <nadavd@exanet.com>. If we're oplocked,
short circuit some is_locked() tests. Jeremy. (This used to be commit f4feed8f90be98eaea59bebcc142fd398ffe2a59)
-rw-r--r--source3/locking/locking.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index b6e2ced336..4c6d89571e 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -77,9 +77,17 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn,
if (!lp_locking(snum) || !lp_strict_locking(snum))
return(False);
- ret = !brl_locktest(fsp->dev, fsp->inode, fsp->fnum,
+ if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && (lock_type == READ_LOCK || lock_type == WRITE_LOCK)) {
+ DEBUG(10,("is_locked: optimisation - exclusive oplock on file %s\n", fsp->fsp_name ));
+ ret = 0;
+ } else if (LEVEL_II_OPLOCK_TYPE(fsp->oplock_type) && (lock_type == READ_LOCK)) {
+ DEBUG(10,("is_locked: optimisation - level II oplock on file %s\n", fsp->fsp_name ));
+ ret = 0;
+ } else {
+ ret = !brl_locktest(fsp->dev, fsp->inode, fsp->fnum,
global_smbpid, sys_getpid(), conn->cnum,
offset, count, lock_type);
+ }
DEBUG(10,("is_locked: brl start=%.0f len=%.0f %s for file %s\n",
(double)offset, (double)count, ret ? "locked" : "unlocked",