[PATCH] fio: Add 'loops' parameter to specify number of times to run the job
authorJens Axboe <axboe@suse.de>
Thu, 3 Nov 2005 14:54:43 +0000 (15:54 +0100)
committerJens Axboe <axboe@suse.de>
Thu, 3 Nov 2005 14:54:43 +0000 (15:54 +0100)
README.fio
fio.c

index 3f7da797dfe208a19eeaf4f191ae269924b5112a..a284b0bc30438f156952d37b18704d3b02a0fdfc 100644 (file)
@@ -51,6 +51,9 @@ The <jobs> format is as follows:
                        use shm for buffers.
        exitall         When one thread quits, terminate the others
        bwavgtime=x     Average bandwidth stats over x msec
+       create_serialize=x      If 'x', serialize file creation.
+       create_fsync=x  If 'x', run fsync() after file creation.
+       loops=x         Run the job 'x' number of times.
 
 
 Examples using cmd line jobs
diff --git a/fio.c b/fio.c
index 020a69343941735ef980f6b2ba0c9165afac6ec5..b7bdd18ef114b78cbbbd270a6c3bd3b17812412c 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -130,6 +130,7 @@ enum {
 #define DEF_BWAVGTIME  (500)
 #define DEF_CREATE_SER (1)
 #define DEF_CREATE_FSYNC       (1)
+#define DEF_LOOPS      (1)
 
 #define ALIGN(buf)     (char *) (((unsigned long) (buf) + MASK) & ~(MASK))
 
@@ -233,6 +234,7 @@ struct thread_data {
        unsigned int bw_avg_time;
        unsigned int create_serialize;
        unsigned int create_fsync;
+       unsigned int loops;
        unsigned long long file_size;
        unsigned long long file_offset;
        unsigned int sync_io;
@@ -1133,10 +1135,12 @@ static void *thread_main(int shm_id, int offset, char *argv[])
 
        memcpy(&td->stat_sample_time, &td->start, sizeof(td->start));
 
-       if (!td->use_aio)
-               do_sync_io(td);
-       else
-               do_async_io(td);
+       while (td->loops--) {
+               if (!td->use_aio)
+                       do_sync_io(td);
+               else
+                       do_async_io(td);
+       }
 
        td->runtime = mtime_since_now(&td->start);
        ret = 0;
@@ -1278,6 +1282,7 @@ static struct thread_data *get_new_job(int global)
        td->bw_avg_time = def_thread.bw_avg_time;
        td->create_serialize = def_thread.create_serialize;
        td->create_fsync = def_thread.create_fsync;
+       td->loops = def_thread.loops;
        memcpy(&td->cpumask, &def_thread.cpumask, sizeof(td->cpumask));
 
        return td;
@@ -1799,6 +1804,10 @@ static int parse_jobs_ini(char *file)
                                fgetpos(f, &off);
                                continue;
                        }
+                       if (!check_int(p, "loops", &td->loops)) {
+                               fgetpos(f, &off);
+                               continue;
+                       }
                        if (!check_range(p, "bsrange", &ul1, &ul2)) {
                                td->min_bs = ul1;
                                td->max_bs = ul2;
@@ -2145,6 +2154,7 @@ int main(int argc, char *argv[])
        def_thread.bw_avg_time = DEF_BWAVGTIME;
        def_thread.create_serialize = DEF_CREATE_SER;
        def_thread.create_fsync = DEF_CREATE_FSYNC;
+       def_thread.loops = DEF_LOOPS;
 
        i = parse_options(argc, argv);