- if (td->bw_log)
- add_log_sample(td, td->bw_log, rate, ddir, bs);
+ delta = td->this_io_bytes[ddir] - td->stat_io_bytes[ddir];
+ if (!delta)
+ continue; /* No entries for interval */
+
+ 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);
+
+ td->stat_io_bytes[ddir] = td->this_io_bytes[ddir];
+ }