summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2009-02-03 15:40:23 -0800
committerTim Prouty <tprouty@samba.org>2009-02-09 23:47:45 -0800
commit17eba16bad9b20518a5d336bc751e749a587ec68 (patch)
tree6c49a7586bb5efc58f418b0d45b0177e72ff7f13 /source3/smbd
parentc6f1f055fdeee29ad7c5b2ae9909e8f1b1a7daec (diff)
downloadsamba-17eba16bad9b20518a5d336bc751e749a587ec68.tar.gz
samba-17eba16bad9b20518a5d336bc751e749a587ec68.tar.bz2
samba-17eba16bad9b20518a5d336bc751e749a587ec68.zip
s3 oplocks: Add capabilites flags field to the kernel_oplocks struct
Here is a short description for each of the new capability flags: KOPLOCKS_LEVEL2_SUPPORTED: Level 2 oplocks are supported natively in the kernel. KOPLOCKS_DEFERRED_OPEN_NOTIFICATION: The kernel notifies deferred openers when they can retry the open. KOPLOCKS_TIMEOUT_NOTIFICATION: The kernel notifies smbds when an oplock break times out. KOPLOCKS_OPLOCK_BROKEN_NOTIFICATION: The kernel notifies smbds when an oplock is broken.
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/close.c4
-rw-r--r--source3/smbd/oplock.c30
2 files changed, 32 insertions, 2 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 2fb8ec2bb5..e484fa8e01 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -134,6 +134,10 @@ static NTSTATUS close_filestruct(files_struct *fsp)
static void notify_deferred_opens(struct share_mode_lock *lck)
{
int i;
+
+ if (!should_notify_deferred_opens()) {
+ return;
+ }
for (i=0; i<lck->num_share_modes; i++) {
struct share_mode_entry *e = &lck->share_modes[i];
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 4c84fd41ed..a6ec9cfa2d 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -188,6 +188,15 @@ bool downgrade_oplock(files_struct *fsp)
return ret;
}
+/*
+ * Some kernel oplock implementations handle the notification themselves.
+ */
+bool should_notify_deferred_opens()
+{
+ return !(koplocks &&
+ (koplocks->flags & KOPLOCKS_DEFERRED_OPEN_NOTIFICATION));
+}
+
/****************************************************************************
Set up an oplock break message.
****************************************************************************/
@@ -306,6 +315,15 @@ static void oplock_timeout_handler(struct event_context *ctx,
static void add_oplock_timeout_handler(files_struct *fsp)
{
+ /*
+ * If kernel oplocks already notifies smbds when an oplock break times
+ * out, just return.
+ */
+ if (koplocks &&
+ (koplocks->flags & KOPLOCKS_TIMEOUT_NOTIFICATION)) {
+ return;
+ }
+
if (fsp->oplock_timeout != NULL) {
DEBUG(0, ("Logic problem -- have an oplock event hanging "
"around\n"));
@@ -491,8 +509,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
if ((global_client_caps & CAP_LEVEL_II_OPLOCKS) &&
!(msg.op_type & FORCE_OPLOCK_BREAK_TO_NONE) &&
- !koplocks && /* NOTE: we force levelII off for kernel oplocks -
- * this will change when it is supported */
+ !(koplocks && !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) &&
lp_level2_oplocks(SNUM(fsp->conn))) {
break_to_level2 = True;
}
@@ -613,6 +630,15 @@ void reply_to_oplock_break_requests(files_struct *fsp)
{
int i;
+ /*
+ * If kernel oplocks already notifies smbds when oplocks are
+ * broken/removed, just return.
+ */
+ if (koplocks &&
+ (koplocks->flags & KOPLOCKS_OPLOCK_BROKEN_NOTIFICATION)) {
+ return;
+ }
+
for (i=0; i<fsp->num_pending_break_messages; i++) {
struct share_mode_entry *e = &fsp->pending_break_messages[i];
char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE];