stat: fix shifted windowed logging when using multiple directions
authorSitsofe Wheeler <sitsofe@yahoo.com>
Wed, 30 Aug 2017 19:08:00 +0000 (20:08 +0100)
committerSitsofe Wheeler <sitsofe@yahoo.com>
Fri, 1 Sep 2017 21:31:42 +0000 (22:31 +0100)
commit8355119b7ef7007b0a251654602584eec000f958
treec9e34298feeb1784496f2d96adf1c028274786ba
parent2b2fa7f5ecfd5cd5b54a209934b05b770e9c9301
stat: fix shifted windowed logging when using multiple directions

When using log_avg_msec and multiple I/O directions, the results
recorded for the directions other than the first are attributed to the
wrong time. This is demonstrated by the following:

sudo modprobe null_blk completion_nsec=100000000 irqmode=2
sudo ./fio --bs=4k --direct=1 --ioengine=libaio --log_avg_msec=1000 \
 --runtime=2s --disable_lat=1 --disable_bw_measurement=1 \
 --filename=/dev/nullb0 --write_iops_log=shiftedlog --rw=rw \
 --name=shiftedlog

results in this:
cat shiftedlog_iops.1.log
1000, 5, 0, 0
2000, 6, 0, 0
2000, 4, 1, 0
2256, 4, 1, 0

shiftedlog_iops.1.log is missing an entry at 1000ms for for the write
direction (1) because the sample has been misattributed to 2000ms (the
third row) due to iolog->avg_last being shared by all directions.

Fix the shifting by turning iolog->avg_last into an array indexed by
direction and only update the windowed stats for the current direction
from add_log_sample().

Fixes https://github.com/axboe/fio/issues/410 .

Reported-by: Kris Davis <shimrot@gmail.com>
Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
iolog.h
stat.c