summaryrefslogtreecommitdiff
path: root/source4/torture/raw
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-03-17 12:11:44 +0100
committerStefan Metzmacher <metze@samba.org>2008-03-17 16:06:07 +0100
commit3530099cf226d591b687715b63b144d243e52083 (patch)
treea0f5fc99146e070cc9e52ced8ddd0992680d946d /source4/torture/raw
parentb65ad8966a7ffba15b64b837610a65694336f80a (diff)
downloadsamba-3530099cf226d591b687715b63b144d243e52083.tar.gz
samba-3530099cf226d591b687715b63b144d243e52083.tar.bz2
samba-3530099cf226d591b687715b63b144d243e52083.zip
RAW-BENCH-OPEN: avoid sync calls before the main loop
On multi cpu machines the server may reply to the first requests while the test is still in setup mode. Now we setup the first opens, but send them all together when entering the main loop. metze (This used to be commit 3f2d12c61e95475009baf77c3e0fbea2abecc17a)
Diffstat (limited to 'source4/torture/raw')
-rw-r--r--source4/torture/raw/openbench.c88
1 files changed, 55 insertions, 33 deletions
diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c
index 8f4558e732..e8b2f56813 100644
--- a/source4/torture/raw/openbench.c
+++ b/source4/torture/raw/openbench.c
@@ -49,9 +49,12 @@ struct benchopen_state {
struct smbcli_state *cli;
struct smbcli_tree *tree;
int client_num;
- int old_fnum;
- int fnum;
- int file_num;
+ int close_fnum;
+ int open_fnum;
+ int close_file_num;
+ int open_file_num;
+ int pending_file_num;
+ int next_file_num;
int count;
int lastcount;
union smb_open open_parms;
@@ -96,11 +99,11 @@ static void reopen_connection_complete(struct composite_context *ctx)
num_connected++;
- DEBUG(0,("reconnect to %s finished (%u connected)\n", state->dest_host,
- num_connected));
+ DEBUG(0,("[%u] reconnect to %s finished (%u connected)\n",
+ state->client_num, state->dest_host, num_connected));
- state->fnum = -1;
- state->old_fnum = -1;
+ state->open_fnum = -1;
+ state->close_fnum = -1;
next_open(state);
}
@@ -137,7 +140,8 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te,
/* kill off the remnants of the old connection */
talloc_free(state->tree);
state->tree = NULL;
- state->fnum = -1;
+ state->open_fnum = -1;
+ state->close_fnum = -1;
ctx = smb_composite_connect_send(io, state->mem_ctx,
lp_resolve_context(state->tctx->lp_ctx),
@@ -159,9 +163,10 @@ static void next_open(struct benchopen_state *state)
{
state->count++;
- state->file_num = (state->file_num+1) % (3*nprocs);
+ state->pending_file_num = state->next_file_num;
+ state->next_file_num = (state->next_file_num+1) % (3*nprocs);
- DEBUG(2,("[%d] opening %u\n", state->client_num, state->file_num));
+ DEBUG(2,("[%d] opening %u\n", state->client_num, state->pending_file_num));
state->open_parms.ntcreatex.level = RAW_OPEN_NTCREATEX;
state->open_parms.ntcreatex.in.flags = 0;
state->open_parms.ntcreatex.in.root_fid = 0;
@@ -173,7 +178,7 @@ static void next_open(struct benchopen_state *state)
state->open_parms.ntcreatex.in.create_options = 0;
state->open_parms.ntcreatex.in.impersonation = 0;
state->open_parms.ntcreatex.in.security_flags = 0;
- state->open_parms.ntcreatex.in.fname = fnames[state->file_num];
+ state->open_parms.ntcreatex.in.fname = fnames[state->pending_file_num];
state->req_open = smb_raw_open_send(state->tree, &state->open_parms);
state->req_open->async.fn = open_completed;
@@ -183,18 +188,18 @@ static void next_open(struct benchopen_state *state)
static void next_close(struct benchopen_state *state)
{
- DEBUG(2,("[%d] closing %d\n", state->client_num, state->old_fnum));
- if (state->old_fnum == -1) {
+ if (state->close_fnum == -1) {
return;
}
+ DEBUG(2,("[%d] closing %d (fnum[%d])\n",
+ state->client_num, state->close_file_num, state->close_fnum));
state->close_parms.close.level = RAW_CLOSE_CLOSE;
- state->close_parms.close.in.file.fnum = state->old_fnum;
+ state->close_parms.close.in.file.fnum = state->close_fnum;
state->close_parms.close.in.write_time = 0;
state->req_close = smb_raw_close_send(state->tree, &state->close_parms);
state->req_close->async.fn = close_completed;
state->req_close->async.private = state;
- state->old_fnum = -1;
}
/*
@@ -219,7 +224,8 @@ static void open_completed(struct smbcli_request *req)
state->tree = NULL;
state->cli = NULL;
num_connected--;
- DEBUG(0,("reopening connection to %s\n", state->dest_host));
+ DEBUG(0,("[%u] reopening connection to %s\n",
+ state->client_num, state->dest_host));
talloc_free(state->te);
state->te = event_add_timed(state->ev, state->mem_ctx,
timeval_current_ofs(1,0),
@@ -228,7 +234,8 @@ static void open_completed(struct smbcli_request *req)
}
if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
- DEBUG(2,("[%d] retrying open\n", state->client_num));
+ DEBUG(2,("[%d] retrying open %d\n",
+ state->client_num, state->pending_file_num));
state->open_retries++;
state->req_open = smb_raw_open_send(state->tree, &state->open_parms);
state->req_open->async.fn = open_completed;
@@ -238,17 +245,21 @@ static void open_completed(struct smbcli_request *req)
if (!NT_STATUS_IS_OK(status)) {
open_failed++;
- DEBUG(0,("open failed - %s\n", nt_errstr(status)));
+ DEBUG(0,("[%u] open failed %d - %s\n",
+ state->client_num, state->pending_file_num,
+ nt_errstr(status)));
return;
}
- state->old_fnum = state->fnum;
- state->fnum = state->open_parms.ntcreatex.out.file.fnum;
+ state->close_file_num = state->open_file_num;
+ state->close_fnum = state->open_fnum;
+ state->open_file_num = state->pending_file_num;
+ state->open_fnum = state->open_parms.ntcreatex.out.file.fnum;
- DEBUG(2,("[%d] open completed: fnum=%d old_fnum=%d\n",
- state->client_num, state->fnum, state->old_fnum));
+ DEBUG(2,("[%d] open completed %d (fnum[%d])\n",
+ state->client_num, state->open_file_num, state->open_fnum));
- if (state->old_fnum != -1) {
+ if (state->close_fnum != -1) {
next_close(state);
}
@@ -272,7 +283,8 @@ static void close_completed(struct smbcli_request *req)
state->tree = NULL;
state->cli = NULL;
num_connected--;
- DEBUG(0,("reopening connection to %s\n", state->dest_host));
+ DEBUG(0,("[%u] reopening connection to %s\n",
+ state->client_num, state->dest_host));
talloc_free(state->te);
state->te = event_add_timed(state->ev, state->mem_ctx,
timeval_current_ofs(1,0),
@@ -282,12 +294,16 @@ static void close_completed(struct smbcli_request *req)
if (!NT_STATUS_IS_OK(status)) {
close_failed++;
- DEBUG(0,("close failed - %s\n", nt_errstr(status)));
+ DEBUG(0,("[%u] close failed %d (fnum[%d]) - %s\n",
+ state->client_num, state->close_file_num,
+ state->close_fnum,
+ nt_errstr(status)));
return;
}
- DEBUG(2,("[%d] close completed: fnum=%d old_fnum=%d\n",
- state->client_num, state->fnum, state->old_fnum));
+ DEBUG(2,("[%d] close completed %d (fnum[%d])\n",
+ state->client_num, state->close_file_num,
+ state->close_fnum));
}
static void echo_completion(struct smbcli_request *req)
@@ -299,7 +315,8 @@ static void echo_completion(struct smbcli_request *req)
talloc_free(state->tree);
state->tree = NULL;
num_connected--;
- DEBUG(0,("reopening connection to %s\n", state->dest_host));
+ DEBUG(0,("[%u] reopening connection to %s\n",
+ state->client_num, state->dest_host));
talloc_free(state->te);
state->te = event_add_timed(state->ev, state->mem_ctx,
timeval_current_ofs(1,0),
@@ -400,11 +417,10 @@ bool torture_bench_open(struct torture_context *torture)
}
for (i=0;i<nprocs;i++) {
- state[i].file_num = i;
- state[i].fnum = smbcli_open(state[i].tree,
- fnames[state->file_num],
- O_RDWR|O_CREAT, DENY_ALL);
- state[i].old_fnum = -1;
+ /* all connections start with the same file */
+ state[i].next_file_num = 0;
+ state[i].open_fnum = -1;
+ state[i].close_fnum = -1;
next_open(&state[i]);
}
@@ -430,6 +446,12 @@ bool torture_bench_open(struct torture_context *torture)
}
talloc_free(report_te);
+ if (progress) {
+ for (i=0;i<nprocs;i++) {
+ printf(" ");
+ }
+ printf("\r");
+ }
minops = state[0].count;
for (i=0;i<nprocs;i++) {