fio.git
7 years agogenerate unique pathname for each fio --client log file
Ben England [Tue, 6 Sep 2016 16:21:30 +0000 (12:21 -0400)]
generate unique pathname for each fio --client log file

7 years agoMakes use of configparser portable to older versions by:
Karl Cronburg [Tue, 6 Sep 2016 14:22:00 +0000 (10:22 -0400)]
Makes use of configparser portable to older versions by:
- relying on its' own NoOptionError exception
- using getter method instead of dictionary overriding
- and using readfp() as older version does not autodetect fp vs string types

Signed-off-by: Karl Cronburg <karl.cronburg@gmail.com>
7 years agoserver: bump version
Jens Axboe [Fri, 2 Sep 2016 17:24:59 +0000 (11:24 -0600)]
server: bump version

Previous histogram commit changes the client/server protocol,
bump the version.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoMerge branch 'histogram-client-server' of https://github.com/cronburg/fio
Jens Axboe [Fri, 2 Sep 2016 17:24:15 +0000 (11:24 -0600)]
Merge branch 'histogram-client-server' of https://github.com/cronburg/fio

7 years agojesd219: fix alignment
Jeff Furlong [Mon, 29 Aug 2016 21:43:27 +0000 (15:43 -0600)]
jesd219: fix alignment

