[SCM] Samba Shared Repository - branch v4-0-test updated - release-4-0-0alpha2-1006-gdf576d6

Stefan Metzmacher metze at samba.org
Mon Feb 25 11:50:32 GMT 2008


The branch, v4-0-test has been updated
       via  df576d69c6981a4879a0e9447069fcfacb3588db (commit)
       via  49402007f6e9e02a29792344c088e40d1a9b7acf (commit)
       via  11f35a2a4d383b506ced35ba06120f9531bac70c (commit)
      from  438032e12f3040fbb58488ca537e4d8da39b6124 (commit)

http://gitweb.samba.org/?samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit df576d69c6981a4879a0e9447069fcfacb3588db
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Feb 21 16:12:27 2008 +0100

    opendb: add odb_update_oplock() call
    
    metze

commit 49402007f6e9e02a29792344c088e40d1a9b7acf
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Feb 21 12:20:31 2008 +0100

    opendb: send also the oplock break level on MSG_NTVFS_OPLOCK_BREAK
    
    metze

commit 11f35a2a4d383b506ced35ba06120f9531bac70c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 22 10:18:13 2008 +0100

    opendb: add odb_get_key() function to get the key back from a struct odb_lock
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 source/cluster/ctdb/opendb_ctdb.c |   27 ++++++++++++-
 source/ntvfs/common/opendb.c      |   10 +++++
 source/ntvfs/common/opendb.h      |    7 +++
 source/ntvfs/common/opendb_tdb.c  |   80 +++++++++++++++++++++++++++++++++---
 4 files changed, 116 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/cluster/ctdb/opendb_ctdb.c b/source/cluster/ctdb/opendb_ctdb.c
index aaab3aa..86dc1f5 100644
--- a/source/cluster/ctdb/opendb_ctdb.c
+++ b/source/cluster/ctdb/opendb_ctdb.c
@@ -133,6 +133,16 @@ static struct odb_lock *odb_ctdb_lock(TALLOC_CTX *mem_ctx,
 	return lck;
 }
 
+static DATA_BLOB odb_ctdb_get_key(TALLOC_CTX *mem_ctx, struct odb_lock *lck)
+{
+	/*
+	 * as this file will went away and isn't used yet,
+	 * copy the implementation from the tdb backend
+	 * --metze
+	 */
+	return data_blob_const(NULL, 0);
+}
+
 /*
   determine if two odb_entry structures conflict
 
@@ -440,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
@@ -610,6 +633,7 @@ static NTSTATUS odb_ctdb_can_open(struct odb_lock *lck,
 static const struct opendb_ops opendb_ctdb_ops = {
 	.odb_init                = odb_ctdb_init,
 	.odb_lock                = odb_ctdb_lock,
+	.odb_get_key             = odb_ctdb_get_key,
 	.odb_open_file           = odb_ctdb_open_file,
 	.odb_open_file_pending   = odb_ctdb_open_file_pending,
 	.odb_close_file          = odb_ctdb_close_file,
@@ -617,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
 };
 
 
diff --git a/source/ntvfs/common/opendb.c b/source/ntvfs/common/opendb.c
index 4826ca5..4ac1080 100644
--- a/source/ntvfs/common/opendb.c
+++ b/source/ntvfs/common/opendb.c
@@ -81,6 +81,10 @@ _PUBLIC_ struct odb_lock *odb_lock(TALLOC_CTX *mem_ctx,
 	return ops->odb_lock(mem_ctx, odb, file_key);
 }
 
+_PUBLIC_ DATA_BLOB odb_get_key(TALLOC_CTX *mem_ctx, struct odb_lock *lck)
+{
+	return ops->odb_get_key(mem_ctx, lck);
+}
 
 /*
   register an open file in the open files database. This implements the share_access
@@ -166,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);
+}
diff --git a/source/ntvfs/common/opendb.h b/source/ntvfs/common/opendb.h
index 231ae3d..c34a07d 100644
--- a/source/ntvfs/common/opendb.h
+++ b/source/ntvfs/common/opendb.h
@@ -24,6 +24,7 @@ struct opendb_ops {
 					struct ntvfs_context *ntvfs_ctx);
 	struct odb_lock *(*odb_lock)(TALLOC_CTX *mem_ctx,
 				     struct odb_context *odb, DATA_BLOB *file_key);
+	DATA_BLOB (*odb_get_key)(TALLOC_CTX *mem_ctx, struct odb_lock *lck);
 	NTSTATUS (*odb_open_file)(struct odb_lock *lck, void *file_handle,
 				  uint32_t stream_id, uint32_t share_access, 
 				  uint32_t access_mask, bool delete_on_close,
@@ -40,8 +41,14 @@ 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 {
+	void *file_handle;
+	uint8_t level;
+};
 
 void odb_set_ops(const struct opendb_ops *new_ops);
 void odb_tdb_init_ops(void);
diff --git a/source/ntvfs/common/opendb_tdb.c b/source/ntvfs/common/opendb_tdb.c
index abd9ca7..3d4a760 100644
--- a/source/ntvfs/common/opendb_tdb.c
+++ b/source/ntvfs/common/opendb_tdb.c
@@ -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
@@ -134,6 +135,12 @@ static struct odb_lock *odb_tdb_lock(TALLOC_CTX *mem_ctx,
 	return lck;
 }
 
+static DATA_BLOB odb_tdb_get_key(TALLOC_CTX *mem_ctx, struct odb_lock *lck)
+{
+	return data_blob_talloc(mem_ctx, lck->key.dptr, lck->key.dsize);
+}
+
+
 /*
   determine if two odb_entry structures conflict
 
@@ -253,12 +260,28 @@ static NTSTATUS odb_push_record(struct odb_lock *lck, struct opendb_file *file)
 /*
   send an oplock break to a client
 */
