Move the "oplock file with byte range locks" check to the correct place, where we...
authorJeremy Allison <jra@samba.org>
Fri, 4 Feb 2011 23:32:09 +0000 (15:32 -0800)
committerJeremy Allison <jra@samba.org>
Sat, 5 Feb 2011 00:18:14 +0000 (01:18 +0100)
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Sat Feb  5 01:18:14 CET 2011 on sn-devel-104

source3/smbd/open.c
source3/smbd/oplock.c

index f236243b37d22385ba814f600d381ba7e0424b9a..0ef2b3a90d976ea6fc404e58c2cf35377b2f42c4 100644 (file)
@@ -1011,6 +1011,17 @@ static bool delay_for_exclusive_oplocks(files_struct *fsp,
        return false;
 }
 
+static bool file_has_brlocks(files_struct *fsp)
+{
+       struct byte_range_lock *br_lck;
+
+       br_lck = brl_get_locks_readonly(fsp);
+       if (!br_lck)
+               return false;
+
+       return br_lck->num_locks > 0 ? true : false;
+}
+
 static void grant_fsp_oplock_type(files_struct *fsp,
                                int oplock_request,
                                bool got_level2_oplock,
@@ -1029,6 +1040,10 @@ static void grant_fsp_oplock_type(files_struct *fsp,
                DEBUG(10,("grant_fsp_oplock_type: oplock type 0x%x on file %s\n",
                        fsp->oplock_type, fsp_str_dbg(fsp)));
                return;
+       } else if (lp_locking(fsp->conn->params) && file_has_brlocks(fsp)) {
+               DEBUG(10,("grant_fsp_oplock_type: file %s has byte range locks\n",
+                       fsp_str_dbg(fsp)));
+               fsp->oplock_type = NO_OPLOCK;
        }
 
        if (is_stat_open(fsp->access_mask)) {
index c3c41d1c33955db20ea0e8d005531a5f03ad4202..a2ba0109aef93e1e2ec8169274bb4ff150f4f975 100644 (file)
@@ -52,17 +52,6 @@ void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp)
                           msg, MSG_SMB_KERNEL_BREAK_SIZE);
 }
 
-static bool file_has_brlocks(files_struct *fsp)
-{
-       struct byte_range_lock *br_lck;
-
-       br_lck = brl_get_locks_readonly(fsp);
-       if (!br_lck)
-               return false;
-
-       return br_lck->num_locks > 0 ? true : false;
-}
-
 /****************************************************************************
  Attempt to set an oplock on a file. Succeeds if kernel oplocks are
  disabled (just sets flags) and no byte-range locks in the file. Returns True
@@ -72,12 +61,6 @@ static bool file_has_brlocks(files_struct *fsp)
 bool set_file_oplock(files_struct *fsp, int oplock_type)
 {
        if (fsp->oplock_type == LEVEL_II_OPLOCK) {
-               if (lp_locking(fsp->conn->params) && file_has_brlocks(fsp)) {
-                       DEBUG(10, ("Refusing level2 oplock because of "
-                                  "byte-range locks on the file\n"));
-                       return false;
-               }
-
                if (koplocks &&
                    !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) {
                        DEBUG(10, ("Refusing level2 oplock, kernel oplocks "