[PATCH] fio: Move file creating even earlier and fix bug in setup_rate()
authorJens Axboe <axboe@suse.de>
Thu, 27 Oct 2005 10:57:59 +0000 (12:57 +0200)
committerJens Axboe <axboe@suse.de>
Thu, 27 Oct 2005 10:57:59 +0000 (12:57 +0200)
fio.c

diff --git a/fio.c b/fio.c
index 435db1985b4d7c81a0492a55729a044846844208..f32f96f3cef020a35d24a8c8c9e53583d44df061 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1291,6 +1291,11 @@ static int add_job(struct thread_data *td, const char *filename, int prioclass,
        if (td->use_aio && !td->aio_depth)
                td->aio_depth = 1;
 
+       if (td->min_bs == -1)
+               td->min_bs = td->bs;
+       if (td->max_bs == -1)
+               td->max_bs = td->bs;
+
        if (setup_rate(td))
                return -1;
 
@@ -1299,11 +1304,6 @@ static int add_job(struct thread_data *td, const char *filename, int prioclass,
        if (write_bw_log)
                setup_log(&td->bw_log);
 
-       if (td->min_bs == -1)
-               td->min_bs = td->bs;
-       if (td->max_bs == -1)
-               td->max_bs = td->bs;
-
        printf("Client%d: file=%s, rw=%d, prio=%d/%d, seq=%d, odir=%d, bs=%d-%d, rate=%d, aio=%d, aio_depth=%d\n", td->thread_number, filename, td->ddir, prioclass, prio, td->sequential, td->odirect, td->min_bs, td->max_bs, td->rate, td->use_aio, td->aio_depth);
        return 0;
 }
@@ -1946,8 +1946,6 @@ static void run_threads(char *argv[])
        unsigned long spent;
        int i, todo, nr_running, m_rate, t_rate;
 
-       gettimeofday(&genesis, NULL);
-
        printf("Starting %d threads\n", thread_number);
        fflush(stdout);
 
@@ -1957,6 +1955,22 @@ static void run_threads(char *argv[])
        nr_running = 0;
        m_rate = t_rate = 0;
 
+       for (i = 0; i < thread_number; i++) {
+               td = &threads[i];
+
+               /*
+                * do file setup here so it happens sequentially,
+                * we don't want X number of threads getting their
+                * client data interspersed on disk
+                */
+               if (setup_file(td)) {
+                       td->runstate = TD_REAPED;
+                       todo--;
+               }
+       }
+
+       gettimeofday(&genesis, NULL);
+
        while (todo) {
                /*
                 * create threads (TD_NOT_CREATED -> TD_CREATED)
@@ -1983,16 +1997,6 @@ static void run_threads(char *argv[])
                                        continue;
                        }
 
-                       /*
-                        * do file setup here so it happens sequentially,
-                        * we don't want X number of threads getting their
-                        * client data interspersed on disk
-                        */
-                       if (setup_file(td)) {
-                               td->terminate = 1;
-                               continue;
-                       }
-
                        td->runstate = TD_CREATED;
                        run_str[td->thread_number - 1] = 'C';
                        sem_init(&startup_sem, 1, 1);