From: Stefan Metzmacher Date: Fri, 19 Aug 2022 15:17:41 +0000 (+0000) Subject: s3:smbd: only run validate_oplock_types() with smbd:validate_oplock_types = yes X-Git-Tag: talloc-2.4.0~1394 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0fbca175ae4763d82f8a414ee3d6354c95d5294e;p=thirdparty%2Fsamba.git s3:smbd: only run validate_oplock_types() with smbd:validate_oplock_types = yes This is really expensive as share_mode_forall_entries() is currently doing a talloc_memdup() of the whole record... This is mainly used to avoid regressions, so only use smbd:validate_oplock_types = yes in make test, but skip it for production. This improves the following test: time smbtorture //127.0.0.1/m -Uroot%test \ smb2.create.bench-path-contention-shared \ --option='torture:bench_path=file.dat' \ --option="torture:timelimit=60" \ --option="torture:nprocs=256" \ --option="torture:qdepth=1" From: open[num/s=8852,avslat=0.014999,minlat=0.000042,maxlat=0.054600] close[num/s=8850,avslat=0.014136,minlat=0.000025,maxlat=0.054537] to: open[num/s=11377,avslat=0.012075,minlat=0.000041,maxlat=0.054107] close[num/s=11375,avslat=0.010594,minlat=0.000023,maxlat=0.053620] BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 88898807428..d413f14bacd 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -2772,6 +2772,7 @@ sub provision($$) panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY) smbd:suicide mode = yes smbd:FSCTL_SMBTORTURE = yes + smbd:validate_oplock_types = yes client min protocol = SMB2_02 server min protocol = SMB2_02 diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 1762ae4ae79..e5ae57cb7fc 100755 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -778,6 +778,7 @@ sub provision_raw_step1($$) panic action = $RealBin/gdb_backtrace \%d smbd:suicide mode = yes smbd:FSCTL_SMBTORTURE = yes + smbd:validate_oplock_types = yes wins support = yes server role = $ctx->{server_role} server services = +echo $services diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 1d6c3cfbfbc..e189d418262 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2210,8 +2210,21 @@ static bool validate_oplock_types_fn( static bool validate_oplock_types(struct share_mode_lock *lck) { struct validate_oplock_types_state state = { .valid = true }; + static bool skip_validation; + bool validate; bool ok; + if (skip_validation) { + return true; + } + + validate = lp_parm_bool(-1, "smbd", "validate_oplock_types", false); + if (!validate) { + DBG_DEBUG("smbd:validate_oplock_types not set to yes\n"); + skip_validation = true; + return true; + } + ok = share_mode_forall_entries(lck, validate_oplock_types_fn, &state); if (!ok) { DBG_DEBUG("share_mode_forall_entries failed\n");