-static NTSTATUS odb_oplock_break_send(struct odb_context *odb, struct opendb_entry *e)
+static NTSTATUS odb_oplock_break_send(struct odb_context *odb,
+				      struct opendb_entry *e,
+				      uint8_t level)
 {
+	NTSTATUS status;
+	struct opendb_oplock_break op_break;
+	DATA_BLOB blob;
+
+	ZERO_STRUCT(op_break);
+
 	/* tell the server handling this open file about the need to send the client
 	   a break */
-	return messaging_send_ptr(odb->ntvfs_ctx->msg_ctx, e->server, 
-				  MSG_NTVFS_OPLOCK_BREAK, e->file_handle);
+	op_break.file_handle	= e->file_handle;
+	op_break.level		= level;
+
+	blob = data_blob_const(&op_break, sizeof(op_break));
+
+	status = messaging_send(odb->ntvfs_ctx->msg_ctx, e->server,
+				MSG_NTVFS_OPLOCK_BREAK, &blob);
+	NT_STATUS_NOT_OK_RETURN(status);
+
+	return NT_STATUS_OK;
 }
 
 /*
@@ -312,7 +335,8 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle,
 			   break request and suspending this call
 			   until the break is acknowledged or the file
 			   is closed */
-			odb_oplock_break_send(odb, &file.entries[i]);
+			odb_oplock_break_send(odb, &file.entries[i],
+					      OPLOCK_BREAK_TO_LEVEL_II/*TODO*/);
 			return NT_STATUS_OPLOCK_NOT_GRANTED;
 		}
 	}
@@ -336,7 +360,8 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle,
 	   exclusive oplocks afterwards. */
 	for (i=0;i<file.num_entries;i++) {
 		if (file.entries[i].oplock_level == OPLOCK_EXCLUSIVE) {
-			odb_oplock_break_send(odb, &file.entries[i]);
+			odb_oplock_break_send(odb, &file.entries[i],
+					      OPLOCK_BREAK_TO_NONE/*TODO*/);
 			return NT_STATUS_OPLOCK_NOT_GRANTED;
 		}
 	}
@@ -439,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
@@ -609,6 +673,7 @@ static NTSTATUS odb_tdb_can_open(struct odb_lock *lck,
 static const struct opendb_ops opendb_tdb_ops = {
 	.odb_init                = odb_tdb_init,
 	.odb_lock                = odb_tdb_lock,
+	.odb_get_key             = odb_tdb_get_key,
 	.odb_open_file           = odb_tdb_open_file,
 	.odb_open_file_pending   = odb_tdb_open_file_pending,
 	.odb_close_file          = odb_tdb_close_file,
@@ -616,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
 };
 
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list