+void reset_io_stats(struct thread_data *td)
+{
+ struct thread_stat *ts = &td->ts;
+ int i, j;
+
+ for (i = 0; i < DDIR_RWDIR_CNT; i++) {
+ reset_io_stat(&ts->clat_stat[i]);
+ reset_io_stat(&ts->slat_stat[i]);
+ reset_io_stat(&ts->lat_stat[i]);
+ reset_io_stat(&ts->bw_stat[i]);
+ reset_io_stat(&ts->iops_stat[i]);
+
+ ts->io_bytes[i] = 0;
+ ts->runtime[i] = 0;
+
+ for (j = 0; j < FIO_IO_U_PLAT_NR; j++)
+ ts->io_u_plat[i][j] = 0;
+ }
+
+ for (i = 0; i < FIO_IO_U_MAP_NR; i++) {
+ ts->io_u_map[i] = 0;
+ ts->io_u_submit[i] = 0;
+ ts->io_u_complete[i] = 0;
+ ts->io_u_lat_u[i] = 0;
+ ts->io_u_lat_m[i] = 0;
+ ts->total_submit = 0;
+ ts->total_complete = 0;
+ }
+
+ for (i = 0; i < 3; i++) {
+ ts->total_io_u[i] = 0;
+ ts->short_io_u[i] = 0;
+ }
+}
+
+static void _add_stat_to_log(struct io_log *iolog, unsigned long elapsed)
+{
+ /*
+ * Note an entry in the log. Use the mean from the logged samples,
+ * making sure to properly round up. Only write a log entry if we
+ * had actual samples done.
+ */
+ if (iolog->avg_window[DDIR_READ].samples) {
+ unsigned long mr;
+
+ mr = iolog->avg_window[DDIR_READ].mean.u.f + 0.50;
+ __add_log_sample(iolog, mr, DDIR_READ, 0, elapsed, 0);
+ }
+ if (iolog->avg_window[DDIR_WRITE].samples) {
+ unsigned long mw;
+
+ mw = iolog->avg_window[DDIR_WRITE].mean.u.f + 0.50;
+ __add_log_sample(iolog, mw, DDIR_WRITE, 0, elapsed, 0);
+ }
+ if (iolog->avg_window[DDIR_TRIM].samples) {
+ unsigned long mw;
+
+ mw = iolog->avg_window[DDIR_TRIM].mean.u.f + 0.50;
+ __add_log_sample(iolog, mw, DDIR_TRIM, 0, elapsed, 0);
+ }
+
+ reset_io_stat(&iolog->avg_window[DDIR_READ]);
+ reset_io_stat(&iolog->avg_window[DDIR_WRITE]);
+ reset_io_stat(&iolog->avg_window[DDIR_TRIM]);
+}
+