Add support for replaying blktrace trim/discard
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
diff --git a/stat.c b/stat.c
index 8a0fab0..8e9fba0 100644
--- a/stat.c
+++ b/stat.c
@@ -157,6 +157,8 @@
char *io_p, *bw_p, *iops_p;
int i2p;
+ assert(ddir_rw(ddir));
+
if (!ts->runtime[ddir])
return;
@@ -370,6 +372,8 @@
unsigned long long bw;
double mean, dev;
+ assert(ddir_rw(ddir));
+
bw = 0;
if (ts->runtime[ddir])
bw = ts->io_bytes[ddir] / ts->runtime[ddir];
@@ -735,13 +739,20 @@
unsigned long val, enum fio_ddir ddir,
unsigned int bs)
{
+ if (!ddir_rw(ddir))
+ return;
+
__add_log_sample(iolog, val, ddir, bs, mtime_since_now(&td->epoch));
}
void add_agg_sample(unsigned long val, enum fio_ddir ddir, unsigned int bs)
{
- struct io_log *iolog = agg_io_log[ddir];
+ struct io_log *iolog;
+ if (!ddir_rw(ddir))
+ return;
+
+ iolog = agg_io_log[ddir];
__add_log_sample(iolog, val, ddir, bs, mtime_since_genesis());
}
@@ -750,6 +761,9 @@
{
struct thread_stat *ts = &td->ts;
+ if (!ddir_rw(ddir))
+ return;
+
add_stat_sample(&ts->clat_stat[ddir], usec);
if (ts->clat_log)
@@ -761,6 +775,9 @@
{
struct thread_stat *ts = &td->ts;
+ if (!ddir_rw(ddir))
+ return;
+
add_stat_sample(&ts->slat_stat[ddir], usec);
if (ts->slat_log)
@@ -772,6 +789,9 @@
{
struct thread_stat *ts = &td->ts;
+ if (!ddir_rw(ddir))
+ return;
+
add_stat_sample(&ts->lat_stat[ddir], usec);
if (ts->lat_log)
@@ -782,9 +802,12 @@
struct timeval *t)
{
struct thread_stat *ts = &td->ts;
- unsigned long spent = mtime_since(&ts->stat_sample_time[ddir], t);
- unsigned long rate;
+ unsigned long spent, rate;
+ if (!ddir_rw(ddir))
+ return;
+
+ spent = mtime_since(&ts->stat_sample_time[ddir], t);
if (spent < td->o.bw_avg_time)
return;