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 <axboe@kernel.dk>
diff --git a/backend.c b/backend.c
index e65af52..1f5f3c7 100644
--- a/backend.c
+++ b/backend.c
@@ -56,13 +56,13 @@
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 @@
* 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 @@
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 919c6cd..28198b9 100644
--- a/fio.h
+++ b/fio.h
@@ -310,7 +310,6 @@
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 eccd3af..8c9faec 100644
--- a/init.c
+++ b/init.c
@@ -775,11 +775,6 @@
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 95938c8..acdb0ea 100644
--- a/libfio.c
+++ b/libfio.c
@@ -133,8 +133,6 @@
{
groupid = 0;
thread_number = 0;
- nr_process = 0;
- nr_thread = 0;
done_secs = 0;
}