Previously we added the bssplit option to accommodate more advanced
blocksize lists.  However, blockalign appears to default to the smallest
element in the bssplit list.  If so, we must update the example JESD219
workload to explicitly specify blockalign=4k, to satisfy the JESD219
workload requirement ("data payloads greater than or equal to 4096 bytes
are aligned on 4k boundaries").  There is no explicit alignment
requirement for <4KB blocksizes, so at this time, there seems to be no
need to specify a separate alignment for some blocksizes in bssplit
list.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoFIO-VERSION-GEN: fix dirty repo tracking
Jens Axboe [Mon, 29 Aug 2016 19:40:08 +0000 (13:40 -0600)]
FIO-VERSION-GEN: fix dirty repo tracking

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agofilelock: bool conversion
Jens Axboe [Mon, 29 Aug 2016 17:44:32 +0000 (11:44 -0600)]
filelock: bool conversion

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agotrim: convert to bool
Jens Axboe [Mon, 29 Aug 2016 16:37:44 +0000 (10:37 -0600)]
trim: convert to bool

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agobackend: check if we need to update rusage stats, if stat_mutex is busy
Jens Axboe [Fri, 26 Aug 2016 20:39:30 +0000 (14:39 -0600)]
backend: check if we need to update rusage stats, if stat_mutex is busy

Even with the fix to check if we need to update rusage happening
right before the stat_mutex lock, we can still deadlock. This
looks something like the below:

helper_thread                   job

lock(stat_mutex);
                                lock(stat_mutex);
down(td->rusage_sem);

And now are both effectively locked in an ABBA deadlock. The helper
thread is waiting for the job to update it's rusage, but the job
is stuck waiting for the stat_mutex.

Fix this by doing a trylock on the stat_mutex, and if it fails,
ensure that we update rusage.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoClient / server code for handling histograms. The server:
Karl Cronburg [Wed, 24 Aug 2016 20:12:20 +0000 (16:12 -0400)]
Client / server code for handling histograms. The server:

- Deals with subtracting consecutive histograms so that client
  doesn't have to recreate linked list.
- Uses existing IOLOG command code to create packets, checking
  for IO_LOG_TYPE_HIST when necessary.

And the client:

- Reconstructs the pointers to the histogram bins from the packet
  format, namely (sample_0, hist_0, sample_1, hist_1, ...) in lieu
  of the current (sample_0, sample_1, ...) format used for the (void *)
  cur_log->samples.
- Flushes histograms to file with updated pointer calculation to get
  ith sample, disabling subtraction in hist_sum() using a null
  pointer.

This does not cover plain-text transmission mode (i.e. when zlib is
not present during fio compilation).

Signed-off-by: Karl Cronburg <kcronbur@redhat.com>
7 years agofile: fio_files_done() can return bool
Jens Axboe [Fri, 26 Aug 2016 14:34:41 +0000 (08:34 -0600)]
file: fio_files_done() can return bool

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agofile: fix numjobs > 1 and implied jobname as filename
Jens Axboe [Fri, 26 Aug 2016 03:00:55 +0000 (21:00 -0600)]
file: fix numjobs > 1 and implied jobname as filename

If we have a jobfile that looks like:

[global]
numjobs=4

[/dev/somedevice]

Then we fail jobs 2 and on, since we don't properly add those
files. Fix this by checking if we're generating a filename
based on the jobname.

Fixes: bcbfeefa7bce ("fio: add multi directory support")
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoMerge branch 'epoch-histograms' of https://github.com/cronburg/fio
Jens Axboe [Thu, 25 Aug 2016 22:03:20 +0000 (16:03 -0600)]
Merge branch 'epoch-histograms' of https://github.com/cronburg/fio

7 years agoGive job file to fiologparser_hist.py so that it can auto detect
Karl Cronburg [Thu, 25 Aug 2016 21:37:21 +0000 (17:37 -0400)]
Give job file to fiologparser_hist.py so that it can auto detect
log_hist_msec. This commit also adds handling of unix epoch
timestamps by fiologparser_hist.py.

Signed-off-by: Karl Cronburg <kcronbur@redhat.com>
7 years agostat: don't trust per_unit_log() if log is NULL
Jens Axboe [Mon, 22 Aug 2016 19:23:29 +0000 (13:23 -0600)]
stat: don't trust per_unit_log() if log is NULL

We return 'false' for that case, but it's not really false. Fixes
a sigbus error on sparc, without logging.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoverify: use proper include for PATH_MAX
Jens Axboe [Sat, 20 Aug 2016 16:28:57 +0000 (10:28 -0600)]
verify: use proper include for PATH_MAX

Resolves: https://github.com/axboe/fio/issues/231
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoManual page for fiologparser_hist.py and Makefile updates to install
Karl Cronburg [Thu, 18 Aug 2016 22:56:17 +0000 (18:56 -0400)]
Manual page for fiologparser_hist.py and Makefile updates to install
them.

Signed-off-by: Karl Cronburg <kcronbur@redhat.com>
7 years agoMerge branch 'epoch' of https://github.com/cronburg/fio
Jens Axboe [Thu, 18 Aug 2016 20:38:21 +0000 (14:38 -0600)]
Merge branch 'epoch' of https://github.com/cronburg/fio

7 years agoOption for changing log files to use Unix epoch instead of being
Karl Cronburg [Thu, 18 Aug 2016 16:48:47 +0000 (12:48 -0400)]
Option for changing log files to use Unix epoch instead of being
zero-based (when fio starts) epoch.

This makes it easier to analyze the data in the context of other
benchmarking tools running at the same time as fio.

Signed-off-by: Karl Cronburg <kcronbur@redhat.com>
7 years agoparse: fix void * pointer math complaint
Jens Axboe [Thu, 18 Aug 2016 16:50:33 +0000 (10:50 -0600)]
parse: fix void * pointer math complaint

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoAdd basic write/read-and-verify example job file
Jens Axboe [Thu, 18 Aug 2016 16:03:49 +0000 (10:03 -0600)]
Add basic write/read-and-verify example job file

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agofio: use the proper enum type for the shifted IO engine flags
Jens Axboe [Thu, 18 Aug 2016 14:17:53 +0000 (08:17 -0600)]
fio: use the proper enum type for the shifted IO engine flags

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoFix backwards reads with --size smaller than the file size
Jens Axboe [Tue, 16 Aug 2016 21:22:17 +0000 (15:22 -0600)]
Fix backwards reads with --size smaller than the file size

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agohistogram: style and list fixups
Jens Axboe [Tue, 16 Aug 2016 20:51:41 +0000 (14:51 -0600)]
histogram: style and list fixups

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoMerge branch 'histogram-delta' of https://github.com/cronburg/fio into histogram
Jens Axboe [Tue, 16 Aug 2016 20:47:09 +0000 (14:47 -0600)]
Merge branch 'histogram-delta' of https://github.com/cronburg/fio into histogram

7 years agoMake histogram samples non-cumulative by tracking a linked-list
Karl Cronburg [Tue, 16 Aug 2016 19:44:09 +0000 (15:44 -0400)]
Make histogram samples non-cumulative by tracking a linked-list
of the most recent histogram and differencing it when we print
to the log file(s). Linked list of pointers used to minimize
runtime impact on recording side, instead choosing to do
subtraction on the logging (when logs get printed to file) side.

This helps cleanup fiologparser_hist.py, makes the log files easier
to understand at a glance, reduces file size(s), and averts the
possibility of integer overflow in the logs (for a long enough fio
job).

7 years agoVarious cleanups
Jens Axboe [Tue, 16 Aug 2016 05:36:11 +0000 (23:36 -0600)]
Various cleanups

- Killing unused declarations

- Bool

- Making code static

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agogfio: fix auto-start of backend
Jens Axboe [Tue, 16 Aug 2016 04:05:27 +0000 (22:05 -0600)]
gfio: fix auto-start of backend

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agogfio: fix link error
Jens Axboe [Mon, 15 Aug 2016 20:22:31 +0000 (14:22 -0600)]
gfio: fix link error

Fixes: a89ba4b12939 ("Fixup correct sparse warnings")
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoparse: remove dead code
Jens Axboe [Mon, 15 Aug 2016 20:22:20 +0000 (14:22 -0600)]
parse: remove dead code

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoparse: get rid of __td_var()
Jens Axboe [Mon, 15 Aug 2016 18:13:57 +0000 (12:13 -0600)]
parse: get rid of __td_var()

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoFixup correct sparse warnings
Jens Axboe [Mon, 15 Aug 2016 18:03:39 +0000 (12:03 -0600)]
Fixup correct sparse warnings

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoOption updates
Jens Axboe [Mon, 15 Aug 2016 17:04:30 +0000 (11:04 -0600)]
Option updates

- Missing long name variants

- libhdfs engine, use correct spelling for 'chunk', but retain
  the old spelling as an alias.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agooptions: pass in right pointer to options free
Jens Axboe [Mon, 15 Aug 2016 15:57:09 +0000 (09:57 -0600)]
options: pass in right pointer to options free

Fixes: a609f12a1701 ("options: remove dependency of 'o' being first in 'td'")
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agofio: inherit IO engine flags to 'td'
Jens Axboe [Mon, 15 Aug 2016 15:42:37 +0000 (09:42 -0600)]
fio: inherit IO engine flags to 'td'

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agofio: move thread_options
Jens Axboe [Mon, 15 Aug 2016 15:39:35 +0000 (09:39 -0600)]
fio: move thread_options

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agooptions: remove dependency of 'o' being first in 'td'
Jens Axboe [Mon, 15 Aug 2016 15:31:25 +0000 (09:31 -0600)]
options: remove dependency of 'o' being first in 'td'

- We currently assume that &td->o == td, but it's unfortunate that we
  have to store 3-4K of option data in the first part of 'td'.

- Kill td_var_offset(), just use offsetof() instead.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoOnly enable atomic io_u flag setting/clearing if we need it
Jens Axboe [Mon, 15 Aug 2016 03:31:16 +0000 (21:31 -0600)]
Only enable atomic io_u flag setting/clearing if we need it

Make it dependent on td_async_processing(), like we do for
other cases.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoiolog: silence warning on pointer cast on 32-bit compiles
Jens Axboe [Mon, 8 Aug 2016 17:32:34 +0000 (11:32 -0600)]
iolog: silence warning on pointer cast on 32-bit compiles

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoCheck if sysfs ioscheduler entry is "none"
Tomohiro Kusumi [Mon, 8 Aug 2016 17:27:31 +0000 (02:27 +0900)]
Check if sysfs ioscheduler entry is "none"

Block devices without elevator (bio-based-dm/loop/etc) have "none"
for sysfs ioscheduler tunable, and write to this entry never fail
from the way elv_iosched_store() is implemented.

This commit checks if the entry is "none" type so as not to show
an irrelevant error message which assumes the entry has a list of
available I/O schedulers.

 # cat /sys/block/dm-0/queue/scheduler
 none
 # echo deadline > /sys/block/dm-0/queue/scheduler ; echo $?
 0
 # cat /sys/block/dm-0/queue/scheduler
 none
 # echo aaa > /sys/block/dm-0/queue/scheduler ; echo $?
 0
 # cat /sys/block/dm-0/queue/scheduler
 none

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoUse a pointer to const char* for I/O engine name (in response to aa2b823c)
Tomohiro Kusumi [Mon, 8 Aug 2016 17:27:30 +0000 (02:27 +0900)]
Use a pointer to const char* for I/O engine name (in response to aa2b823c)

aa2b823c also needed to change ioengine_ops::name size to 64,
or make it a pointer to a readonly string which seems to be better
in this case as no one is to (or should be able to) modify it.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoAdd missing FIO_NET_CMD entry to fio_server_ops[]
Tomohiro Kusumi [Mon, 8 Aug 2016 17:27:29 +0000 (02:27 +0900)]
Add missing FIO_NET_CMD entry to fio_server_ops[]

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoMake local const string array static
Tomohiro Kusumi [Mon, 8 Aug 2016 17:27:28 +0000 (02:27 +0900)]
Make local const string array static

like it is in io_ddir_name().

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoChange --output-format argument from optional to required
Tomohiro Kusumi [Mon, 8 Aug 2016 17:27:27 +0000 (02:27 +0900)]
Change --output-format argument from optional to required

Not sure if there were any reason d10983d7 chose to add if(!optarg)
conditional, but this is what other fio options (or in general) do.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoUse char* for pid_file path
Tomohiro Kusumi [Mon, 8 Aug 2016 17:27:26 +0000 (02:27 +0900)]
Use char* for pid_file path

since no function expects this to be void*.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoFix spelling error
Jens Axboe [Mon, 8 Aug 2016 16:25:31 +0000 (10:25 -0600)]
Fix spelling error

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoAdd 'unlink_each_loop' option
mrturtledev [Mon, 8 Aug 2016 15:57:14 +0000 (09:57 -0600)]
Add 'unlink_each_loop' option

If this option is set, fio will unlink the files after each loop
of a job has completed.

Original patch by Martin, various tweaks and updates from me.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoioengines: fixup td_io_unlink_file() error propagation
Jens Axboe [Mon, 8 Aug 2016 15:46:06 +0000 (09:46 -0600)]
ioengines: fixup td_io_unlink_file() error propagation

Return 0 for success, error number on error. gluster already did this,
but pmemblk did not.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoiolog: hist_sum() should return unsigned long
Jens Axboe [Mon, 8 Aug 2016 13:48:33 +0000 (07:48 -0600)]
iolog: hist_sum() should return unsigned long

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agostat: fixups to histogram logging
Jens Axboe [Sun, 7 Aug 2016 21:18:38 +0000 (15:18 -0600)]
stat: fixups to histogram logging

1) Use correct size for the 'dst' passin to __add_log_sample()
2) Various style fixups

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoiolog: style updates
Jens Axboe [Sun, 7 Aug 2016 21:11:32 +0000 (15:11 -0600)]
iolog: style updates

