opendb_tdb: grant level2 oplocks
authorStefan Metzmacher <metze@samba.org>
Fri, 22 Feb 2008 16:26:40 +0000 (17:26 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 26 Feb 2008 08:29:40 +0000 (09:29 +0100)
metze
(This used to be commit 57f1b9d11cfcac3b5fdee1ad9e4ba81d0859c8dc)

source4/ntvfs/common/opendb_tdb.c

index dd2fb138d65c74940efd125c89ec2484cde2a19b..33105324069d787190714a40e303bfaa21356254 100644 (file)
@@ -367,18 +367,32 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle,
        }
 
        /*
-         possibly grant an exclusive or batch oplock if this is the only client
-         with the file open. We don't yet grant levelII oplocks.
+         possibly grant an exclusive, batch or level2 oplock
        */
-       if (oplock_granted != NULL) {
-               if ((oplock_level == OPLOCK_BATCH ||
-                    oplock_level == OPLOCK_EXCLUSIVE) &&
-                   file.num_entries == 0) {
-                       (*oplock_granted) = oplock_level;
+       if (oplock_granted) {
+               if (oplock_level == OPLOCK_EXCLUSIVE) {
+                       if (file.num_entries == 0) {
+                               e.oplock_level  = OPLOCK_EXCLUSIVE;
+                               *oplock_granted = EXCLUSIVE_OPLOCK_RETURN;
+                       } else {
+                               e.oplock_level  = OPLOCK_NONE;
+                               *oplock_granted = NO_OPLOCK_RETURN;
+                       }
+               } else if (oplock_level == OPLOCK_BATCH) {
+                       if (file.num_entries == 0) {
+                               e.oplock_level  = OPLOCK_BATCH;
+                               *oplock_granted = BATCH_OPLOCK_RETURN;
+                       } else {
+                               e.oplock_level  = OPLOCK_LEVEL_II;
+                               *oplock_granted = LEVEL_II_OPLOCK_RETURN;
+                       }
+               } else if (oplock_level == OPLOCK_LEVEL_II) {
+                       e.oplock_level  = OPLOCK_LEVEL_II;
+                       *oplock_granted = LEVEL_II_OPLOCK_RETURN;
                } else {
-                       (*oplock_granted) = OPLOCK_NONE;
+                       e.oplock_level  = OPLOCK_NONE;
+                       *oplock_granted = NO_OPLOCK_RETURN;
                }
-               e.oplock_level = (*oplock_granted);
        }
 
        /* it doesn't conflict, so add it to the end */