r4121: Optimisation from Nadav Danieli <nadavd@exanet.com>. If we're oplocked,
authorJeremy Allison <jra@samba.org>
Thu, 9 Dec 2004 22:10:40 +0000 (22:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:53:35 +0000 (10:53 -0500)
short circuit some is_locked() tests.
Jeremy.
(This used to be commit f4feed8f90be98eaea59bebcc142fd398ffe2a59)

source3/locking/locking.c

index b6e2ced3360fee4febac39b080d5b8947ccb99f2..4c6d89571e389e34f2c468edbeb06c0ae5cc65ff 100644 (file)
@@ -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",