Fixup some slightly off coding style from the histogram logging commit.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoserver: bump protocol version
Jens Axboe [Sun, 7 Aug 2016 21:08:51 +0000 (15:08 -0600)]
server: bump protocol version

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoMerge branch 'histograms-PR' of https://github.com/cronburg/fio
Jens Axboe [Sun, 7 Aug 2016 21:07:53 +0000 (15:07 -0600)]
Merge branch 'histograms-PR' of https://github.com/cronburg/fio

7 years agoThis commit / feature adds completion latency histogram output to fio, piggybacking
Karl Cronburg [Fri, 5 Aug 2016 18:45:00 +0000 (14:45 -0400)]
This commit / feature adds completion latency histogram output to fio, piggybacking
on the existing histograms recorded by stat.c and adding the following command
line options:

- log_hist_msec operates like log_avg_msec does, but produces files
  named *_clat_hist*
- write_hist_log has the same semantics as write_lat_log but for histograms.
- log_hist_coarseness changes how many bins are logged.

The more substantial contribution is a post-processor for digesting these log files,
located in fio/tools/hist/fiologparser_hist.py, which computes min/max/avg/percentile
statistics.

To compare the accuracy of the statistics produced by fiologparser_hist.py,
a reference implementation is located here:

https://github.com/cronburg/fio/blob/histograms/tools/hist/fiologparser_numpy.py

