+static void handle_trace_notify(struct blk_io_trace *t)
+{
+ switch (t->action) {
+ case BLK_TN_PROCESS:
+ dprint(FD_BLKTRACE, "got process notify: %x, %d\n",
+ t->action, t->pid);
+ break;
+ case BLK_TN_TIMESTAMP:
+ dprint(FD_BLKTRACE, "got timestamp notify: %x, %d\n",
+ t->action, t->pid);
+ break;
+ case BLK_TN_MESSAGE:
+ break;
+ default:
+ dprint(FD_BLKTRACE, "unknown trace act %x\n", t->action);
+ break;
+ }
+}
+
+static void handle_trace_discard(struct thread_data *td,
+ struct blk_io_trace *t,
+ unsigned long long ttime,
+ unsigned long *ios, unsigned int *rw_bs)
+{
+ struct io_piece *ipo;
+ unsigned int bs;
+ int fileno;
+
+ if (td->o.replay_skip & (1u << DDIR_TRIM))
+ return;
+
+ ipo = calloc(1, sizeof(*ipo));
+ init_ipo(ipo);
+ fileno = trace_add_file(td, t->device, &bs);
+
+ ios[DDIR_TRIM]++;
+ if (t->bytes > rw_bs[DDIR_TRIM])
+ rw_bs[DDIR_TRIM] = t->bytes;
+
+ td->o.size += t->bytes;
+
+ INIT_FLIST_HEAD(&ipo->list);
+
+ ipo->offset = t->sector * bs;
+ if (td->o.replay_scale)
+ ipo->offset = ipo->offset / td->o.replay_scale;
+ ipo_bytes_align(td->o.replay_align, ipo);
+ ipo->len = t->bytes;
+ ipo->delay = ttime / 1000;
+ ipo->ddir = DDIR_TRIM;
+ ipo->fileno = fileno;
+
+ dprint(FD_BLKTRACE, "store discard, off=%llu, len=%lu, delay=%lu\n",
+ ipo->offset, ipo->len,
+ ipo->delay);
+ queue_io_piece(td, ipo);
+}
+
+static void handle_trace_fs(struct thread_data *td, struct blk_io_trace *t,
+ unsigned long long ttime, unsigned long *ios,
+ unsigned int *rw_bs)
+{
+ unsigned int bs;
+ int rw;
+ int fileno;
+
+ fileno = trace_add_file(td, t->device, &bs);
+
+ rw = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
+
+ if (rw) {
+ if (td->o.replay_skip & (1u << DDIR_WRITE))
+ return;
+ } else {
+ if (td->o.replay_skip & (1u << DDIR_READ))
+ return;
+ }
+
+ assert(t->bytes);
+
+ if (t->bytes > rw_bs[rw])
+ rw_bs[rw] = t->bytes;
+
+ ios[rw]++;
+ td->o.size += t->bytes;
+ store_ipo(td, t->sector, t->bytes, rw, ttime, fileno, bs);
+}
+
+static void handle_trace_flush(struct thread_data *td, struct blk_io_trace *t,
+ unsigned long long ttime, unsigned long *ios)
+{
+ struct io_piece *ipo;
+ unsigned int bs;
+ int fileno;
+
+ if (td->o.replay_skip & (1u << DDIR_SYNC))
+ return;
+
+ ipo = calloc(1, sizeof(*ipo));
+ init_ipo(ipo);
+ fileno = trace_add_file(td, t->device, &bs);
+
+ ipo->delay = ttime / 1000;
+ ipo->ddir = DDIR_SYNC;
+ ipo->fileno = fileno;
+
+ ios[DDIR_SYNC]++;
+ dprint(FD_BLKTRACE, "store flush delay=%lu\n", ipo->delay);
+ queue_io_piece(td, ipo);