s3:smbd only care about missing level2 support if kernel oplocks are enabled
authorChristian Ambach <ambi@samba.org>
Fri, 30 Mar 2012 14:11:08 +0000 (16:11 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 11 Apr 2012 20:45:21 +0000 (22:45 +0200)
if kernel oplocks are not enabled for that share, we can grant level2 oplocks

Signed-off-by: Jeremy Allison <jra@samba.org>
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Wed Apr 11 22:45:21 CEST 2012 on sn-devel-104

source3/smbd/oplock.c

index c619edc5b9d39090562285384afb1ca25276c344..b181fb79ba077638f3ecbfd863721a1b8d065bba 100644 (file)
@@ -62,8 +62,11 @@ void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp)
 
 bool set_file_oplock(files_struct *fsp, int oplock_type)
 {
+
+       bool use_kernel = lp_kernel_oplocks(SNUM(fsp->conn)) && koplocks;
+
        if (fsp->oplock_type == LEVEL_II_OPLOCK) {
-               if (koplocks &&
+               if (use_kernel &&
                    !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) {
                        DEBUG(10, ("Refusing level2 oplock, kernel oplocks "
                                   "don't support them\n"));
@@ -73,7 +76,7 @@ bool set_file_oplock(files_struct *fsp, int oplock_type)
 
        if ((fsp->oplock_type != NO_OPLOCK) &&
            (fsp->oplock_type != FAKE_LEVEL_II_OPLOCK) &&
-           koplocks &&
+           use_kernel &&
            !koplocks->ops->set_oplock(koplocks, fsp, oplock_type)) {
                return False;
        }
@@ -484,6 +487,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
        struct share_mode_entry msg;
        files_struct *fsp;
        bool break_to_level2 = False;
+       bool use_kernel;
        struct smbd_server_connection *sconn =
                talloc_get_type_abort(private_data,
                struct smbd_server_connection);
@@ -543,9 +547,11 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
                return;
        }
 
-       if ((global_client_caps & CAP_LEVEL_II_OPLOCKS) && 
+       use_kernel = lp_kernel_oplocks(SNUM(fsp->conn)) && koplocks;
+
+       if ((global_client_caps & CAP_LEVEL_II_OPLOCKS) &&
            !(msg.op_type & FORCE_OPLOCK_BREAK_TO_NONE) &&
-           !(koplocks && !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) &&
+           !(use_kernel && !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) &&
            lp_level2_oplocks(SNUM(fsp->conn))) {
                break_to_level2 = True;
        }