From 812409e9486a37ba2f51e6e23c97e6ae8e26ff9a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 19 Mar 2012 10:44:29 +0100 Subject: [PATCH] backend: privatize nr_thread/nr_process We need to start moving init items out of add_job(), to allow for updating of job options. The number of threads and processes can be calculated before running jobs, so move them there. Signed-off-by: Jens Axboe --- backend.c | 13 +++++++++++-- fio.h | 1 - init.c | 5 ----- libfio.c | 2 -- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/backend.c b/backend.c index e65af525..1f5f3c7f 100644 --- a/backend.c +++ b/backend.c @@ -56,13 +56,13 @@ static struct flist_head *cgroup_list; static char *cgroup_mnt; static int exit_value; static volatile int fio_abort; +static unsigned int nr_process = 0; +static unsigned int nr_thread = 0; struct io_log *agg_io_log[2]; int groupid = 0; unsigned int thread_number = 0; -unsigned int nr_process = 0; -unsigned int nr_thread = 0; int shm_id = 0; int temp_stall_ts; unsigned long done_secs = 0; @@ -998,6 +998,7 @@ static void *thread_main(void *data) * eating a file descriptor */ fio_mutex_remove(td->mutex); + td->mutex = NULL; /* * A new gid requires privilege, so we need to do this before setting @@ -1359,6 +1360,14 @@ static void run_threads(void) set_sig_handlers(); + nr_thread = nr_process = 0; + for_each_td(td, i) { + if (td->o.use_thread) + nr_thread++; + else + nr_process++; + } + if (!terse_output) { log_info("Starting "); if (nr_thread) diff --git a/fio.h b/fio.h index 919c6cde..28198b9c 100644 --- a/fio.h +++ b/fio.h @@ -310,7 +310,6 @@ enum { extern int exitall_on_terminate; extern unsigned int thread_number; -extern unsigned int nr_process, nr_thread; extern int shm_id; extern int groupid; extern int terse_output; diff --git a/init.c b/init.c index eccd3afe..8c9faec2 100644 --- a/init.c +++ b/init.c @@ -775,11 +775,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, if (ioengine_load(td)) goto err; - if (td->o.use_thread) - nr_thread++; - else - nr_process++; - if (td->o.odirect) td->io_ops->flags |= FIO_RAWIO; diff --git a/libfio.c b/libfio.c index 95938c88..acdb0ea4 100644 --- a/libfio.c +++ b/libfio.c @@ -133,8 +133,6 @@ void reset_fio_state(void) { groupid = 0; thread_number = 0; - nr_process = 0; - nr_thread = 0; done_secs = 0; } -- 2.25.1