Add number_ios= option
authorJens Axboe <axboe@kernel.dk>
Fri, 9 Aug 2013 18:53:44 +0000 (12:53 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 9 Aug 2013 18:53:44 +0000 (12:53 -0600)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
HOWTO
cconv.c
fio.1
io_u.c
options.c
server.h
thread_options.h

diff --git a/HOWTO b/HOWTO
index 2335a07ffc142366cbf652d8caffca542ea9f2ab..005dac251dd202917fdb446ffec22d3126757f8c 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -709,6 +709,13 @@ offset_increment=int       If this is provided, then the real offset becomes
                which are intended to operate on a file in parallel in 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
+               time (or hits an error condition). With this setting, the
+               range/size can be set independently of the number of IOs to
+               perform. When fio reaches this number, it will exit normally
+               and report status.
+
 fsync=int      If writing to a file, issue a sync of the dirty data
                for every number of blocks given. For example, if you give
                32 as a parameter, fio will sync the file for every 32
diff --git a/cconv.c b/cconv.c
index 8e7c69e9305a443e1b57d426776ee3a144b6c9e2..21e3a51bb4dfa6a431c05f3562b6a9415a45a14b 100644 (file)
--- a/cconv.c
+++ b/cconv.c
@@ -146,6 +146,7 @@ void convert_thread_options_to_cpu(struct thread_options *o,
        o->zone_skip = le64_to_cpu(top->zone_skip);
        o->lockmem = le64_to_cpu(top->lockmem);
        o->offset_increment = le64_to_cpu(top->offset_increment);
+       o->number_ios = le64_to_cpu(top->number_ios);
 
        o->overwrite = le32_to_cpu(top->overwrite);
        o->bw_avg_time = le32_to_cpu(top->bw_avg_time);
@@ -394,6 +395,7 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
        top->start_offset = __cpu_to_le64(o->start_offset);
        top->trim_backlog = __cpu_to_le64(o->trim_backlog);
        top->offset_increment = __cpu_to_le64(o->offset_increment);
+       top->number_ios = __cpu_to_le64(o->number_ios);
 
        for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
                top->percentile_list[i].u.i = __cpu_to_le64(fio_double_to_uint64(o->percentile_list[i].u.f));
diff --git a/fio.1 b/fio.1
index b54eeadb045016c0c970a4d11deb93faaf030e79..e35bd938c7eb5d9bf24c724c3d640a370cbe7919 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -576,6 +576,13 @@ 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.
 .TP
+.BI number_ios \fR=\fPint
+Fio will normally perform IOs until it has exhausted the size of the region
+set by \fBsize\fR, or if it exhaust the allocated time (or hits an error
+condition). With this setting, the range/size can be set independently of
+the number of IOs to perform. When fio reaches this number, it will exit
+normally and report status.
+.TP
 .BI fsync \fR=\fPint
 How many I/Os to perform before issuing an \fBfsync\fR\|(2) of dirty data.  If
 0, don't sync.  Default: 0.
diff --git a/io_u.c b/io_u.c
index a35aafd2d947617f4da588c11752f3e849f71a54..c50a17dfb8d5580a1fd7f646aec37a076c27821f 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1413,6 +1413,9 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u,
                add_bw_sample(td, idx, bytes, &icd->time);
 
        add_iops_sample(td, idx, bytes, &icd->time);
+
+       if (td->o.number_ios && !--td->o.number_ios)
+               td->done = 1;
 }
 
 static long long usec_for_io(struct thread_data *td, enum fio_ddir ddir)
index 1816d0be74eb090fa8742e71924a75c76356df2a..caf89d3c64fccd29668c0b49814169fb784f523f 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1482,6 +1482,16 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_INVALID,
        },
+       {
+               .name   = "number_ios",
+               .lname  = "Number of IOs to perform",
+               .type   = FIO_OPT_STR_VAL,
+               .off1   = td_var_offset(number_ios),
+               .help   = "Force job completion of this number of IOs",
+               .def    = "0",
+               .category = FIO_OPT_C_IO,
+               .group  = FIO_OPT_G_INVALID,
+       },
        {
                .name   = "bs",
                .lname  = "Block size",
index 2f41be0923c0bde215919fd0f6220c441dad0855..aefd4183248313a190973759b353f2bc433cb782 100644 (file)
--- a/server.h
+++ b/server.h
@@ -38,7 +38,7 @@ struct fio_net_cmd_reply {
 };
 
 enum {
-       FIO_SERVER_VER                  = 24,
+       FIO_SERVER_VER                  = 25,
 
        FIO_SERVER_MAX_FRAGMENT_PDU     = 1024,
 
index eaafaee206d184dbbca87d3db20970ac08a64673..3f345c56b3bafaca9eb5acd1210e58633fb63f86 100644 (file)
@@ -236,6 +236,7 @@ struct thread_options {
        unsigned int flow_sleep;
 
        unsigned long long offset_increment;
+       unsigned long long number_ios;
 
        unsigned int sync_file_range;
 };
@@ -440,6 +441,7 @@ struct thread_options_pack {
        uint32_t flow_sleep;
 
        uint64_t offset_increment;
+       uint64_t number_ios;
 
        uint32_t sync_file_range;
 } __attribute__((packed));