From 108cf27bb1fe0e602d00a8cc0b54c1d72a1630c8 Mon Sep 17 00:00:00 2001 From: Zack Kirsch Date: Wed, 1 Apr 2009 17:46:40 -0700 Subject: s4 torture: Addition to RAW-BENCH-LOCK to take a configurable number of locks before starting the test This can be useful for benchmarking as well as stress testing. --- source4/torture/raw/lockbench.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c index d20175a0189..c7f99aeb3c3 100644 --- a/source4/torture/raw/lockbench.c +++ b/source4/torture/raw/lockbench.c @@ -317,13 +317,15 @@ bool torture_bench_lock(struct torture_context *torture) { bool ret = true; TALLOC_CTX *mem_ctx = talloc_new(torture); - int i; + int i, j; int timelimit = torture_setting_int(torture, "timelimit", 10); struct timeval tv; struct benchlock_state *state; int total = 0, minops=0; struct smbcli_state *cli; bool progress; + off_t offset; + int initial_locks = torture_setting_int(torture, "initial_locks", 0); progress = torture_setting_bool(torture, "progress", true); @@ -371,6 +373,21 @@ bool torture_bench_lock(struct torture_context *torture) goto failed; } + /* Optionally, lock initial_locks for each proc beforehand. */ + if (i == 0 && initial_locks > 0) { + printf("Initializing %d locks on each proc.\n", + initial_locks); + } + + for (j = 0; j < initial_locks; j++) { + offset = (0xFFFFFED8LLU * (i+2)) + j; + if (!NT_STATUS_IS_OK(smbcli_lock64(state[i].tree, + state[i].fnum, offset, 1, 0, WRITE_LOCK))) { + printf("Failed initializing, lock=%d\n", j); + goto failed; + } + } + state[i].stage = LOCK_INITIAL; lock_send(&state[i]); } @@ -413,6 +430,7 @@ bool torture_bench_lock(struct torture_context *torture) return ret; failed: + smbcli_deltree(state[0].tree, BASEDIR); talloc_free(mem_ctx); return false; } -- cgit