summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-07-24 11:05:21 -0600
committerJens Axboe <axboe@kernel.dk>2020-07-24 11:05:21 -0600
commitc355011a2509fdf6caa2a220e1534d61f14c4801 (patch)
tree272b1bdb6cdf2bfcfa35a82560fe76732dcd6028
parent693403ebc40fd2986e9a4f3bdee31c61d44f123f (diff)
parent5c0abd5e21df3b0ca7ee0833eb0ddf3f87ad4374 (diff)
downloadfio-c355011a2509fdf6caa2a220e1534d61f14c4801.tar.gz
fio-c355011a2509fdf6caa2a220e1534d61f14c4801.tar.bz2
Merge branch 'sribs-patch-1039' of https://github.com/sribs/fio
* 'sribs-patch-1039' of https://github.com/sribs/fio: stat: stop triggerring division by zero on bandwidth lower than 1KBps io_u: fix exit failure case when using rates and timeout
-rw-r--r--io_u.c19
-rw-r--r--stat.c25
2 files changed, 34 insertions, 10 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
*/
diff --git a/stat.c b/stat.c
index b3951199..23657cee 100644
--- a/stat.c
+++ b/stat.c
@@ -414,6 +414,18 @@ static void display_lat(const char *name, unsigned long long min,
free(maxp);
}
+static double convert_agg_kbytes_percent(struct group_run_stats *rs, int ddir, int mean)
+{
+ double p_of_agg = 100.0;
+ if (rs && rs->agg[ddir] > 1024) {
+ p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024.0);
+
+ if (p_of_agg > 100.0)
+ p_of_agg = 100.0;
+ }
+ return p_of_agg;
+}
+
static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
int ddir, struct buf_output *out)
{
@@ -551,11 +563,7 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
else
bw_str = "kB";
- if (rs->agg[ddir]) {
- p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024);
- if (p_of_agg > 100.0)
- p_of_agg = 100.0;
- }
+ p_of_agg = convert_agg_kbytes_percent(rs, ddir, mean);
if (rs->unit_base == 1) {
min *= 8.0;
@@ -1376,11 +1384,7 @@ static void add_ddir_status_json(struct thread_stat *ts,
}
if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
- if (rs->agg[ddir]) {
- p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024);
- if (p_of_agg > 100.0)
- p_of_agg = 100.0;
- }
+ p_of_agg = convert_agg_kbytes_percent(rs, ddir, mean);
} else {
min = max = 0;
p_of_agg = mean = dev = 0.0;
@@ -3130,3 +3134,4 @@ uint32_t *io_u_block_info(struct thread_data *td, struct io_u *io_u)
assert(idx < td->ts.nr_block_infos);
return info;
}
+