From 2a81240dd3bc53e1e62e26b763ee07ce37151e70 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 8 Nov 2005 10:35:19 +0100 Subject: [PATCH] [PATCH] fio: add stonewall option to serialize jobs when wanted --- README.fio | 1 + fio.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.fio b/README.fio index b536280..51eda02 100644 --- a/README.fio +++ b/README.fio @@ -53,6 +53,7 @@ The format is as follows: create_fsync=x If 'x', run fsync() after file creation. loops=x Run the job 'x' number of times. verify=x If 'x' and writing, verify data written. + stonewall Wait for preceeding jobs to end before running. Examples using a job file diff --git a/fio.c b/fio.c index 898e062..0e4f0f0 100644 --- a/fio.c +++ b/fio.c @@ -141,6 +141,7 @@ enum { #define DEF_CREATE_FSYNC (1) #define DEF_LOOPS (1) #define DEF_VERIFY (0) +#define DEF_STONEWALL (0) #define ALIGN(buf) (char *) (((unsigned long) (buf) + MASK) & ~(MASK)) @@ -271,6 +272,7 @@ struct thread_data { unsigned int sync_io; unsigned int mem_type; unsigned int verify; + unsigned int stonewall; cpu_set_t cpumask; struct drand48_data bsrange_state; @@ -1833,6 +1835,7 @@ static struct thread_data *get_new_job(int global) td->create_fsync = def_thread.create_fsync; td->loops = def_thread.loops; td->verify = def_thread.verify; + td->stonewall = def_thread.stonewall; memcpy(&td->cpumask, &def_thread.cpumask, sizeof(td->cpumask)); return td; @@ -2208,6 +2211,11 @@ static int parse_jobs_ini(char *file) fgetpos(f, &off); continue; } + if (!strncmp(p, "stonewall", 9)) { + td->stonewall = 1; + fgetpos(f, &off); + continue; + } printf("Client%d: bad option %s\n",td->thread_number,p); } fsetpos(f, &off); @@ -2373,7 +2381,7 @@ static void run_threads(char *argv[]) struct timeval genesis; struct thread_data *td; unsigned long spent; - int i, todo, nr_running, m_rate, t_rate; + int i, todo, nr_running, m_rate, t_rate, nr_started; printf("Starting %d threads\n", thread_number); fflush(stdout); @@ -2382,6 +2390,7 @@ static void run_threads(char *argv[]) todo = thread_number; nr_running = 0; + nr_started = 0; m_rate = t_rate = 0; for (i = 0; i < thread_number; i++) { @@ -2429,10 +2438,14 @@ static void run_threads(char *argv[]) continue; } + if (td->stonewall && (nr_started || nr_running)) + continue; + td_set_runstate(td, TD_CREATED); check_str_update(td, nr_running, t_rate, m_rate); sem_init(&startup_sem, 1, 1); todo--; + nr_started++; if (fork()) sem_wait(&startup_sem); @@ -2453,6 +2466,7 @@ static void run_threads(char *argv[]) td_set_runstate(td, TD_RUNNING); nr_running++; + nr_started--; m_rate += td->ratemin; t_rate += td->rate; check_str_update(td, nr_running, t_rate, m_rate); @@ -2553,6 +2567,7 @@ int main(int argc, char *argv[]) def_thread.create_fsync = DEF_CREATE_FSYNC; def_thread.loops = DEF_LOOPS; def_thread.verify = DEF_VERIFY; + def_thread.stonewall = DEF_STONEWALL; i = parse_options(argc, argv); -- 2.25.1