for computing the same statistics from the *_clat.* files fio already produces.
A comparison can be viewed here:

https://cronburg.com/fio/demo/latency.html

The reference implementation is excluded from this commit, as I'm still working
with Mark (markhpc) on getting it into the branch where he's working on fiologparser.
Also I'd eventually like to make FIO_IO_U_PLAT_GROUP_NR in stat.h
configurable (allowing for a larger maximum histogram latency value than 17
seconds), but haven't added it to keep the changes to fio minimal for now.

A more detailed description of the motivation behind this feature, and explanation
of the design process and algorithms used in the post-processor can be found here:

https://cronburg.com/fio/cloud-latency-problem-measurement/

7 years agoRevert "filesetup: ensure that we catch a file flagged for extend"
Jens Axboe [Fri, 5 Aug 2016 01:40:15 +0000 (19:40 -0600)]
Revert "filesetup: ensure that we catch a file flagged for extend"

This reverts commit bcb7260a54438ab38a5928279f7e5a3a465ed1bb.

Don't think this was a functionally sound change, let's revert
to the previous behavior of create_on_open.

7 years agotravis: don't enable rbd
Jens Axboe [Wed, 3 Aug 2016 16:18:42 +0000 (10:18 -0600)]
travis: don't enable rbd

Apparently it fails with an older version of the rbd library. Need
to figure out how to check and test for that.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agotravis: add rbd/zlib
Jens Axboe [Wed, 3 Aug 2016 16:14:10 +0000 (10:14 -0600)]
travis: add rbd/zlib

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agofilesetup: ensure that we catch a file flagged for extend
Jens Axboe [Wed, 3 Aug 2016 15:53:34 +0000 (09:53 -0600)]
filesetup: ensure that we catch a file flagged for extend

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoiolog: prevent early entry from skewing entire logging run
Jens Axboe [Wed, 3 Aug 2016 15:11:56 +0000 (09:11 -0600)]
iolog: prevent early entry from skewing entire logging run

