backend: privatize nr_thread/nr_process
authorJens Axboe <axboe@kernel.dk>
Mon, 19 Mar 2012 09:44:29 +0000 (10:44 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 19 Mar 2012 09:44:29 +0000 (10:44 +0100)
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>
backend.c
fio.h
init.c
libfio.c

index e65af5258af564e64594c65bcbe32f01bb6d9f35..1f5f3c7f567967ab2f0d662eb6ab9845fadd9515 100644 (file)
--- 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 919c6cde8da2c9ed74ec401cf0c5f21396a46289..28198b9cbeffd99acf03c831c9ec0bbd1b7d0c89 100644 (file)
--- 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 eccd3afedd87af446fd2de017234eba9667de2c9..8c9faec22f2cb5a67150d1264d600be1cdf709a9 100644 (file)
--- 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;
 
index 95938c88da4e12e4b3eb8adc9b33e74438be340e..acdb0ea468a8d3855ecc4affcc395dd086218ee3 100644 (file)
--- 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;
 }