From f94008e45a15666439766488edf84b21a86111ee Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Feb 2008 16:30:13 +0100 Subject: opendb: add odb_break_oplocks() function This send breaks to none to all level2 holders metze (This used to be commit bd3654500b14e4ed8d4a8bb25ff9da5035a16a8b) --- source4/cluster/ctdb/opendb_ctdb.c | 13 ++++++++++++- source4/ntvfs/common/opendb.c | 5 +++++ source4/ntvfs/common/opendb.h | 1 + source4/ntvfs/common/opendb_tdb.c | 40 +++++++++++++++++++++++++++++++++++++- 4 files changed, 57 insertions(+), 2 deletions(-) (limited to 'source4') diff --git a/source4/cluster/ctdb/opendb_ctdb.c b/source4/cluster/ctdb/opendb_ctdb.c index 86dc1f50f1..915b760424 100644 --- a/source4/cluster/ctdb/opendb_ctdb.c +++ b/source4/cluster/ctdb/opendb_ctdb.c @@ -464,6 +464,16 @@ static NTSTATUS odb_ctdb_update_oplock(struct odb_lock *lck, void *file_handle, return NT_STATUS_FOOBAR; } +static NTSTATUS odb_ctdb_break_oplocks(struct odb_lock *lck) +{ + /* + * 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 */ @@ -642,7 +652,8 @@ static const struct opendb_ops opendb_ctdb_ops = { .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_update_oplock = odb_ctdb_update_oplock + .odb_update_oplock = odb_ctdb_update_oplock, + .odb_break_oplocks = odb_ctdb_break_oplocks }; diff --git a/source4/ntvfs/common/opendb.c b/source4/ntvfs/common/opendb.c index 4ac10806e1..3f5d7210be 100644 --- a/source4/ntvfs/common/opendb.c +++ b/source4/ntvfs/common/opendb.c @@ -176,3 +176,8 @@ _PUBLIC_ NTSTATUS odb_update_oplock(struct odb_lock *lck, void *file_handle, { return ops->odb_update_oplock(lck, file_handle, oplock_level); } + +_PUBLIC_ NTSTATUS odb_break_oplocks(struct odb_lock *lck) +{ + return ops->odb_break_oplocks(lck); +} diff --git a/source4/ntvfs/common/opendb.h b/source4/ntvfs/common/opendb.h index c34a07d6fa..c46390446c 100644 --- a/source4/ntvfs/common/opendb.h +++ b/source4/ntvfs/common/opendb.h @@ -43,6 +43,7 @@ struct opendb_ops { uint32_t access_mask); NTSTATUS (*odb_update_oplock)(struct odb_lock *lck, void *file_handle, uint32_t oplock_level); + NTSTATUS (*odb_break_oplocks)(struct odb_lock *lck); }; struct opendb_oplock_break { diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index 3d4a760e2e..dd2fb138d6 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -503,6 +503,43 @@ static NTSTATUS odb_tdb_update_oplock(struct odb_lock *lck, void *file_handle, return odb_push_record(lck, &file); } +/* + send oplocks breaks to none to all level2 holders +*/ +static NTSTATUS odb_tdb_break_oplocks(struct odb_lock *lck) +{ + struct odb_context *odb = lck->odb; + NTSTATUS status; + struct opendb_file file; + int i; + bool modified = true; + + status = odb_pull_record(lck, &file); + if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { + return NT_STATUS_OK; + } + NT_STATUS_NOT_OK_RETURN(status); + + /* see if anyone has an oplock, which we need to break */ + for (i=0;i