If we go out of ramp time, our wakeup trigger could cause us to enter
too early in add_log_sample(). If that happens, the time diff could be
negative (so huge unsigned). Since we carry that forward, we end up
logging every entry and not just over the average window.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agofix typo in HOWTO
Jan Fajerski [Wed, 3 Aug 2016 11:35:27 +0000 (13:35 +0200)]
fix typo in HOWTO

7 years agofix typo in HOWTO
Jan Fajerski [Wed, 3 Aug 2016 11:22:16 +0000 (13:22 +0200)]
fix typo in HOWTO

7 years agoengines/rbd: fix compile without blkin support
Jens Axboe [Tue, 2 Aug 2016 21:23:43 +0000 (15:23 -0600)]
engines/rbd: fix compile without blkin support

If we don't have rbd-blkin support, compile fails with:

engines/rbd.c:21:26: error: field ‘info’ has incomplete type
  struct blkin_trace_info info;
                          ^~~~
Makefile:313: recipe for target 'engines/rbd.o' failed

Hide 'info' behind the ifdef.

Fixes: a4c4c3460bd5 ("Add support for blkin tracing in rbd engine")
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoMerge branch 'wip-traceinfo' of https://github.com/vears91/fio
Jens Axboe [Tue, 2 Aug 2016 21:05:59 +0000 (15:05 -0600)]
Merge branch 'wip-traceinfo' of https://github.com/vears91/fio

7 years agoRevert "filesetup: ensure that we align file starting offset"
Jens Axboe [Tue, 2 Aug 2016 15:07:07 +0000 (09:07 -0600)]
Revert "filesetup: ensure that we align file starting offset"

There are valid reasons to use an offset that isn't a multiple
of the block size. We previously made this change to fix an
issue with a job file, but that job file had an offset that
wasn't a multiple of the hardware block size. As long as the
offset is a multiple of the hardware block size for unbuffered
IO, then it should be fine.

This reverts commit c465cd14ca958dfdb87bb1998add722d62ae3691.

7 years agobackend: do_verify() cleanup
Jens Axboe [Mon, 1 Aug 2016 19:46:17 +0000 (13:46 -0600)]
backend: do_verify() cleanup

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agobackend: do_dry_run(): get_io_u() can return an error pointer
Jens Axboe [Fri, 29 Jul 2016 15:59:38 +0000 (09:59 -0600)]
backend: do_dry_run(): get_io_u() can return an error pointer

Don't just check for NULL.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoUse larger local buffer for I/O engine name
Tomohiro Kusumi [Fri, 29 Jul 2016 15:06:00 +0000 (00:06 +0900)]
Use larger local buffer for I/O engine name

16 bytes may not be large enough in the future if a new I/O engine
with a name longer than strlen(name)=15 is added.

The longest one right now seems to be "fusion-aw-sync" which is 14(+1).

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoNull terminate before (or after) strncpy(3)
Tomohiro Kusumi [Fri, 29 Jul 2016 15:05:59 +0000 (00:05 +0900)]
Null terminate before (or after) strncpy(3)

These three strncpy() calls copy at most sizeof(buffer)-1 bytes,
but buffer isn't explicitly 0 cleared, so 0 terminate the last byte.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoMake switch_ioscheduler() return 0 if FIO_HAVE_IOSCHED_SWITCH is undefined
Tomohiro Kusumi [Fri, 29 Jul 2016 15:05:58 +0000 (00:05 +0900)]
Make switch_ioscheduler() return 0 if FIO_HAVE_IOSCHED_SWITCH is undefined

Defining FIO_HAVE_IOSCHED_SWITCH currently equals saying it's Linux,
as switch_ioscheduler() only works on Linux kernel with "scheduler"
sysfs entry (though read/write to sysfs obviously compiles on others).

