+ if (!(t->action & BLK_TC_ACT(BLK_TC_NOTIFY))) {
+ if (!last_ttime || td->o.no_stall)
+ delay = 0;
+ else if (td->o.replay_time_scale == 100)
+ delay = t->time - last_ttime;
+ else {
+ double tmp = t->time - last_ttime;
+ double scale;
+
+ scale = (double) 100.0 / (double) td->o.replay_time_scale;
+ tmp *= scale;
+ delay = tmp;
+ }
+ last_ttime = t->time;
+ }
+
+ t_bytes_align(&td->o, t);
+
+ if (t->action & BLK_TC_ACT(BLK_TC_NOTIFY))
+ handle_trace_notify(t);
+ else if (t->action & BLK_TC_ACT(BLK_TC_DISCARD))
+ handle_trace_discard(td, t, delay, ios, bs);
+ else if (t->action & BLK_TC_ACT(BLK_TC_FLUSH))
+ handle_trace_flush(td, t, delay, ios);
+ else
+ handle_trace_fs(td, t, delay, ios, bs);
+}
+
+static void byteswap_trace(struct blk_io_trace *t)
+{
+ t->magic = fio_swap32(t->magic);
+ t->sequence = fio_swap32(t->sequence);
+ t->time = fio_swap64(t->time);
+ t->sector = fio_swap64(t->sector);
+ t->bytes = fio_swap32(t->bytes);
+ t->action = fio_swap32(t->action);
+ t->pid = fio_swap32(t->pid);
+ t->device = fio_swap32(t->device);
+ t->cpu = fio_swap32(t->cpu);
+ t->error = fio_swap16(t->error);
+ t->pdu_len = fio_swap16(t->pdu_len);
+}
+
+static bool t_is_write(struct blk_io_trace *t)
+{
+ return (t->action & BLK_TC_ACT(BLK_TC_WRITE | BLK_TC_DISCARD)) != 0;
+}
+
+static enum fio_ddir t_get_ddir(struct blk_io_trace *t)
+{
+ if (t->action & BLK_TC_ACT(BLK_TC_READ))
+ return DDIR_READ;
+ else if (t->action & BLK_TC_ACT(BLK_TC_WRITE))
+ return DDIR_WRITE;
+ else if (t->action & BLK_TC_ACT(BLK_TC_DISCARD))
+ return DDIR_TRIM;
+
+ return DDIR_INVAL;
+}
+
+static void depth_inc(struct blk_io_trace *t, int *depth)
+{
+ enum fio_ddir ddir;
+
+ ddir = t_get_ddir(t);
+ if (ddir != DDIR_INVAL)
+ depth[ddir]++;
+}
+
+static void depth_dec(struct blk_io_trace *t, int *depth)
+{
+ enum fio_ddir ddir;
+
+ ddir = t_get_ddir(t);
+ if (ddir != DDIR_INVAL)
+ depth[ddir]--;
+}
+
+static void depth_end(struct blk_io_trace *t, int *this_depth, int *depth)
+{
+ enum fio_ddir ddir = DDIR_INVAL;
+
+ ddir = t_get_ddir(t);
+ if (ddir != DDIR_INVAL) {
+ depth[ddir] = max(depth[ddir], this_depth[ddir]);
+ this_depth[ddir] = 0;
+ }