opendb: add odb_update_oplock() call
authorStefan Metzmacher <metze@samba.org>
Thu, 21 Feb 2008 15:12:27 +0000 (16:12 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 25 Feb 2008 10:51:17 +0000 (11:51 +0100)
metze

source/cluster/ctdb/opendb_ctdb.c
source/ntvfs/common/opendb.c
source/ntvfs/common/opendb.h
source/ntvfs/common/opendb_tdb.c

index f056e2171660b66a1577541d558582053c09124f..86dc1f50f11c6fd18d8aef6fd247c00a931adafd 100644 (file)
@@ -450,6 +450,19 @@ static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle)
        return odb_push_record(lck, &file);
 }
 
+/*
+  update the oplock level of the client
+*/
+static NTSTATUS odb_ctdb_update_oplock(struct odb_lock *lck, void *file_handle,
+                                      uint32_t oplock_level)
+{
+       /*
+        * as this file will went away and isn't used yet,
+        * copy the implementation from the tdb backend
+        * --metze
+        */
+       return NT_STATUS_FOOBAR;
+}
 
 /*
   remove a pending opendb entry
@@ -628,7 +641,8 @@ static const struct opendb_ops opendb_ctdb_ops = {
        .odb_rename              = odb_ctdb_rename,
        .odb_set_delete_on_close = odb_ctdb_set_delete_on_close,
        .odb_get_delete_on_close = odb_ctdb_get_delete_on_close,
-       .odb_can_open            = odb_ctdb_can_open
+       .odb_can_open            = odb_ctdb_can_open,
+       .odb_update_oplock       = odb_ctdb_update_oplock
 };
 
 
index f12f23817db80944c3fe175fed232c27b68e95de..4ac10806e13255cf0d45fe1985f8c8fd6155d6d7 100644 (file)
@@ -170,3 +170,9 @@ _PUBLIC_ NTSTATUS odb_can_open(struct odb_lock *lck,
 {
        return ops->odb_can_open(lck, share_access, create_options, access_mask);
 }
+
+_PUBLIC_ NTSTATUS odb_update_oplock(struct odb_lock *lck, void *file_handle,
+                                   uint32_t oplock_level)
+{
+       return ops->odb_update_oplock(lck, file_handle, oplock_level);
+}
index ccf6db27a04f56589935336e2b942d806d78e8ab..c34a07d6facf31d1e40114bf59af86ec967aa65d 100644 (file)
@@ -41,6 +41,8 @@ struct opendb_ops {
        NTSTATUS (*odb_can_open)(struct odb_lock *lck,
                                 uint32_t share_access, uint32_t create_options, 
                                 uint32_t access_mask);
+       NTSTATUS (*odb_update_oplock)(struct odb_lock *lck, void *file_handle,
+                                     uint32_t oplock_level);
 };
 
 struct opendb_oplock_break {
index 25f37f5e26af9618ca8d2d7a76f12fad22ec3b53..3d4a760e2e4adcb8d8e9aaa35e52d3571f586f07 100644 (file)
@@ -2,7 +2,8 @@
    Unix SMB/CIFS implementation.
 
    Copyright (C) Andrew Tridgell 2004
-   
+   Copyright (C) Stefan Metzmacher 2008
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
@@ -463,6 +464,45 @@ static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle)
        return odb_push_record(lck, &file);
 }
 
+/*
+  update the oplock level of the client
+*/
+static NTSTATUS odb_tdb_update_oplock(struct odb_lock *lck, void *file_handle,
+                                     uint32_t oplock_level)
+{
+       struct odb_context *odb = lck->odb;
+       struct opendb_file file;
+       int i;
+       NTSTATUS status;
+
+       status = odb_pull_record(lck, &file);
+       NT_STATUS_NOT_OK_RETURN(status);
+
+       /* find the entry, and update it */
+       for (i=0;i<file.num_entries;i++) {
+               if (file_handle == file.entries[i].file_handle &&
+                   cluster_id_equal(&odb->ntvfs_ctx->server_id, &file.entries[i].server)) {
+                       file.entries[i].oplock_level = oplock_level;
+                       break;
+               }
+       }
+
+       if (i == file.num_entries) {
+               return NT_STATUS_UNSUCCESSFUL;
+       }
+
+       /* send any pending notifications, removing them once sent */
+       for (i=0;i<file.num_pending;i++) {
+               messaging_send_ptr(odb->ntvfs_ctx->msg_ctx,
+                                  file.pending[i].server,
+                                  MSG_PVFS_RETRY_OPEN,
+                                  file.pending[i].notify_ptr);
+       }
+       file.num_pending = 0;
+
+       return odb_push_record(lck, &file);
+}
+
 
 /*
   remove a pending opendb entry
@@ -641,7 +681,8 @@ static const struct opendb_ops opendb_tdb_ops = {
        .odb_rename              = odb_tdb_rename,
        .odb_set_delete_on_close = odb_tdb_set_delete_on_close,
        .odb_get_delete_on_close = odb_tdb_get_delete_on_close,
-       .odb_can_open            = odb_tdb_can_open
+       .odb_can_open            = odb_tdb_can_open,
+       .odb_update_oplock       = odb_tdb_update_oplock
 };