s3:smbd: move global oplocks vars to smbd_server_connection
authorStefan Metzmacher <metze@samba.org>
Thu, 24 May 2012 21:15:08 +0000 (23:15 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 25 May 2012 07:05:34 +0000 (09:05 +0200)
metze

source3/smbd/globals.c
source3/smbd/globals.h
source3/smbd/oplock.c

index 196b6431095ae071a3d7771a63fa08432c41e01d..515a1e810d5a080fc152621e92d0b18b3f0f12ae 100644 (file)
@@ -93,9 +93,6 @@ struct vfs_init_function_entry *backends = NULL;
 char *sparse_buf = NULL;
 char *LastDir = NULL;
 
-/* Current number of oplocks we have outstanding. */
-int32_t exclusive_oplocks_open = 0;
-int32_t level_II_oplocks_open = 0;
 struct kernel_oplocks *koplocks = NULL;
 
 struct smbd_parent_context *am_parent = NULL;
index 24c21ffee4e7db1d4a262cf764a928d84bf244e1..f49cdbb473988447311cca2d938b8b3bc19f9f81 100644 (file)
@@ -108,9 +108,6 @@ extern struct vfs_init_function_entry *backends;
 extern char *sparse_buf;
 extern char *LastDir;
 
-/* Current number of oplocks we have outstanding. */
-extern int32_t exclusive_oplocks_open;
-extern int32_t level_II_oplocks_open;
 extern struct kernel_oplocks *koplocks;
 
 struct smbd_parent_context;
@@ -519,6 +516,12 @@ struct smbd_server_connection {
 
        uint64_t num_requests;
 
+       /* Current number of oplocks we have outstanding. */
+       struct {
+               int32_t exclusive_open;
+               int32_t level_II_open;
+       } oplocks;
+
        struct {
                struct fd_event *fde;
 
index b4e8c9be5a505fb5b2dcebba891e82ecfe2d132b..3cfc81291b91eb26297ba0ff157b8057ae8446b3 100644 (file)
@@ -53,7 +53,7 @@ void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp)
 
 bool set_file_oplock(files_struct *fsp, int oplock_type)
 {
-
+       struct smbd_server_connection *sconn = fsp->conn->sconn;
        bool use_kernel = lp_kernel_oplocks(SNUM(fsp->conn)) && koplocks;
 
        if (fsp->oplock_type == LEVEL_II_OPLOCK) {
@@ -75,9 +75,9 @@ bool set_file_oplock(files_struct *fsp, int oplock_type)
        fsp->oplock_type = oplock_type;
        fsp->sent_oplock_break = NO_BREAK_SENT;
        if (oplock_type == LEVEL_II_OPLOCK) {
-               level_II_oplocks_open++;
+               sconn->oplocks.level_II_open++;
        } else if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
-               exclusive_oplocks_open++;
+               sconn->oplocks.exclusive_open++;
        }
 
        DEBUG(5,("set_file_oplock: granted oplock on file %s, %s/%lu, "
@@ -95,6 +95,8 @@ bool set_file_oplock(files_struct *fsp, int oplock_type)
 
 void release_file_oplock(files_struct *fsp)
 {
+       struct smbd_server_connection *sconn = fsp->conn->sconn;
+
        if ((fsp->oplock_type != NO_OPLOCK) &&
            (fsp->oplock_type != FAKE_LEVEL_II_OPLOCK) &&
            koplocks) {
@@ -102,13 +104,13 @@ void release_file_oplock(files_struct *fsp)
        }
 
        if (fsp->oplock_type == LEVEL_II_OPLOCK) {
-               level_II_oplocks_open--;
+               sconn->oplocks.level_II_open--;
        } else if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
-               exclusive_oplocks_open--;
+               sconn->oplocks.exclusive_open--;
        }
 
-       SMB_ASSERT(exclusive_oplocks_open>=0);
-       SMB_ASSERT(level_II_oplocks_open>=0);
+       SMB_ASSERT(sconn->oplocks.exclusive_open>=0);
+       SMB_ASSERT(sconn->oplocks.level_II_open>=0);
 
        if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
                /* This doesn't matter for close. */
@@ -130,6 +132,8 @@ void release_file_oplock(files_struct *fsp)
 
 static void downgrade_file_oplock(files_struct *fsp)
 {
+       struct smbd_server_connection *sconn = fsp->conn->sconn;
+
        if (!EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
                DEBUG(0, ("trying to downgrade an already-downgraded oplock!\n"));
                return;
@@ -139,8 +143,8 @@ static void downgrade_file_oplock(files_struct *fsp)
                koplocks->ops->release_oplock(koplocks, fsp, LEVEL_II_OPLOCK);
        }
        fsp->oplock_type = LEVEL_II_OPLOCK;
-       exclusive_oplocks_open--;
-       level_II_oplocks_open++;
+       sconn->oplocks.exclusive_open--;
+       sconn->oplocks.level_II_open++;
        fsp->sent_oplock_break = NO_BREAK_SENT;
 }
 
@@ -265,7 +269,8 @@ static files_struct *initial_break_processing(
                dbgtext( "initial_break_processing: called for %s/%u\n",
                         file_id_string_tos(&id), (int)file_id);
                dbgtext( "Current oplocks_open (exclusive = %d, levelII = %d)\n",
-                       exclusive_oplocks_open, level_II_oplocks_open );
+                       sconn->oplocks.exclusive_open,
+                       sconn->oplocks.level_II_open);
        }
 
        /*