smbd: Put "have_read_oplocks" into brlock.tdb
authorVolker Lendecke <vl@samba.org>
Wed, 11 Sep 2013 12:48:14 +0000 (12:48 +0000)
committerJeremy Allison <jra@samba.org>
Mon, 14 Oct 2013 23:52:29 +0000 (01:52 +0200)
commiteb50c18c4a2d0caa3b8d21b2e1b536adc8dc0276
tree508858b344654e4f59ecfff0c8977b58f05e438e
parent54019ca9aaf9d200c60e8d234259c439875c85f7
smbd: Put "have_read_oplocks" into brlock.tdb

This implements an idea by metze: Right now Samba does not grant level2
oplocks where it should: After an initial no-oplock open that has been
written to, we don't have the FAKE_LEVEL2_OPLOCK entry in locking.tdb
around anymore, this downgraded to NO_OPLOCK. Windows in this case will
grant level2 if being asked, we don't.  Part of the reason for this
is that we don't have a proper mechanism to communicate the fact that
level2 needs to be broken to other smbds. Metze's insight was that we
have to look into brlock.tdb for every write anyway, so this might be
the right place to store this information.

My first reaction was that this is really hackish, but on further thought
this is not. oplocks depend on brlocks anyway, and we have the proper
mechanisms in place for brlocks.

The format for this change is to add one byte to the end of the brlock.tdb
record with value 1 if we have level2 oplocks around. Thus this patch
effectively reverts 8f41142 which I discovered while writing this
change. We now legally have unaligned records.

We can certainly talk about the format, but I'm not yet convinced we
need an idl for this yet. This is a potentially very hot code path,
and ndr marshalling has a cost.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/brlock.c
source3/locking/proto.h