fio was maintaining separate read/write stats, but only one timer for
bw_avg_time. Whichever IO direction happened to cross the timer would
get its interval logged; the other data direction would not. Now both
ddir are logged each time we cross bw_avg_time.
Where intervals don't contain any activity in a given ddir, no log
entry is made.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
spent = mtime_since(&td->bw_sample_time, t);
if (spent < td->o.bw_avg_time)
return;
spent = mtime_since(&td->bw_sample_time, t);
if (spent < td->o.bw_avg_time)
return;
+
+ /*
+ * Compute both read and write rates for the interval.
+ */
+ for (ddir = DDIR_READ; ddir <= DDIR_WRITE; ddir++) {
+ uint64_t delta;
+
+ delta = td->this_io_bytes[ddir] - td->stat_io_bytes[ddir];
+ if (!delta)
+ continue; /* No entries for interval */
- rate = (td->this_io_bytes[ddir] - td->stat_io_bytes[ddir]) *
- 1000 / spent / 1024;
- add_stat_sample(&ts->bw_stat[ddir], rate);
+ rate = delta * 1000 / spent / 1024;
+ add_stat_sample(&ts->bw_stat[ddir], rate);
- if (td->bw_log)
- add_log_sample(td, td->bw_log, rate, ddir, bs);
+ if (td->bw_log)
+ add_log_sample(td, td->bw_log, rate, ddir, bs);
+
+ td->stat_io_bytes[ddir] = td->this_io_bytes[ddir];
+ }
fio_gettime(&td->bw_sample_time, NULL);
fio_gettime(&td->bw_sample_time, NULL);
- td->stat_io_bytes[ddir] = td->this_io_bytes[ddir];
}
void add_iops_sample(struct thread_data *td, enum fio_ddir ddir,
}
void add_iops_sample(struct thread_data *td, enum fio_ddir ddir,