From c418e94dfec2ff4486e9ca84e6bba280e9987810 Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Fri, 30 Mar 2012 15:31:19 +0200 Subject: [PATCH 1/5] s3:param convert kernel oplocks to share parameter Signed-off-by: Jeremy Allison --- source3/include/proto.h | 2 +- source3/param/loadparm.c | 14 ++++++-------- source3/smbd/oplock.c | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 28b58b2..8acb8d1 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1503,7 +1503,6 @@ bool lp_client_plaintext_auth(void); bool lp_client_lanman_auth(void); bool lp_client_ntlmv2_auth(void); bool lp_host_msdfs(void); -bool lp_kernel_oplocks(void); bool lp_enhanced_browsing(void); bool lp_use_mmap(void); bool lp_unix_extensions(void); @@ -1633,6 +1632,7 @@ int lp_strict_locking(const struct share_params *p ); bool lp_posix_locking(const struct share_params *p ); bool lp_share_modes(int ); bool lp_oplocks(int ); +bool lp_kernel_oplocks(int ); bool lp_level2_oplocks(int ); bool lp_onlyuser(int ); bool lp_manglednames(const struct share_params *p ); diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 6ad2452..de57a3b 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -331,7 +331,6 @@ struct global { bool bNTStatusSupport; bool bStatCache; int iMaxStatCacheSize; - bool bKernelOplocks; bool bAllowTrustedDomains; bool bLanmanAuth; bool bNTLMAuth; @@ -487,6 +486,7 @@ struct service { bool bPosixLocking; bool bShareModes; bool bOpLocks; + bool bKernelOplocks; bool bLevel2OpLocks; bool bOnlyUser; bool bMangledNames; @@ -632,6 +632,7 @@ static struct service sDefault = { True, /* bPosixLocking */ True, /* bShareModes */ True, /* bOpLocks */ + True, /* bKernelOplocks */ True, /* bLevel2OpLocks */ False, /* bOnlyUser */ True, /* bMangledNames */ @@ -3601,11 +3602,11 @@ static struct parm_struct parm_table[] = { { .label = "kernel oplocks", .type = P_BOOL, - .p_class = P_GLOBAL, - .ptr = &Globals.bKernelOplocks, + .p_class = P_LOCAL, + .ptr = &sDefault.bKernelOplocks, .special = NULL, .enum_list = NULL, - .flags = FLAG_ADVANCED | FLAG_GLOBAL, + .flags = FLAG_ADVANCED | FLAG_SHARE, }, { .label = "locking", @@ -5412,9 +5413,6 @@ static void init_globals(bool reinit_globals) Globals.bDNSproxy = True; - /* this just means to use them if they exist */ - Globals.bKernelOplocks = True; - Globals.bAllowTrustedDomains = True; string_set(&Globals.szIdmapBackend, "tdb"); Globals.bIdmapReadOnly = false; @@ -5822,7 +5820,6 @@ FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth) FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth) FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth) FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs) -FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks) FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing) FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap) FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions) @@ -5989,6 +5986,7 @@ FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking) FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking) FN_LOCAL_BOOL(lp_share_modes, bShareModes) FN_LOCAL_BOOL(lp_oplocks, bOpLocks) +FN_LOCAL_BOOL(lp_kernel_oplocks, bKernelOplocks) FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks) FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser) FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames) diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 087d6ef..072d487 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -932,7 +932,7 @@ bool init_oplocks(struct messaging_context *msg_ctx) messaging_register(msg_ctx, NULL, MSG_SMB_OPEN_RETRY, process_open_retry_message); - if (lp_kernel_oplocks()) { + if (lp_kernel_oplocks(-1)) { #if HAVE_KERNEL_OPLOCKS_IRIX koplocks = irix_init_kernel_oplocks(NULL); #elif HAVE_KERNEL_OPLOCKS_LINUX -- 1.7.1 From aef682fbeeb0850ef39d97ede05de2c218b4ac4b Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Fri, 30 Mar 2012 16:11:37 +0200 Subject: [PATCH 2/5] docs: update kernel oplocks documentation Signed-off-by: Jeremy Allison --- docs-xml/smbdotconf/locking/kerneloplocks.xml | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs-xml/smbdotconf/locking/kerneloplocks.xml b/docs-xml/smbdotconf/locking/kerneloplocks.xml index c4f12b9..9ac7256 100644 --- a/docs-xml/smbdotconf/locking/kerneloplocks.xml +++ b/docs-xml/smbdotconf/locking/kerneloplocks.xml @@ -1,11 +1,13 @@ For UNIXes that support kernel based (currently only IRIX and the Linux 2.4 kernel), this parameter - allows the use of them to be turned on or off. + allows the use of them to be turned on or off. However, this disables + Level II oplocks for clients as the Linux and IRIX kernels do not + support them properly. Kernel oplocks support allows Samba oplocks to be broken whenever a local UNIX process or NFS operation @@ -13,6 +15,9 @@ 8 has oplocked. This allows complete data consistency between SMB/CIFS, NFS and local file access (and is a very cool feature :-). + If you do not need this interaction, you should disable the + parameter on Linux and IRIX to get Level II oplocks and the associated + performance benefit. This parameter defaults to on, but is translated to a no-op on systems that no not have the necessary kernel support. -- 1.7.1 From 5786ef579bfc4bea15ec315aec11e92ede9a5731 Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Fri, 30 Mar 2012 15:51:25 +0200 Subject: [PATCH 3/5] s3:smbd add seperate function to initialize kernel oplocks Signed-off-by: Jeremy Allison --- source3/smbd/oplock.c | 10 +++++++--- source3/smbd/proto.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 072d487..f00d8a5 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -932,7 +932,13 @@ bool init_oplocks(struct messaging_context *msg_ctx) messaging_register(msg_ctx, NULL, MSG_SMB_OPEN_RETRY, process_open_retry_message); - if (lp_kernel_oplocks(-1)) { + return true; +} + +void init_kernel_oplocks(void) +{ + /* only initialize once */ + if (koplocks == NULL) { #if HAVE_KERNEL_OPLOCKS_IRIX koplocks = irix_init_kernel_oplocks(NULL); #elif HAVE_KERNEL_OPLOCKS_LINUX @@ -942,6 +948,4 @@ bool init_oplocks(struct messaging_context *msg_ctx) koplocks = onefs_init_kernel_oplocks(NULL); #endif } - - return True; } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index aadad4b..c9b5e7f 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -668,6 +668,7 @@ void contend_level2_oplocks_end(files_struct *fsp, void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e); void message_to_share_mode_entry(struct share_mode_entry *e, char *msg); bool init_oplocks(struct messaging_context *msg_ctx); +void init_kernel_oplocks(void); /* The following definitions come from smbd/oplock_irix.c */ -- 1.7.1 From 2f1c4c7c825a957f1941746e97152071aa4716ba Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Fri, 30 Mar 2012 16:00:15 +0200 Subject: [PATCH 4/5] s3:smbd only initialize kernel oplocks if they are enabled for a share Signed-off-by: Jeremy Allison --- source3/smbd/service.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/source3/smbd/service.c b/source3/smbd/service.c index f57e57f..430a26d 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -946,6 +946,10 @@ static connection_struct *make_connection_snum(struct smbd_server_connection *sc conn); } + if (lp_kernel_oplocks(snum)) { + init_kernel_oplocks(); + } + /* * Fix compatibility issue pointed out by Volker. * We pass the conn->connectpath to the preexec -- 1.7.1 From 3b21d06a01ee4e6a7c12d3b9a6e80c49762c09d2 Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Fri, 30 Mar 2012 16:11:08 +0200 Subject: [PATCH 5/5] s3:smbd only care about missing level2 support if kernel oplocks are enabled if kernel oplocks are not enabled for that share, we can grant level2 oplocks The last five patches address Bug #8870 - "kernel oplocks" is not a share specific option Signed-off-by: Jeremy Allison Autobuild-User: Jeremy Allison Autobuild-Date: Wed Apr 11 22:45:21 CEST 2012 on sn-devel-104 --- source3/smbd/oplock.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index f00d8a5..6c4fd0f 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -61,8 +61,11 @@ void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp) bool set_file_oplock(files_struct *fsp, int oplock_type) { + + bool use_kernel = lp_kernel_oplocks(SNUM(fsp->conn)) && koplocks; + if (fsp->oplock_type == LEVEL_II_OPLOCK) { - if (koplocks && + if (use_kernel && !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) { DEBUG(10, ("Refusing level2 oplock, kernel oplocks " "don't support them\n")); @@ -72,7 +75,7 @@ bool set_file_oplock(files_struct *fsp, int oplock_type) if ((fsp->oplock_type != NO_OPLOCK) && (fsp->oplock_type != FAKE_LEVEL_II_OPLOCK) && - koplocks && + use_kernel && !koplocks->ops->set_oplock(koplocks, fsp, oplock_type)) { return False; } @@ -489,6 +492,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx, struct share_mode_entry msg; files_struct *fsp; bool break_to_level2 = False; + bool use_kernel; if (data->data == NULL) { DEBUG(0, ("Got NULL buffer\n")); @@ -550,9 +554,11 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx, return; } - if ((global_client_caps & CAP_LEVEL_II_OPLOCKS) && + use_kernel = lp_kernel_oplocks(SNUM(fsp->conn)) && koplocks; + + if ((global_client_caps & CAP_LEVEL_II_OPLOCKS) && !(msg.op_type & FORCE_OPLOCK_BREAK_TO_NONE) && - !(koplocks && !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) && + !(use_kernel && !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) && lp_level2_oplocks(SNUM(fsp->conn))) { break_to_level2 = True; } -- 1.7.1