io_u: fix rate limiting to handle file wrap-around
When using "rate" with "time_based", the amount of time to sleep should be based
on the invocation time (epoch) rather than the start time of a given loop
(start) because no other statistics are reset when a file is re-opened.
Prior to this change, a wrap-around would cause the rate_ddir code to compute
that ~0 time had elapsed since the last I/O (i.e., a near-infinite rate), and
trigger a very long sleep in an attempt to adjust to the given rate.
Testing done:
Using configuration below...
Before: starts at 100 MB/sec and drops to 0 after ~10 sec (upon wrap) before
recovering at t ~ 20.
After: maintains 100 MB/sec for the duration of the test
[repro]
# 1 GiB + 1 Byte, to force a fill_io_u failure, the file to close and
# reopen, and the start timestamp to reset.
size=
1073741825
bs=
2097152
direct=1
ioengine=psync
readwrite=write
runtime=30s
time_based
rate=100m
filename=data_file