summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-04-10 04:51:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:04:01 -0500
commit72343b9615c2ecbff0676e4a5d1b5ee4fe50ad58 (patch)
tree790d76678cdf9e011bd970788258e81653c8b3e9 /source4
parent4480a62ec3845d1e4f7d3f161f542d7cfe748320 (diff)
downloadsamba-72343b9615c2ecbff0676e4a5d1b5ee4fe50ad58.tar.gz
samba-72343b9615c2ecbff0676e4a5d1b5ee4fe50ad58.tar.bz2
samba-72343b9615c2ecbff0676e4a5d1b5ee4fe50ad58.zip
r15014: added a simple batch oplock benchmark
Jeremy, Samba3 currently fails this test with a 2.6.16-rc6 kernel and kernel oplocks enabled. With kernel oplock off it passes, though its a bit slow (This used to be commit 99df20246049c2645b04d5790b9e41c607872dc7)
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/raw/oplock.c94
-rw-r--r--source4/torture/torture.c1
-rw-r--r--source4/torture/torture_util.c9
3 files changed, 97 insertions, 7 deletions
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index 14d4c7bc04..e7fa335e7a 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -24,6 +24,7 @@
#include "libcli/raw/libcliraw.h"
#include "libcli/libcli.h"
#include "torture/util.h"
+#include "lib/events/events.h"
#define CHECK_VAL(v, correct) do { \
if ((v) != (correct)) { \
@@ -48,6 +49,8 @@ static struct {
int failures;
} break_info;
+#define BASEDIR "\\test_notify"
+
/*
a handler function for oplock break requests
*/
@@ -86,8 +89,6 @@ static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t ti
break_info.level = level;
break_info.count++;
- printf("Closing in oplock handler\n");
-
io.close.level = RAW_CLOSE_CLOSE;
io.close.in.file.fnum = fnum;
io.close.in.write_time = 0;
@@ -108,7 +109,7 @@ static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t ti
*/
static BOOL test_oplock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
- const char *fname = "\\test_oplock.dat";
+ const char *fname = BASEDIR "\\test_oplock.dat";
NTSTATUS status;
BOOL ret = True;
union smb_open io;
@@ -478,21 +479,100 @@ done:
*/
BOOL torture_raw_oplock(struct torture_context *torture)
{
- struct smbcli_state *cli1;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
- if (!torture_open_connection(&cli1)) {
+ if (!torture_open_connection(&cli)) {
+ return False;
+ }
+
+ if (!torture_setup_dir(cli, BASEDIR)) {
return False;
}
mem_ctx = talloc_init("torture_raw_oplock");
- if (!test_oplock(cli1, mem_ctx)) {
+ if (!test_oplock(cli, mem_ctx)) {
+ ret = False;
+ }
+
+ smb_raw_exit(cli->session);
+ smbcli_deltree(cli->tree, BASEDIR);
+ torture_close_connection(cli);
+ talloc_free(mem_ctx);
+ return ret;
+}
+
+
+/*
+ stress testing of oplocks
+*/
+BOOL torture_bench_oplock(struct torture_context *torture)
+{
+ struct smbcli_state **cli;
+ BOOL ret = True;
+ TALLOC_CTX *mem_ctx = talloc_new(torture);
+ extern int torture_nprocs;
+ int i, count=0;
+ int timelimit = lp_parm_int(-1, "torture", "timelimit", 10);
+ union smb_open io;
+ struct timeval tv;
+ struct event_context *ev = event_context_find(mem_ctx);
+
+ cli = talloc_array(mem_ctx, struct smbcli_state *, torture_nprocs);
+
+ printf("Opening %d connections\n", torture_nprocs);
+ for (i=0;i<torture_nprocs;i++) {
+ if (!torture_open_connection_ev(&cli[i], ev)) {
+ return False;
+ }
+ talloc_steal(mem_ctx, cli[i]);
+ smbcli_oplock_handler(cli[i]->transport, oplock_handler_close,
+ cli[i]->tree);
+ }
+
+ if (!torture_setup_dir(cli[0], BASEDIR)) {
ret = False;
+ goto done;
}
- torture_close_connection(cli1);
+ io.ntcreatex.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = BASEDIR "\\test.dat";
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
+
+ tv = timeval_current();
+
+ printf("Running for %d seconds\n", timelimit);
+ while (timeval_elapsed(&tv) < timelimit) {
+ for (i=0;i<torture_nprocs;i++) {
+ NTSTATUS status;
+
+ status = smb_raw_open(cli[i]->tree, mem_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ count++;
+ }
+ printf("%.2f ops/second\r", count/timeval_elapsed(&tv));
+ }
+
+ printf("%.2f ops/second\n", count/timeval_elapsed(&tv));
+
+ smb_raw_exit(cli[torture_nprocs-1]->session);
+
+done:
+ smb_raw_exit(cli[0]->session);
+ smbcli_deltree(cli[0]->tree, BASEDIR);
talloc_free(mem_ctx);
return ret;
}
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 1c388dd6cb..9852d886f8 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -587,6 +587,7 @@ static struct {
{"BENCH-NBT", torture_bench_nbt, 0},
{"BENCH-WINS", torture_bench_wins, 0},
{"BENCH-CLDAP", torture_bench_cldap, 0},
+ {"BENCH-OPLOCK", torture_bench_oplock, 0},
/* RAW smb tests */
{"RAW-QFSINFO", torture_raw_qfsinfo, 0},
diff --git a/source4/torture/torture_util.c b/source4/torture/torture_util.c
index 69c462bc6d..12e4559137 100644
--- a/source4/torture/torture_util.c
+++ b/source4/torture/torture_util.c
@@ -493,6 +493,15 @@ _PUBLIC_ BOOL torture_open_connection(struct smbcli_state **c)
return torture_open_connection_share(NULL, c, host, share, NULL);
}
+_PUBLIC_ BOOL torture_open_connection_ev(struct smbcli_state **c,
+ struct event_context *ev)
+{
+ const char *host = lp_parm_string(-1, "torture", "host");
+ const char *share = lp_parm_string(-1, "torture", "share");
+
+ return torture_open_connection_share(NULL, c, host, share, ev);
+}
+
_PUBLIC_ BOOL torture_close_connection(struct smbcli_state *c)