[PATCH] fio: add stonewall option to serialize jobs when wanted
authorJens Axboe <axboe@suse.de>
Tue, 8 Nov 2005 09:35:19 +0000 (10:35 +0100)
committerJens Axboe <axboe@suse.de>
Tue, 8 Nov 2005 09:35:19 +0000 (10:35 +0100)
README.fio
fio.c

index b5362806ae37675e57c427d9a41d395c139307fe..51eda0214c6e66ca0e8db6c8fd71de32cdf5a69f 100644 (file)
@@ -53,6 +53,7 @@ The <jobs> 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 898e0627a65985f46830fcb45e2ac97b01657979..0e4f0f067cf1779acc20d36ce2ec86819f6a0bab 100644 (file)
--- 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);