From 59917521e9d811efe7b424d49f03fb972ee0a119 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 8 Mar 2008 09:12:09 +0100 Subject: opendb: pass down a pointer to the fd in odb_open_file() This prepares kernel oplock support. metze (This used to be commit 9db9b6d85d80a8aaa8bd432afaef9bb634d7364d) --- source4/ntvfs/common/opendb.c | 4 ++-- source4/ntvfs/common/opendb.h | 2 +- source4/ntvfs/common/opendb_tdb.c | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/common') diff --git a/source4/ntvfs/common/opendb.c b/source4/ntvfs/common/opendb.c index 1cc077137c..676706e03f 100644 --- a/source4/ntvfs/common/opendb.c +++ b/source4/ntvfs/common/opendb.c @@ -97,11 +97,11 @@ _PUBLIC_ DATA_BLOB odb_get_key(TALLOC_CTX *mem_ctx, struct odb_lock *lck) */ _PUBLIC_ NTSTATUS odb_open_file(struct odb_lock *lck, void *file_handle, const char *path, - bool allow_level_II_oplock, + int *fd, bool allow_level_II_oplock, uint32_t oplock_level, uint32_t *oplock_granted) { return ops->odb_open_file(lck, file_handle, path, - allow_level_II_oplock, + fd, allow_level_II_oplock, oplock_level, oplock_granted); } diff --git a/source4/ntvfs/common/opendb.h b/source4/ntvfs/common/opendb.h index fb3223aea9..045476337a 100644 --- a/source4/ntvfs/common/opendb.h +++ b/source4/ntvfs/common/opendb.h @@ -27,7 +27,7 @@ struct opendb_ops { DATA_BLOB (*odb_get_key)(TALLOC_CTX *mem_ctx, struct odb_lock *lck); NTSTATUS (*odb_open_file)(struct odb_lock *lck, void *file_handle, const char *path, - bool allow_level_II_oplock, + int *fd, bool allow_level_II_oplock, uint32_t oplock_level, uint32_t *oplock_granted); NTSTATUS (*odb_open_file_pending)(struct odb_lock *lck, void *private); NTSTATUS (*odb_close_file)(struct odb_lock *lck, void *file_handle, diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index 17fcdfbbb4..9b4a5bfa9f 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -442,7 +442,7 @@ static NTSTATUS odb_tdb_open_can_internal(struct odb_context *odb, */ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle, const char *path, - bool allow_level_II_oplock, + int *fd, bool allow_level_II_oplock, uint32_t oplock_level, uint32_t *oplock_granted) { struct odb_context *odb = lck->odb; @@ -504,6 +504,7 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, } lck->can_open.e->file_handle = file_handle; + lck->can_open.e->fd = fd; lck->can_open.e->allow_level_II_oplock = allow_level_II_oplock; lck->can_open.e->oplock_level = oplock_level; @@ -800,6 +801,7 @@ static NTSTATUS odb_tdb_can_open(struct odb_lock *lck, lck->can_open.e->server = odb->ntvfs_ctx->server_id; lck->can_open.e->file_handle = NULL; + lck->can_open.e->fd = NULL; lck->can_open.e->stream_id = stream_id; lck->can_open.e->share_access = share_access; lck->can_open.e->access_mask = access_mask; -- cgit From 49c86b73bf1babf151835d4afdbfb132f2e2c34e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 7 Mar 2008 12:21:11 +0100 Subject: opendb_tdb: use sys_lease to setup kernel oplocks metze (This used to be commit e473068bddfaa9028ab8ee49291035313b35fed3) --- source4/ntvfs/common/config.mk | 5 ++++- source4/ntvfs/common/opendb_tdb.c | 46 ++++++++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 9 deletions(-) (limited to 'source4/ntvfs/common') diff --git a/source4/ntvfs/common/config.mk b/source4/ntvfs/common/config.mk index 2fc0942ed4..3963ebcdee 100644 --- a/source4/ntvfs/common/config.mk +++ b/source4/ntvfs/common/config.mk @@ -9,7 +9,10 @@ OBJ_FILES = \ opendb.o \ opendb_tdb.o \ notify.o -PUBLIC_DEPENDENCIES = NDR_OPENDB NDR_NOTIFY sys_notify share LIBDBWRAP +PUBLIC_DEPENDENCIES = \ + NDR_OPENDB NDR_NOTIFY \ + sys_notify sys_lease \ + share LIBDBWRAP PRIVATE_DEPENDENCIES = brlock_ctdb opendb_ctdb # End LIBRARY ntvfs_common ################################################ diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index 9b4a5bfa9f..be78e09958 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -49,11 +49,13 @@ #include "ntvfs/common/ntvfs_common.h" #include "cluster/cluster.h" #include "param/param.h" +#include "ntvfs/sysdep/sys_lease.h" struct odb_context { struct tdb_wrap *w; struct ntvfs_context *ntvfs_ctx; bool oplocks; + struct sys_lease_context *lease_ctx; }; /* @@ -72,6 +74,10 @@ struct odb_lock { } can_open; }; +static NTSTATUS odb_oplock_break_send(struct messaging_context *msg_ctx, + struct opendb_entry *e, + uint8_t level); + /* Open up the openfiles.tdb database. Close it down using talloc_free(). We need the messaging_ctx to allow for pending open @@ -98,6 +104,11 @@ static struct odb_context *odb_tdb_init(TALLOC_CTX *mem_ctx, /* leave oplocks disabled by default until the code is working */ odb->oplocks = lp_parm_bool(ntvfs_ctx->lp_ctx, NULL, "opendb", "oplocks", false); + odb->lease_ctx = sys_lease_context_create(ntvfs_ctx->config, odb, + ntvfs_ctx->event_ctx, + ntvfs_ctx->msg_ctx, + odb_oplock_break_send); + return odb; } @@ -491,23 +502,29 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, oplock_level = OPLOCK_NONE; } + lck->can_open.e->file_handle = file_handle; + lck->can_open.e->fd = fd; + lck->can_open.e->allow_level_II_oplock = allow_level_II_oplock; + lck->can_open.e->oplock_level = oplock_level; + + if (odb->lease_ctx && fd) { + NTSTATUS status; + status = sys_lease_setup(odb->lease_ctx, lck->can_open.e); + NT_STATUS_NOT_OK_RETURN(status); + } + if (oplock_granted) { - if (oplock_level == OPLOCK_EXCLUSIVE) { + if (lck->can_open.e->oplock_level == OPLOCK_EXCLUSIVE) { *oplock_granted = EXCLUSIVE_OPLOCK_RETURN; - } else if (oplock_level == OPLOCK_BATCH) { + } else if (lck->can_open.e->oplock_level == OPLOCK_BATCH) { *oplock_granted = BATCH_OPLOCK_RETURN; - } else if (oplock_level == OPLOCK_LEVEL_II) { + } else if (lck->can_open.e->oplock_level == OPLOCK_LEVEL_II) { *oplock_granted = LEVEL_II_OPLOCK_RETURN; } else { *oplock_granted = NO_OPLOCK_RETURN; } } - lck->can_open.e->file_handle = file_handle; - lck->can_open.e->fd = fd; - lck->can_open.e->allow_level_II_oplock = allow_level_II_oplock; - lck->can_open.e->oplock_level = oplock_level; - /* it doesn't conflict, so add it to the end */ lck->file.entries = talloc_realloc(lck, lck->file.entries, struct opendb_entry, @@ -570,6 +587,11 @@ static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle, if (lck->file.entries[i].delete_on_close) { lck->file.delete_on_close = true; } + if (odb->lease_ctx && lck->file.entries[i].fd) { + NTSTATUS status; + status = sys_lease_remove(odb->lease_ctx, &lck->file.entries[i]); + NT_STATUS_NOT_OK_RETURN(status); + } if (i < lck->file.num_entries-1) { memmove(lck->file.entries+i, lck->file.entries+i+1, (lck->file.num_entries - (i+1)) * @@ -623,6 +645,13 @@ static NTSTATUS odb_tdb_update_oplock(struct odb_lock *lck, void *file_handle, if (file_handle == lck->file.entries[i].file_handle && cluster_id_equal(&odb->ntvfs_ctx->server_id, &lck->file.entries[i].server)) { lck->file.entries[i].oplock_level = oplock_level; + + if (odb->lease_ctx && lck->file.entries[i].fd) { + NTSTATUS status; + status = sys_lease_update(odb->lease_ctx, &lck->file.entries[i]); + NT_STATUS_NOT_OK_RETURN(status); + } + break; } } @@ -833,5 +862,6 @@ static const struct opendb_ops opendb_tdb_ops = { void odb_tdb_init_ops(void) { + sys_lease_init(); odb_set_ops(&opendb_tdb_ops); } -- cgit From 71e2f7d2604932805762a841318cacc54cbc0b1c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 27 Mar 2008 10:11:48 +0100 Subject: opendb_tdb: enable oplocks per default metze (This used to be commit 225a9852eeee66f22a4135a660f18b70666c1c5f) --- source4/ntvfs/common/opendb_tdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/common') diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index be78e09958..fc05b342a8 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -102,7 +102,7 @@ static struct odb_context *odb_tdb_init(TALLOC_CTX *mem_ctx, odb->ntvfs_ctx = ntvfs_ctx; /* leave oplocks disabled by default until the code is working */ - odb->oplocks = lp_parm_bool(ntvfs_ctx->lp_ctx, NULL, "opendb", "oplocks", false); + odb->oplocks = lp_parm_bool(ntvfs_ctx->lp_ctx, NULL, "opendb", "oplocks", true); odb->lease_ctx = sys_lease_context_create(ntvfs_ctx->config, odb, ntvfs_ctx->event_ctx, -- cgit