This commit makes the function return 0 if FIO_HAVE_IOSCHED_SWITCH
is undefined (i.e. if not Linux). This is essentially the same as
{diskutil,cgroup,blktrace}.c being compiled only on Linux.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoUse in-place path separator "/" for Linux specific code
Tomohiro Kusumi [Fri, 29 Jul 2016 15:05:57 +0000 (00:05 +0900)]
Use in-place path separator "/" for Linux specific code

diskutil,cgroup,blktrace related code fully depend on Linux kernel,
so sprintf variants can use in-place path separator "/" instead of
FIO_OS_PATH_SEPARATOR.

In fact these Linux specific files are mix of two types within the
same file depending on who wrote them, where they were originally
using "/".

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agogettime: remove unneeded 'ret' in {utime,mtime}_since()
Jens Axboe [Fri, 29 Jul 2016 14:35:28 +0000 (08:35 -0600)]
gettime: remove unneeded 'ret' in {utime,mtime}_since()

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoFix overflow caused by signed long division by unsigned long.
YukiKita [Fri, 29 Jul 2016 00:25:17 +0000 (09:25 +0900)]
Fix overflow caused by signed long division by unsigned long.
The over flow seems to occurr when the value of 'log_avg_msec' option is relatively large.

7 years agoFix memory leak in _fio_rbd_connect()
Jevon Qiao [Thu, 28 Jul 2016 07:26:38 +0000 (15:26 +0800)]
Fix memory leak in _fio_rbd_connect()

When running fio with rbd engine and specifying clustername, a piece of
memory will be allocated in _fio_rbd_connect(), but it never gets freed.

Signed-off-by: Jevon Qiao <scaleqiao@gmail.com>
7 years agoFix segmentation fault while specifying clustername with rbd engine
Jevon Qiao [Thu, 28 Jul 2016 07:22:40 +0000 (15:22 +0800)]
Fix segmentation fault while specifying clustername with rbd engine

Fio with rbd engine will panic if clustername option is specified but clientname
is not. In that case, o->client_name will be a NULL pointer, strlen(o->client_name) in _fio_rbd_connect() will lead to the segmentation fault.

Signed-off-by: Jevon Qiao <scaleqiao@gmail.com>
7 years agoexamples/backwards-read.fio: add size
Jens Axboe [Wed, 27 Jul 2016 14:33:21 +0000 (08:33 -0600)]
examples/backwards-read.fio: add size

Ensure that it runs standalone.

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoChange arch_i386 to arch_x86
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:20 +0000 (22:37 +0900)]
Change arch_i386 to arch_x86

fio_arch_strings[arch_i386] is "x86" (not "i386"),
so change arch_i386 to arch_x86.

Other than arch_i386, "i386" is only used in __i386__.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoAdd missing archs in fio_arch_strings[]
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:19 +0000 (22:37 +0900)]
Add missing archs in fio_arch_strings[]

Add MIPS and AArch64 after PARISC.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoRename exists_and_not_file() to exists_and_not_regfile()
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:18 +0000 (22:37 +0900)]
Rename exists_and_not_file() to exists_and_not_regfile()

Renaming makes the purpose of this function more clear IMO.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoFix stat(2) related bugs introduced by changes made for Windows
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:17 +0000 (22:37 +0900)]
Fix stat(2) related bugs introduced by changes made for Windows

Non-Windows could have regular files that start with "\\\\.\\",
so the conditionals added by ecc314ba and 3892182a in 2011-2012
introduced corner case bugs, though in reality I doubt anyone
would want to create such a file.

This commit brings back the original conditional that was there
before ecc314ba for non-Windows platforms. It also adds WIN32
guard for a change made by 3892182a.

