Merge branch 'master' of ssh://router/data/git/fio
authorJens Axboe <jens.axboe@oracle.com>
Mon, 27 Jul 2009 10:28:21 +0000 (12:28 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 27 Jul 2009 10:28:21 +0000 (12:28 +0200)
13 files changed:
HOWTO
README
eta.c
filesetup.c
fio.1
fio.c
fio.h
fio_generate_plots
memory.c
options.c
parse.c
parse.h
stat.c

diff --git a/HOWTO b/HOWTO
index 5099c83c8fd7913773de58285ff323e2bdaec4d0..dc70ab6693688e4078713abd0292bb8036915035 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -112,7 +112,7 @@ section residing above it. If the first character in a line is a ';' or a
 '#', the entire line is discarded as a comment.
 
 So let's look at a really simple job file that defines two processes, each
-randomly reading from a 128MiB file.
+randomly reading from a 128MB file.
 
 ; -- start job file --
 [global]
@@ -150,9 +150,9 @@ numjobs=4
 
 Here we have no global section, as we only have one job defined anyway.
 We want to use async io here, with a depth of 4 for each file. We also
-increased the buffer size used to 32KiB and define numjobs to 4 to
+increased the buffer size used to 32KB and define numjobs to 4 to
 fork 4 identical jobs. The result is 4 processes each randomly writing
-to their own 64MiB file. Instead of using the above job file, you could
+to their own 64MB file. Instead of using the above job file, you could
 have given the parameters on the command line. For this case, you would
 specify:
 
@@ -197,21 +197,21 @@ Some parameters take an option of a given type, such as an integer or
 a string. The following types are used:
 
 str    String. This is a sequence of alpha characters.
-time   Integer with possible time postfix. In seconds unless otherwise
+time   Integer with possible time suffix. In seconds unless otherwise
        specified, use eg 10m for 10 minutes. Accepts s/m/h for seconds,
        minutes, and hours.
-int    SI integer. A whole number value, which may contain a postfix
-       describing the base of the number. Accepted postfixes are k/m/g,
-       meaning kilo, mega, and giga. So if you want to specify 4096,
-       you could either write out '4096' or just give 4k. The postfixes
-       signify base 2 values, so 1024 is 1k and 1024k is 1m and so on.
-       If the option accepts an upper and lower range, use a colon ':'
-       or minus '-' to separate such values. May also include a prefix
-       to indicate numbers base. If 0x is used, the number is assumed to
-       be hexadecimal. See irange.
+int    SI integer. A whole number value, which may contain a suffix
+       describing the base of the number. Accepted suffixes are k/m/g/t/p,
+       meaning kilo, mega, giga, tera, and peta. The suffix is not case
+       sensitive. So if you want to specify 4096, you could either write
+       out '4096' or just give 4k. The suffixes signify base 2 values, so
+       1024 is 1k and 1024k is 1m and so on. If the option accepts an upper
+       and lower range, use a colon ':' or minus '-' to separate such values.
+       May also include a prefix to indicate numbers base. If 0x is used,
+       the number is assumed to be hexadecimal. See irange.
 bool   Boolean. Usually parsed as an integer, however only defined for
        true and false (1 and 0).
-irange Integer range with postfix. Allows value range to be given, such
+irange Integer range with suffix. Allows value range to be given, such
        as 1024-4096. A colon may also be used as the separator, eg
        1k:4k. If the option allows two sets of ranges, they can be
        specified with a ',' or '/' delimiter: 1k-4k/8k-32k. Also see
@@ -290,6 +290,11 @@ rw=str             Type of io pattern. Accepted values are:
                IO's, instead of for every IO. Use rw=randread:8 to specify
                that.
 
+kb_base=int    The base unit for a kilobyte. The defacto base is 2^10, 1024.
+               Storage manufacturers like to use 10^3 or 1000 as a base
+               ten unit instead, for obvious reasons. Allow values are
+               1024 or 1000, with 1024 being the default.
+
 randrepeat=bool        For random IO workloads, seed the generator in a predictable
                way so that results are repeatable across repetitions.
 
@@ -595,7 +600,7 @@ thinktime_blocks
                after every block.
 
 rate=int       Cap the bandwidth used by this job. The number is in bytes/sec,
-               the normal postfix rules apply. You can use rate=500k to limit
+               the normal suffix rules apply. You can use rate=500k to limit
                reads and writes to 500k each, or you can specify read and
                writes separately. Using rate=1m,500k would limit reads to
                1MB/sec and writes to 500KB/sec. Capping only reads or
@@ -691,7 +696,7 @@ mem=str             Fio can use various types of memory as the io unit buffer.
                that for shmhuge and mmaphuge to work, the system must have
                free huge pages allocated. This can normally be checked
                and set by reading/writing /proc/sys/vm/nr_hugepages on a
-               Linux system. Fio assumes a huge page is 4MiB in size. So
+               Linux system. Fio assumes a huge page is 4MB in size. So
                to calculate the number of huge pages you need for a given
                job file, add up the io depth of all jobs (normally one unless
                iodepth= is used) and multiply by the maximum bs set. Then
@@ -715,7 +720,7 @@ iomem_align=int     This indiciates the memory alignment of the IO memory buffers.
 
 hugepage-size=int
                Defines the size of a huge page. Must at least be equal
-               to the system setting, see /proc/meminfo. Defaults to 4MiB.
+               to the system setting, see /proc/meminfo. Defaults to 4MB.
                Should probably always be a multiple of megabytes, so using
                hugepage-size=Xm is the preferred way to set this to avoid
                setting a non-pow-2 bad value.
@@ -1005,10 +1010,10 @@ each thread, group of threads, and disks in that order. For each data
 direction, the output looks like:
 
 Client1 (g=0): err= 0:
-  write: io=    32MiB, bw=   666KiB/s, runt= 50320msec
+  write: io=    32MB, bw=   666KB/s, runt= 50320msec
     slat (msec): min=    0, max=  136, avg= 0.03, stdev= 1.92
     clat (msec): min=    0, max=  631, avg=48.50, stdev=86.82
-    bw (KiB/s) : min=    0, max= 1196, per=51.00%, avg=664.02, stdev=681.68
+    bw (KB/s) : min=    0, max= 1196, per=51.00%, avg=664.02, stdev=681.68
   cpu        : usr=1.49%, sys=0.25%, ctx=7969, majf=0, minf=17
   IO depths    : 1=0.1%, 2=0.3%, 4=0.5%, 8=99.0%, 16=0.0%, 32=0.0%, >32=0.0%
      submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
@@ -1068,8 +1073,8 @@ After each client has been listed, the group statistics are printed. They
 will look like this:
 
 Run status group 0 (all jobs):
-   READ: io=64MiB, aggrb=22178, minb=11355, maxb=11814, mint=2840msec, maxt=2955msec
-  WRITE: io=64MiB, aggrb=1302, minb=666, maxb=669, mint=50093msec, maxt=50320msec
+   READ: io=64MB, aggrb=22178, minb=11355, maxb=11814, mint=2840msec, maxt=2955msec
+  WRITE: io=64MB, aggrb=1302, minb=666, maxb=669, mint=50093msec, maxt=50320msec
 
 For each data direction, it prints:
 
@@ -1112,12 +1117,12 @@ Split up, the format is as follows:
 
        jobname, groupid, error
        READ status:
-               KiB IO, bandwidth (KiB/sec), runtime (msec)
+               KB IO, bandwidth (KB/sec), runtime (msec)
                Submission latency: min, max, mean, deviation
                Completion latency: min, max, mean, deviation
                Bw: min, max, aggregate percentage of total, mean, deviation
        WRITE status:
-               KiB IO, bandwidth (KiB/sec), runtime (msec)
+               KB IO, bandwidth (KB/sec), runtime (msec)
                Submission latency: min, max, mean, deviation
                Completion latency: min, max, mean, deviation
                Bw: min, max, aggregate percentage of total, mean, deviation
diff --git a/README b/README
index 480f1d0ef6d455efa1e49c672def112b0607e6c1..d5235de39a6ff7dfa32b9e055cbaac5974e7fc2a 100644 (file)
--- a/README
+++ b/README
@@ -202,8 +202,8 @@ The job file parameters are:
                        also include k/m postfix.
        direct=x        1 for direct IO, 0 for buffered IO
        thinktime=x     "Think" x usec after each io
-       rate=x          Throttle rate to x KiB/sec
-       ratemin=x       Quit if rate of x KiB/sec can't be met
+       rate=x          Throttle rate to x KB/sec
+       ratemin=x       Quit if rate of x KB/sec can't be met
        ratecycle=x     ratemin averaged over x msecs
        cpumask=x       Only allow job to run on CPUs defined by mask.
        cpus_allowed=x  Like 'cpumask', but allow text setting of CPU affinity.
diff --git a/eta.c b/eta.c
index 9573e8a6c97fc950c1613af91876f1755a92b000..8dbff985cac272795038a53d21ff14037fd6e825 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -232,6 +232,7 @@ void print_thread_status(void)
        static unsigned int rate[2], iops[2];
        static int linelen_last;
        static int eta_good;
+       int i2p = 0;
 
        if (temp_stall_ts || terse_output || eta_print == FIO_ETA_NEVER)
                return;
@@ -292,6 +293,8 @@ void print_thread_status(void)
                eta_sec = 0;
 
        for_each_td(td, i) {
+               if (!i2p && is_power_of_2(td->o.kb_base))
+                       i2p = 1;
                if (exitall_on_terminate) {
                        if (eta_secs[i] < eta_sec)
                                eta_sec = eta_secs[i];
@@ -334,9 +337,9 @@ void print_thread_status(void)
        if (m_rate || t_rate) {
                char *tr, *mr;
 
-               mr = num2str(m_rate, 4, 0, 1);
-               tr = num2str(t_rate, 4, 0, 1);
-               printf(", CR=%s/%s KiB/s", tr, mr);
+               mr = num2str(m_rate, 4, 0, i2p);
+               tr = num2str(t_rate, 4, 0, i2p);
+               printf(", CR=%s/%s KB/s", tr, mr);
                free(tr);
                free(mr);
        } else if (m_iops || t_iops)
@@ -355,8 +358,8 @@ void print_thread_status(void)
                        sprintf(perc_str, "%3.1f%% done", perc);
                }
 
-               rate_str[0] = num2str(rate[0], 5, 10, 1);
-               rate_str[1] = num2str(rate[1], 5, 10, 1);
+               rate_str[0] = num2str(rate[0], 5, 10, i2p);
+               rate_str[1] = num2str(rate[1], 5, 10, i2p);
 
                iops_str[0] = num2str(iops[0], 4, 1, 0);
                iops_str[1] = num2str(iops[1], 4, 1, 0);
index 1a5a7eccb1b8c95c545c7b94923990d6a005e23c..d7c83a796f29401752e9c6030988732dd1e1d4ad 100644 (file)
@@ -611,7 +611,7 @@ int setup_files(struct thread_data *td)
                temp_stall_ts = 1;
                if (!terse_output)
                        log_info("%s: Laying out IO file(s) (%u file(s) /"
-                                " %LuMiB)\n", td->o.name, need_extend,
+                                " %LuMB)\n", td->o.name, need_extend,
                                        extend_size >> 20);
 
                for_each_file(td, f, i) {
diff --git a/fio.1 b/fio.1
index fa54763dbc43fca5876f287fac908384d82b3d89..b3925b5f19b766b3cdba94ceca463e01adcde58b 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -78,9 +78,10 @@ String: a sequence of alphanumeric characters.
 .TP
 .I int
 SI integer: a whole number, possibly containing a suffix denoting the base unit
-of the value.  Accepted suffixes are `k', 'M' and 'G', denoting kilo (1024),
-mega (1024*1024) and giga (1024*1024*1024) respectively. If prefixed with '0x',
-the value is assumed to be base 16 (hexadecimal).
+of the value.  Accepted suffixes are `k', 'M', 'G', 'T', and 'P', denoting
+kilo (1024), mega (1024^2), giga (1024^3), tera (1024^4), and peta (1024^5)
+respectively. The suffix is not case sensitive. If prefixed with '0x', the
+value is assumed to be base 16 (hexadecimal).
 .TP
 .I bool
 Boolean: a true or false value. `0' denotes false, `1' denotes true.
@@ -172,6 +173,11 @@ to perform before getting a new offset can be specified by appending
 `:\fIint\fR' to the pattern type.  The default is 1.
 .RE
 .TP
+.BI kb_base \fR=\fPint
+The base unit for a kilobyte. The defacto base is 2^10, 1024.  Storage
+manufacturers like to use 10^3 or 1000 as a base ten unit instead, for obvious
+reasons. Allow values are 1024 or 1000, with 1024 being the default.
+.TP
 .BI randrepeat \fR=\fPbool
 Seed the random number generator in a predictable way so results are repeatable
 across runs.  Default: true.
@@ -523,7 +529,7 @@ sum of the \fBiomem_align\fR and \fBbs\fR used.
 .TP
 .BI hugepage\-size \fR=\fPint
 Defines the size of a huge page.  Must be at least equal to the system setting.
-Should be a multiple of 1MiB. Default: 4MiB.
+Should be a multiple of 1MB. Default: 4MB.
 .TP
 .B exitall
 Terminate all jobs when one finishes.  Default: wait for each job to finish.
@@ -871,7 +877,7 @@ semicolon-delimited format suitable for scripted use.  The fields are:
 .P
 Read status:
 .RS
-.B KiB I/O, bandwidth \fR(KiB/s)\fP, runtime \fR(ms)\fP
+.B KB I/O, bandwidth \fR(KB/s)\fP, runtime \fR(ms)\fP
 .P
 Submission latency:
 .RS
@@ -889,7 +895,7 @@ Bandwidth:
 .P
 Write status:
 .RS
-.B KiB I/O, bandwidth \fR(KiB/s)\fP, runtime \fR(ms)\fP
+.B KB I/O, bandwidth \fR(KB/s)\fP, runtime \fR(ms)\fP
 .P
 Submission latency:
 .RS
diff --git a/fio.c b/fio.c
index fc6dd8aecbc0e11561dc23f8a0bbaec9a73565cc..ba9e384b6609950a8c500dab96de39d0c8bce904 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -223,7 +223,7 @@ static int __check_min_rate(struct thread_data *td, struct timeval *now,
                                if (rate < ratemin ||
                                    bytes < td->rate_bytes[ddir]) {
                                        log_err("%s: min rate %u not met, got"
-                                               " %luKiB/sec\n", td->o.name,
+                                               " %luKB/sec\n", td->o.name,
                                                        ratemin, rate);
                                        return 1;
                                }
diff --git a/fio.h b/fio.h
index fb70b465bec4e1da83a9359b8d2dbe39d84d5c24..56d3101d94f1d7cf9e720abaf4a700dba83f309b 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -42,6 +42,7 @@ struct group_run_stats {
        unsigned long long max_bw[2], min_bw[2];
        unsigned long long io_kb[2];
        unsigned long long agg[2];
+       unsigned int kb_base;
 };
 
 /*
@@ -118,6 +119,8 @@ struct thread_stat {
        unsigned continue_on_error;
        unsigned long total_err_count;
        int first_error;
+
+       unsigned int kb_base;
 };
 
 struct bssplit {
@@ -134,6 +137,7 @@ struct thread_options {
        char *opendir;
        char *ioengine;
        enum td_ddir td_ddir;
+       unsigned int kb_base;
        unsigned int ddir_nr;
        unsigned int iodepth;
        unsigned int iodepth_low;
index 9b1e1ca59ecf7df69d38aa2769e9b84c25b5c1c5..4e2cb08e1045a75a83a8d5a88c7113a2a3153136 100755 (executable)
@@ -30,7 +30,7 @@ done
 
 if [ "$PLOT_LINE"x != "x" ]; then
        echo Making bw logs
-       echo "set title 'Bandwidth - $TITLE'; set xlabel 'time (msec)'; set ylabel 'KiB/sec'; set terminal png; set output '$TITLE-bw.png'; plot " $PLOT_LINE | $GNUPLOT -
+       echo "set title 'Bandwidth - $TITLE'; set xlabel 'time (msec)'; set ylabel 'KB/sec'; set terminal png; set output '$TITLE-bw.png'; plot " $PLOT_LINE | $GNUPLOT -
 fi
 
 PLOT_LINE=""
index 00339e42663f25522ca1269c35883610a0d1e552..9b49d3986fc78584743cc4e047cd11cdfdd7e4ac 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -39,7 +39,7 @@ int fio_pin_memory(void)
        if (phys_mem) {
                if ((mlock_size + 128 * 1024 * 1024) > phys_mem) {
                        mlock_size = phys_mem - 128 * 1024 * 1024;
-                       log_info("fio: limiting mlocked memory to %lluMiB\n",
+                       log_info("fio: limiting mlocked memory to %lluMB\n",
                                                        mlock_size >> 20);
                }
        }
index 0954ccdb2bd9138b45ad36d9b7cd25e0d8a2bdd3..6941af0e8d9efa91e1a7a0d67152e9266322432f 100644 (file)
--- a/options.c
+++ b/options.c
@@ -82,7 +82,7 @@ static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
                } else
                        perc = -1;
 
-               if (str_to_decimal(fname, &val, 1)) {
+               if (str_to_decimal(fname, &val, 1, &td)) {
                        log_err("fio: bssplit conversion failed\n");
                        free(td->o.bssplit);
                        return 1;
@@ -627,6 +627,19 @@ static int gtod_cpu_verify(struct fio_option *o, void *data)
        return 0;
 }
 
+static int kb_base_verify(struct fio_option *o, void *data)
+{
+       struct thread_data *td = data;
+
+       if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
+               log_err("fio: kb_base set to nonsensical value: %u\n",
+                               td->o.kb_base);
+               return 1;
+       }
+
+       return 0;
+}
+
 #define __stringify_1(x)       #x
 #define __stringify(x)         __stringify_1(x)
 
@@ -661,6 +674,15 @@ static struct fio_option options[] = {
                .prio   = -1, /* must come after "directory" */
                .help   = "File(s) to use for the workload",
        },
+       {
+               .name   = "kb_base",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(kb_base),
+               .verify = kb_base_verify,
+               .prio   = 1,
+               .def    = "1024",
+               .help   = "How many bytes per KB for reporting (1000 or 1024)",
+       },
        {
                .name   = "lockfile",
                .type   = FIO_OPT_STR,
@@ -1694,3 +1716,16 @@ void options_mem_free(struct thread_data fio_unused *td)
        __options_mem(td, 0);
 #endif
 }
+
+unsigned int fio_get_kb_base(void *data)
+{
+       struct thread_data *td = data;
+       unsigned int kb_base = 0;
+
+       if (td)
+               kb_base = td->o.kb_base;
+       if (!kb_base)
+               kb_base = 1024;
+
+       return kb_base;
+}
diff --git a/parse.c b/parse.c
index 5043374405d8a1e262687a5a1bdcac90f18990cf..b0ea3d3a5bae985d14c1a7f71a5bf2198ae45615 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -14,6 +14,7 @@
 #include "debug.h"
 
 static struct fio_option *fio_options;
+extern unsigned int fio_get_kb_base(void *);
 
 static int vp_cmp(const void *p1, const void *p2)
 {
@@ -41,15 +42,15 @@ static void posval_sort(struct fio_option *o, struct value_pair *vpmap)
        qsort(vpmap, entries, sizeof(struct value_pair), vp_cmp);
 }
 
-static void show_option_range(struct fio_option *o)
+static void show_option_range(struct fio_option *o, FILE *out)
 {
        if (!o->minval && !o->maxval)
                return;
 
-       printf("%20s: min=%d", "range", o->minval);
+       fprintf(out, "%20s: min=%d", "range", o->minval);
        if (o->maxval)
-               printf(", max=%d", o->maxval);
-       printf("\n");
+               fprintf(out, ", max=%d", o->maxval);
+       fprintf(out, "\n");
 }
 
 static void show_option_values(struct fio_option *o)
@@ -73,6 +74,28 @@ static void show_option_values(struct fio_option *o)
                printf("\n");
 }
 
+static void show_option_help(struct fio_option *o, FILE *out)
+{
+       const char *typehelp[] = {
+               "string (opt=bla)",
+               "string with possible k/m/g postfix (opt=4k)",
+               "string with time postfix (opt=10s)",
+               "string (opt=bla)",
+               "string with dual range (opt=1k-4k,4k-8k)",
+               "integer value (opt=100)",
+               "boolean value (opt=1)",
+               "no argument (opt)",
+       };
+
+       if (o->alias)
+               fprintf(out, "%20s: %s\n", "alias", o->alias);
+
+       fprintf(out, "%20s: %s\n", "type", typehelp[o->type]);
+       fprintf(out, "%20s: %s\n", "default", o->def ? o->def : "no default");
+       show_option_range(o, stdout);
+       show_option_values(o);
+}
+
 static unsigned long get_mult_time(char c)
 {
        switch (c) {
@@ -90,30 +113,39 @@ static unsigned long get_mult_time(char c)
        }
 }
 
-static unsigned long get_mult_bytes(char c)
+static unsigned long long get_mult_bytes(char c, void *data)
 {
+       unsigned int kb_base = fio_get_kb_base(data);
+       unsigned long long ret = 1;
+
        switch (c) {
-       case 'k':
-       case 'K':
-               return 1024;
-       case 'm':
-       case 'M':
-               return 1024 * 1024;
+       default:
+               break;
+       case 'p':
+       case 'P':
+               ret *= (unsigned long long) kb_base;
+       case 't':
+       case 'T':
+               ret *= (unsigned long long) kb_base;
        case 'g':
        case 'G':
-               return 1024 * 1024 * 1024;
-       case 'e':
-       case 'E':
-               return 1024 * 1024 * 1024 * 1024UL;
-       default:
-               return 1;
+               ret *= (unsigned long long) kb_base;
+       case 'm':
+       case 'M':
+               ret *= (unsigned long long) kb_base;
+       case 'k':
+       case 'K':
+               ret *= (unsigned long long) kb_base;
+               break;
        }
+
+       return ret;
 }
 
 /*
  * convert string into decimal value, noting any size suffix
  */
-int str_to_decimal(const char *str, long long *val, int kilo)
+int str_to_decimal(const char *str, long long *val, int kilo, void *data)
 {
        int len, base;
 
@@ -131,21 +163,21 @@ int str_to_decimal(const char *str, long long *val, int kilo)
                return 1;
 
        if (kilo)
-               *val *= get_mult_bytes(str[len - 1]);
+               *val *= get_mult_bytes(str[len - 1], data);
        else
                *val *= get_mult_time(str[len - 1]);
 
        return 0;
 }
 
-static int check_str_bytes(const char *p, long long *val)
+static int check_str_bytes(const char *p, long long *val, void *data)
 {
-       return str_to_decimal(p, val, 1);
+       return str_to_decimal(p, val, 1, data);
 }
 
 static int check_str_time(const char *p, long long *val)
 {
-       return str_to_decimal(p, val, 0);
+       return str_to_decimal(p, val, 0, NULL);
 }
 
 void strip_blank_front(char **p)
@@ -178,7 +210,7 @@ void strip_blank_end(char *p)
        *(s + 1) = '\0';
 }
 
-static int check_range_bytes(const char *str, long *val)
+static int check_range_bytes(const char *str, long *val, void *data)
 {
        char suffix;
 
@@ -186,7 +218,7 @@ static int check_range_bytes(const char *str, long *val)
                return 1;
 
        if (sscanf(str, "%lu%c", val, &suffix) == 2) {
-               *val *= get_mult_bytes(suffix);
+               *val *= get_mult_bytes(suffix, data);
                return 0;
        }
 
@@ -287,7 +319,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                if (is_time)
                        ret = check_str_time(ptr, &ull);
                else
-                       ret = check_str_bytes(ptr, &ull);
+                       ret = check_str_bytes(ptr, &ull, data);
 
                if (ret)
                        break;
@@ -354,8 +386,8 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                p1 = tmp;
 
                ret = 1;
-               if (!check_range_bytes(p1, &ul1) &&
-                   !check_range_bytes(p2, &ul2)) {
+               if (!check_range_bytes(p1, &ul1, data) &&
+                   !check_range_bytes(p2, &ul2, data)) {
                        ret = 0;
                        if (ul1 > ul2) {
                                unsigned long foo = ul1;
@@ -431,8 +463,14 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
        if (ret)
                return ret;
 
-       if (o->verify)
+       if (o->verify) {
                ret = o->verify(o, data);
+               if (ret) {
+                       fprintf(stderr,"Correct format for offending option\n");
+                       fprintf(stderr, "%20s: %s\n", o->name, o->help);
+                       show_option_help(o, stderr);
+               }
+       }
 
        return ret;
 }
@@ -668,28 +706,6 @@ static int string_distance(const char *s1, const char *s2)
        return i;
 }
 
-static void show_option_help(struct fio_option *o)
-{
-       const char *typehelp[] = {
-               "string (opt=bla)",
-               "string with possible k/m/g postfix (opt=4k)",
-               "string with time postfix (opt=10s)",
-               "string (opt=bla)",
-               "string with dual range (opt=1k-4k,4k-8k)",
-               "integer value (opt=100)",
-               "boolean value (opt=1)",
-               "no argument (opt)",
-       };
-
-       if (o->alias)
-               printf("%20s: %s\n", "alias", o->alias);
-
-       printf("%20s: %s\n", "type", typehelp[o->type]);
-       printf("%20s: %s\n", "default", o->def ? o->def : "no default");
-       show_option_range(o);
-       show_option_values(o);
-}
-
 static struct fio_option *find_child(struct fio_option *options,
                                     struct fio_option *o)
 {
@@ -794,7 +810,7 @@ int show_cmd_help(struct fio_option *options, const char *name)
                if (!match)
                        continue;
 
-               show_option_help(o);
+               show_option_help(o, stdout);
        }
 
        if (found)
@@ -804,7 +820,7 @@ int show_cmd_help(struct fio_option *options, const char *name)
        if (closest) {
                printf(" - showing closest match\n");
                printf("%20s: %s\n", closest->name, closest->help);
-               show_option_help(closest);
+               show_option_help(closest, stdout);
        } else
                printf("\n");
 
diff --git a/parse.h b/parse.h
index 677b62b969850582c8e6419d838ec549b6b5dc5f..5b1a53deb748a1beb61dfce5ae5b62c087b7c2c4 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -62,7 +62,7 @@ extern void options_init(struct fio_option *);
 
 extern void strip_blank_front(char **);
 extern void strip_blank_end(char *);
-extern int str_to_decimal(const char *, long long *, int);
+extern int str_to_decimal(const char *, long long *, int, void *);
 
 /*
  * Handlers for the options
diff --git a/stat.c b/stat.c
index e1af59ed57dbb981dc9fbd1f3e9a69cb1275b7b3..c52620d374f01f7c51241a971c018a4722e60914 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -59,15 +59,17 @@ static void show_group_stats(struct group_run_stats *rs, int id)
        log_info("\nRun status group %d (all jobs):\n", id);
 
        for (i = 0; i <= DDIR_WRITE; i++) {
+               const int i2p = is_power_of_2(rs->kb_base);
+
                if (!rs->max_run[i])
                        continue;
 
-               p1 = num2str(rs->io_kb[i], 6, 1024, 1);
-               p2 = num2str(rs->agg[i], 6, 1024, 1);
-               p3 = num2str(rs->min_bw[i], 6, 1024, 1);
-               p4 = num2str(rs->max_bw[i], 6, 1024, 1);
+               p1 = num2str(rs->io_kb[i], 6, rs->kb_base, i2p);
+               p2 = num2str(rs->agg[i], 6, rs->kb_base, i2p);
+               p3 = num2str(rs->min_bw[i], 6, rs->kb_base, i2p);
+               p4 = num2str(rs->max_bw[i], 6, rs->kb_base, i2p);
 
-               log_info("%s: io=%siB, aggrb=%siB/s, minb=%siB/s, maxb=%siB/s,"
+               log_info("%s: io=%sB, aggrb=%sB/s, minb=%sB/s, maxb=%sB/s,"
                         " mint=%llumsec, maxt=%llumsec\n", ddir_str[i], p1, p2,
                                                p3, p4, rs->min_run[i],
                                                rs->max_run[i]);
@@ -153,20 +155,22 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
        unsigned long long bw, iops;
        double mean, dev;
        char *io_p, *bw_p, *iops_p;
+       int i2p;
 
        if (!ts->runtime[ddir])
                return;
 
+       i2p = is_power_of_2(rs->kb_base);
        runt = ts->runtime[ddir];
 
        bw = (1000 * ts->io_bytes[ddir]) / runt;
-       io_p = num2str(ts->io_bytes[ddir] >> 10, 6, 1024, 1);
-       bw_p = num2str(bw >> 10, 6, 1024, 1);
+       io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p);
+       bw_p = num2str(bw, 6, 1, i2p);
 
        iops = (1000 * ts->total_io_u[ddir]) / runt;
        iops_p = num2str(iops, 6, 1, 0);
 
-       log_info("  %s: io=%siB, bw=%siB/s, iops=%s, runt=%6lumsec\n",
+       log_info("  %s: io=%sB, bw=%sB/s, iops=%s, runt=%6lumsec\n",
                                        ddir_str[ddir], io_p, bw_p, iops_p,
                                        ts->runtime[ddir]);
 
@@ -210,7 +214,7 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
                double p_of_agg;
 
                p_of_agg = mean * 100 / (double) rs->agg[ddir];
-               log_info("    bw (KiB/s) : min=%5lu, max=%5lu, per=%3.2f%%,"
+               log_info("    bw (KB/s) : min=%5lu, max=%5lu, per=%3.2f%%,"
                         " avg=%5.02f, stdev=%5.02f\n", min, max, p_of_agg,
                                                        mean, dev);
        }
@@ -457,6 +461,7 @@ void show_run_stats(void)
        struct thread_data *td;
        struct thread_stat *threadstats, *ts;
        int i, j, k, l, nr_ts, last_ts, idx;
+       int kb_base_warned = 0;
 
        runstats = malloc(sizeof(struct group_run_stats) * (groupid + 1));
 
@@ -529,6 +534,12 @@ void show_run_stats(void)
                         * first pid in group, not very useful...
                         */
                        ts->pid = td->pid;
+
+                       ts->kb_base = td->o.kb_base;
+               } else if (ts->kb_base != td->o.kb_base && !kb_base_warned) {
+                       log_info("fio: kb_base differs for jobs in group, using"
+                                " %u as the base\n", ts->kb_base);
+                       kb_base_warned = 1;
                }
 
                ts->continue_on_error = td->o.continue_on_error;
@@ -590,6 +601,7 @@ void show_run_stats(void)
 
                ts = &threadstats[i];
                rs = &runstats[ts->groupid];
+               rs->kb_base = ts->kb_base;
 
                for (j = 0; j <= DDIR_WRITE; j++) {
                        if (!ts->runtime[j])
@@ -603,7 +615,7 @@ void show_run_stats(void)
                        if (ts->runtime[j]) {
                                unsigned long runt;
 
-                               runt = ts->runtime[j] * 1024 / 1000;
+                               runt = ts->runtime[j];
                                bw = ts->io_bytes[j] / runt;
                        }
                        if (bw < rs->min_bw[j])
@@ -611,7 +623,7 @@ void show_run_stats(void)
                        if (bw > rs->max_bw[j])
                                rs->max_bw[j] = bw;
 
-                       rs->io_kb[j] += ts->io_bytes[j] >> 10;
+                       rs->io_kb[j] += ts->io_bytes[j] / rs->kb_base;
                }
        }
 
@@ -619,13 +631,13 @@ void show_run_stats(void)
                unsigned long max_run[2];
 
                rs = &runstats[i];
-               max_run[0] = rs->max_run[0] * 1024 / 1000;
-               max_run[1] = rs->max_run[1] * 1024 / 1000;
+               max_run[0] = rs->max_run[0];
+               max_run[1] = rs->max_run[1];
 
                if (rs->max_run[0])
-                       rs->agg[0] = (rs->io_kb[0]*1024) / max_run[0];
+                       rs->agg[0] = (rs->io_kb[0] * 1000) / max_run[0];
                if (rs->max_run[1])
-                       rs->agg[1] = (rs->io_kb[1]*1024) / max_run[1];
+                       rs->agg[1] = (rs->io_kb[1] * 1000) / max_run[1];
        }
 
        /*