summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-02-22 16:34:50 +0100
committerStefan Metzmacher <metze@samba.org>2008-02-26 09:32:58 +0100
commit348439e9301fa3b07f5263a6dabc61557a384179 (patch)
tree295d25ac165efdf6bd4080a28babeb500bba56bc
parent4ee328d7d26f1a86559993f6533b8a1e12a4c6a1 (diff)
downloadsamba-348439e9301fa3b07f5263a6dabc61557a384179.tar.gz
samba-348439e9301fa3b07f5263a6dabc61557a384179.tar.xz
samba-348439e9301fa3b07f5263a6dabc61557a384179.zip
pvfs_oplocks: add pvfs_break_level2_oplocks()
metze (This used to be commit e0837238b6b09143970f03b6a78201c3fe55f3cd)
-rw-r--r--source4/ntvfs/posix/pvfs_oplock.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/source4/ntvfs/posix/pvfs_oplock.c b/source4/ntvfs/posix/pvfs_oplock.c
index eff9ae1f1d..cf30ddbc59 100644
--- a/source4/ntvfs/posix/pvfs_oplock.c
+++ b/source4/ntvfs/posix/pvfs_oplock.c
@@ -198,3 +198,42 @@ NTSTATUS pvfs_oplock_release(struct ntvfs_module_context *ntvfs,
return NT_STATUS_OK;
}
+
+NTSTATUS pvfs_break_level2_oplocks(struct pvfs_file *f)
+{
+ struct pvfs_file_handle *h = f->handle;
+ struct odb_lock *olck;
+ NTSTATUS status;
+
+ if (h->oplock && h->oplock->level == OPLOCK_EXCLUSIVE) {
+ return NT_STATUS_OK;
+ }
+
+ olck = odb_lock(h, h->pvfs->odb_context, &h->odb_locking_key);
+ if (olck == NULL) {
+ DEBUG(0,("Unable to lock opendb for oplock update\n"));
+ return NT_STATUS_FOOBAR;
+ }
+
+ if (h->oplock && h->oplock->level == OPLOCK_BATCH) {
+ status = odb_update_oplock(olck, h, OPLOCK_LEVEL_II);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("Unable to update oplock level for '%s' - %s\n",
+ h->name->full_name, nt_errstr(status)));
+ talloc_free(olck);
+ return status;
+ }
+ }
+
+ status = odb_break_oplocks(olck);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("Unable to break level2 oplocks to none for '%s' - %s\n",
+ h->name->full_name, nt_errstr(status)));
+ talloc_free(olck);
+ return status;
+ }
+
+ talloc_free(olck);
+
+ return NT_STATUS_OK;
+}