Samba 3.0.32 - oplock code
Jeremy Allison
jra at samba.org
Thu Dec 11 01:09:39 GMT 2008
On Wed, Dec 10, 2008 at 03:53:56PM -0800, Jeremy Allison wrote:
> On Wed, Dec 10, 2008 at 05:20:05PM +0200, Itay Dar wrote:
> > Hello,
> > I am reading the oplock granting code in samba 3.0.32 And I have a
> > question, if I may.
> >
> > It seems to me that if someone is asking for an exclusive lock or level
> > two oplock when all other share lock owners of the files don't have any
> > oplock (not even a fake level two) he will be granted a level two
> > oplock.
> > But if one of the other clients will perform a write operation or
> > anything else, he wont notify the level oplock 2 holder on the async
> > oplock break needed.
> >
> > I have checked samba . 3.0.20, and it seems no oplock is granted in that
> > case in the old version.
> >
> > I think there are two possibilities for a solution, send everyone else a
> > request two make fake level two oplock upgrade or just deny the oplock
> > request from the client.
> > I have a patch for the second suggestion.
> >
> > Am I right ?
>
> I'd like to see your patch to be sure, but this sounds
> very plausible. Could you send it to the list please ?
Does this patch fit what you're talking about (created
for 3.2.x and above, but should be similar in 3.0.x) ?
Jeremy
-------------- next part --------------
diff --git a/source/smbd/open.c b/source/smbd/open.c
index dde273d..b0cdb3d 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -741,15 +741,15 @@ static bool delay_for_oplocks(struct share_mode_lock *lck,
BATCH_OPLOCK_TYPE(exclusive->op_type) : True;
}
- if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
- /* We can at most grant level2 as there are other
- * level2 or NO_OPLOCK entries. */
- fsp->oplock_type = LEVEL_II_OPLOCK;
- }
-
- if ((fsp->oplock_type == NO_OPLOCK) && have_level2) {
- /* Store a level2 oplock, but don't tell the client */
- fsp->oplock_type = FAKE_LEVEL_II_OPLOCK;
+ if (have_level2) {
+ if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
+ /* We can at most grant level2 as there are other
+ * level2 entries. */
+ fsp->oplock_type = LEVEL_II_OPLOCK;
+ } else if (fsp->oplock_type == NO_OPLOCK) {
+ /* Store a level2 oplock, but don't tell the client */
+ fsp->oplock_type = FAKE_LEVEL_II_OPLOCK;
+ }
}
if (!delay_it) {
More information about the samba-technical
mailing list