summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsribs <sriharsha.bs@outlook.com>2020-07-24 15:36:58 +0530
committersribs <sriharsha.bs@outlook.com>2020-07-24 22:19:55 +0530
commitdf06a03616661423baa39b68a8679c7f7baa99ed (patch)
treea78e6f629006475b0bbda2996922e514b48902fd
parent5090d1d0f2a109c276384c93308566b7a3bfa5ad (diff)
downloadfio-df06a03616661423baa39b68a8679c7f7baa99ed.tar.gz
fio-df06a03616661423baa39b68a8679c7f7baa99ed.tar.bz2
io_u: fix exit failure case when using rates and timeout
Previously when using a rate smaller than the minimum block size, fio could end up failing to exit at a designated timeout and while doing this, do check if usec takes in negative values which could potentially not exit fio indefinitely. Fixes: https://github.com/axboe/fio/issues/1039 Signed-off-by: Sriharsha B S <sribs@microsoft.com>
-rw-r--r--io_u.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/io_u.c b/io_u.c
index 7f50906b..6a729e51 100644
--- a/io_u.c
+++ b/io_u.c
@@ -680,7 +680,22 @@ static enum fio_ddir rate_ddir(struct thread_data *td, enum fio_ddir ddir)
if (td->o.io_submit_mode == IO_MODE_INLINE)
io_u_quiesce(td);
+ if (td->o.timeout && ((usec + now) > td->o.timeout)) {
+ /*
+ * check if the usec is capable of taking negative values
+ */
+ if (now > td->o.timeout) {
+ ddir = DDIR_INVAL;
+ return ddir;
+ }
+ usec = td->o.timeout - now;
+ }
usec_sleep(td, usec);
+
+ now = utime_since_now(&td->epoch);
+ if ((td->o.timeout && (now > td->o.timeout)) || td->terminate)
+ ddir = DDIR_INVAL;
+
return ddir;
}
@@ -896,6 +911,10 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)
set_rw_ddir(td, io_u);
+ if (io_u->ddir == DDIR_INVAL) {
+ dprint(FD_IO, "invalid direction received ddir = %d", io_u->ddir);
+ return 1;
+ }
/*
* fsync() or fdatasync() or trim etc, we are done
*/