--
 # uname
 Linux
 # cat ./test1.c
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 /* copied from fio/init.c */
 static int exists_and_not_file(const char *filename)
 {
  struct stat sb;
  if (lstat(filename, &sb) == -1)
  return 0;
  /* \\.\ is the device namespace in Windows, where every file
   * is a device node */
  if (S_ISREG(sb.st_mode) && strncmp(filename, "\\\\.\\", 4) != 0)
  return 0;
  return 1;
 }
 int main(int argc, char **argv) {
  printf("exists_and_not_file(\"%s\") = %d\n",
  argv[1], exists_and_not_file(argv[1]));
  return 0;
 }
 # gcc -Wall -g ./test1.c -o test1
 # ls /dev/sda
 /dev/sda
 # ./test1 /dev/sda
 exists_and_not_file("/dev/sda") = 1  /* the existing blkdev isn't a file */
 # touch xxxxx
 # ./test1 ./xxxxx
 exists_and_not_file("./xxxxx") = 0  /* the existing regfile is not not a file */
 # touch "\\\\.\\xxxxx"
 # ./test1 "\\\\.\\xxxxx"
 exists_and_not_file("\\.\xxxxx") = 1  /* XXX */
 # stat "\\\\.\\xxxxx" | head -2
   File: `\\\\.\\xxxxx'
   Size: 0               Blocks: 0          IO Block: 4096   regular empty file

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoDon't malloc/memcpy ioengine_ops on td initialization
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:16 +0000 (22:37 +0900)]
Don't malloc/memcpy ioengine_ops on td initialization

The only reason load_ioengine() needs to malloc extra space for
struct ioengine_ops and memcpy from the original ops is because td
has per-thread/process ioengine private data which is a part of
this structure.

If data (and dlhandle) are separated from struct ioengine_ops,
load_ioengine() no longer needs to malloc, as the rest of structure
fields such as function pointers and string literal are static.
Td only needs a pointer to the original ops. Also avoid memcpying
a list_head from the original ops.

This commit moves/renames data and dlhandle to struct thread_data
as thread_data::io_ops_data and thread_data::io_ops_dlhandle.
engines/*.c which access ioengine private data by dereferencing
td->io_ops->... are modified accordingly, but nothing more than that.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoAdd missing --cmdhelp type string for FIO_OPT_UNSUPPORTED
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:15 +0000 (22:37 +0900)]
Add missing --cmdhelp type string for FIO_OPT_UNSUPPORTED

Without "unsupported" at index 12 (FIO_OPT_UNSUPPORTED) of typehelp[],
unsupported commands print irrelevant binary at typehelp[12].

 # fio --cmdhelp=numa_cpu_nodes
       numa_cpu_nodes: Build fio with libnuma-dev(el) to enable this option
                 type: ÏÿF
              default: no default

With this commit.
 # fio --cmdhelp=numa_cpu_nodes
       numa_cpu_nodes: Build fio with libnuma-dev(el) to enable this option
                 type: unsupported
              default: no default

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoUse correct I/O engine name "cpuio" instead of "cpu"
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:14 +0000 (22:37 +0900)]
Use correct I/O engine name "cpuio" instead of "cpu"

"cpuio" is the name of the engine/option, though the filename is cpu.c.

 # grep "ioengine =" engines/cpu.c -A1
 static struct ioengine_ops ioengine = {
  .name           = "cpuio",

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoIgnore exit_io_done= option if no I/O threads are configured
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:13 +0000 (22:37 +0900)]
Ignore exit_io_done= option if no I/O threads are configured

The cpuio engine option exit_io_done= should be effective only if
there is at least one real I/O thread configured.

The existing fio_cpuio_queue() with exit_io_done= option enabled
lets cpuio threads exit even if cpuio threads are the only threads
configured.

Since this option is supposed to mean "exit when I/O threads are done",
cpuio threads exiting (but only after the first spin cycle is done)
when no threads have done any I/O is a bit confusing.

> [cpu] exit_on_io_done=bool Detect when IO threads are done, then exit.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoMention cpuio never finishes without real I/O in documentation
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:12 +0000 (22:37 +0900)]
Mention cpuio never finishes without real I/O in documentation

reap_threads() terminates cpuio threads only when there is
at least one real I/O thread that is exiting.

> if (*nr_running == cputhreads && !pending && realthreads)
> fio_terminate_threads(TERMINATE_ALL);

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoMention default values for readwrite=/ioengine=/mem= in documentation
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:11 +0000 (22:37 +0900)]
Mention default values for readwrite=/ioengine=/mem= in documentation

HOWTO/fio(1) mention defaults for many of the available options.
This commit adds defaults for the following options.

 readwrite=
 ioengine=
 mem=

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoUse sizeof(char*) instead of sizeof(void*)
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:10 +0000 (22:37 +0900)]
Use sizeof(char*) instead of sizeof(void*)

Conform to the exact data type though both pointers are
normally expected to be the same size on various archs.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoUse default CPU_COUNT() function in DragonFlyBSD
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:08 +0000 (22:37 +0900)]
Use default CPU_COUNT() function in DragonFlyBSD

os/os.h has a default CPU_COUNT() inline function for those that
are expected to have CPU_COUNT() macro, but not in certain versions.
This seems to have been added for RHEL5 (or older?) and variants,
but use this in os/os-dragonfly.h since it's essentially the same
as its own fio_cpu_count() implementation.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoFix typos in log_err() message
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:07 +0000 (22:37 +0900)]
Fix typos in log_err() message

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoMake return value type of fio_getaffinity() consistent
Tomohiro Kusumi [Wed, 27 Jul 2016 13:37:06 +0000 (22:37 +0900)]
Make return value type of fio_getaffinity() consistent

Return type of fio_getaffinity() isn't consistent among supported OS.
Windows and DragonFlyBSD return void while FreeBSD version is int.
The default version for those that don't support is do{}while(0).

Linux version is a macro for sched_getaffinity(2) which returns 0
on success and -1 otherwise, so others should basically follow that.

Note that I haven't compiled this on Windows, but it shouldn't fail.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoFix memory leak in _fio_setup_rbd_data()
Jevon Qiao [Wed, 27 Jul 2016 07:36:36 +0000 (15:36 +0800)]
Fix memory leak in _fio_setup_rbd_data()

Signed-off-by: Jevon Qiao <scaleqiao@gmail.com>
7 years agoAdd sample job file showing how to read backwards
Jens Axboe [Tue, 26 Jul 2016 20:50:02 +0000 (14:50 -0600)]
Add sample job file showing how to read backwards

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoRevert "Revert "fio: Simplify forking of processes""
Jens Axboe [Tue, 26 Jul 2016 14:17:42 +0000 (08:17 -0600)]
Revert "Revert "fio: Simplify forking of processes""

This reverts commit cb92ecf8118b1a8b13909ab18d8a646e24ac79f2.

7 years agoAdd support for blkin tracing in rbd engine
vears91 [Mon, 27 Jun 2016 13:38:34 +0000 (16:38 +0300)]
Add support for blkin tracing in rbd engine

Add configure support to disable or enable fio rbd engine with blkin, and use rbd_aio_write_traced and rbd_aio_read_traced to pass the trace information to librbd if fio was compiled with blkin.

Signed-off-by: Victor Araujo <ve.ar91@gmail.com>
7 years agoFio 2.13 fio-2.13
Jens Axboe [Fri, 22 Jul 2016 19:43:56 +0000 (13:43 -0600)]
Fio 2.13

Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agolog: fix averaged latency logging
Jens Axboe [Fri, 22 Jul 2016 19:19:31 +0000 (13:19 -0600)]
log: fix averaged latency logging

We inadvertently broke that in the previous commit, fix it up.

Fixes: d454a205f81e ("log: fix missing entries")
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agolog: fix missing entries
Jens Axboe [Fri, 22 Jul 2016 18:34:53 +0000 (12:34 -0600)]
log: fix missing entries

If the timing is just off, we could miss adding entries to
an averaged iops or bandwidth log. Allow a bit of slack for
that, similarly to what we do elsewhere.

Fixes: a47591e4923f ("Improve logging accuracy")
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoFix "exitall_on_error" option
YukiKita [Fri, 22 Jul 2016 09:18:14 +0000 (18:18 +0900)]
Fix "exitall_on_error" option
"exitall_on_error" option should be enabled without any argument.

7 years agodrifting in output of interval-averaged values was eventually causing IOP samples...
Karl Cronburg [Wed, 20 Jul 2016 20:21:55 +0000 (16:21 -0400)]
drifting in output of interval-averaged values was eventually causing IOP samples to be dropped.

7 years agoAdd missing header inclusion for Android from 1c764dbe
Tomohiro Kusumi [Tue, 19 Jul 2016 22:30:42 +0000 (07:30 +0900)]
Add missing header inclusion for Android from 1c764dbe

1c764dbe (which just got committed) was missing below for Android,
sorry about that.
 #include "./os-linux-syscall.h"

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
7 years agoAdd os/os-linux-syscall.h to separate syscall NR from arch headers
Tomohiro Kusumi [Tue, 19 Jul 2016 16:33:47 +0000 (01:33 +0900)]
Add os/os-linux-syscall.h to separate syscall NR from arch headers

Linux syscall NR should be defined under os/ with ifdef(arch)
switch rather than arch/ where headers are included not only by
Linux but also all other supported OS that don't need these NR.
(It'll get worse and worse if someone wants to add something
similar under arch/ for other supported OS)

Not sure if you like the way I separated these by adding
os/os-linux-syscall.h, but doing something like
 #if FIO_OS is (Linux or Android)
 ...
 #endif
in arch/arch-*.h doesn't work because arch headers are to be
included prior to os/os-*.h.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>