is_locked optimization
Nadav Danieli
nadavd at exanet.com
Thu Dec 2 22:17:55 GMT 2004
Oops, sorry, forgot to attach the diff :-)
On Fri, 2004-12-03 at 00:09, Nadav Danieli wrote:
> Hello all,
>
> When reading/writing file with locking and strict locking (default)
> enabled, is_locked is called. I have very little knowledge about tdb
> overhead, but it seems that if oplock is granted, unnecessary (to me,)
> to call brl_locktest.
> Attached is a suggested change for is_locked in cases an oplock is
> granted.
> I would like to hear any opinion regarding this change, and of course,
> if it is wrong.
>
> Regards,
>
> Nadav Danieli
-------------- next part --------------
--- source/locking/locking.c 2004-11-16 05:03:30.000000000 +0200
+++ source/locking/locking.new.c 2004-12-02 22:08:49.000000000 +0200
@@ -80,9 +80,23 @@
if (!lp_locking(snum) || !lp_strict_locking(snum))
return(False);
- ret = !brl_locktest(fsp->dev, fsp->inode, fsp->fnum,
- global_smbpid, sys_getpid(), conn->cnum,
- offset, count, lock_type, check_self);
+ do {
+ if (!check_self) {
+ if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) &&
+ (lock_type == READ_LOCK || lock_type == WRITE_LOCK)) {
+ ret = 0;
+ break;
+ }
+ if (LEVEL_II_OPLOCK_TYPE(fsp->oplock_type) &&
+ (lock_type == READ_LOCK)) {
+ ret = 0;
+ break;
+ }
+ }
+ ret = !brl_locktest(fsp->dev, fsp->inode, fsp->fnum,
+ global_smbpid, sys_getpid(), conn->cnum,
+ offset, count, lock_type, check_self);
+ } while ( 0 );
DEBUG(10,("is_locked: brl start=%.0f len=%.0f %s for file %s\n",
(double)offset, (double)count, ret ? "locked" : "unlocked",
More information about the samba-technical
mailing list