Allow reset of offset_increment counter
authorJiri Horky <jiri.horky@gmail.com>
Fri, 25 Jul 2014 07:55:03 +0000 (09:55 +0200)
committerJens Axboe <axboe@fb.com>
Fri, 25 Jul 2014 07:55:03 +0000 (09:55 +0200)
Reset offset_increment only within a sub-group of jobs, eg when
numjobs=x is used to automatically group jobs together.

Signed-off-by: Jens Axboe <axboe@fb.com>
HOWTO
filesetup.c
fio.1
fio.h
init.c

diff --git a/HOWTO b/HOWTO
index ac9606988b2c73b510823bf445300fcb92a67222..1c4b308cf3df9bd33d75306cb3e0e2dfd8df4a40 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -736,11 +736,12 @@ offset=int        Start io at the given offset in the file. The data before
                caps the file size at real_size - offset.
 
 offset_increment=int   If this is provided, then the real offset becomes
-               the offset + offset_increment * thread_number, where the
-               thread number is a counter that starts at 0 and is incremented
-               for each job. This option is useful if there are several jobs
-               which are intended to operate on a file in parallel in disjoint
-               segments, with even spacing between the starting points.
+               offset + offset_increment * thread_number, where the thread
+               number is a counter that starts at 0 and is incremented for
+               each sub-job (i.e. when numjobs option is specified). This
+               option is useful if there are several jobs which are intended
+               to operate on a file in parallel disjoint segments, with
+               even spacing between the starting points.
 
 number_ios=int Fio will normally perform IOs until it has exhausted the size
                of the region set by size=, or if it exhaust the allocated
index 39c276a3d2203180772a1e9a88974dc545d360fd..12a43b1fa14459439dd73013dd4ef018e5f6bfba 100644 (file)
@@ -758,7 +758,7 @@ uint64_t get_start_offset(struct thread_data *td, struct fio_file *f)
                return f->real_file_size;
 
        return td->o.start_offset +
-               (td->thread_number - 1) * td->o.offset_increment;
+               td->subjob_number * td->o.offset_increment;
 }
 
 /*
diff --git a/fio.1 b/fio.1
index 22d6b1e882d10b2a543fb88ddf657387b3b35d94..5291126401a34fdd836137cc9694dc7b5574255d 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -657,10 +657,11 @@ Offset in the file to start I/O. Data before the offset will not be touched.
 .TP
 .BI offset_increment \fR=\fPint
 If this is provided, then the real offset becomes the
-offset + offset_increment * thread_number, where the thread number is a counter
-that starts at 0 and is incremented for each job. This option is useful if
-there are several jobs which are intended to operate on a file in parallel in
-disjoint segments, with even spacing between the starting points.
+offset + offset_increment * thread_number, where the thread number is a
+counter that starts at 0 and is incremented for each sub-job (i.e. when
+numjobs option is specified). This option is useful if there are several jobs
+which are intended to operate on a file in parallel disjoint segments, with
+even spacing between the starting points.
 .TP
 .BI number_ios \fR=\fPint
 Fio will normally perform IOs until it has exhausted the size of the region
diff --git a/fio.h b/fio.h
index c694f2cf40f1c48a9d332e36d25517878e5c02b1..dfbad6d6896e0a8181119b765c33fde2a4d9bc3d 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -102,6 +102,7 @@ struct thread_data {
        char verror[FIO_VERROR_SIZE];
        pthread_t thread;
        unsigned int thread_number;
+       unsigned int subjob_number;
        unsigned int groupid;
        struct thread_stat ts;
 
diff --git a/init.c b/init.c
index b4a0cbb91f9c3ce3c01b1db9b5f3b8fa33f5e22f..62c7dc2472c9f67625a6b3a97d37d8847a185931 100644 (file)
--- a/init.c
+++ b/init.c
@@ -380,6 +380,7 @@ static struct thread_data *get_new_job(int global, struct thread_data *parent,
        profile_add_hooks(td);
 
        td->thread_number = thread_number;
+       td->subjob_number = 0;
 
        if (jobname)
                td->o.name = strdup(jobname);
@@ -1288,6 +1289,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                td_new->o.numjobs = 1;
                td_new->o.stonewall = 0;
                td_new->o.new_group = 0;
+               td_new->subjob_number = numjobs;
 
                if (file_alloced) {
                        if (td_new->files) {