+#define TRACE_FIFO_SIZE 65536
+
+/*
+ * fifo refill frontend, to avoid reading data in trace sized bites
+ */
+static int refill_fifo(struct thread_data *td, struct fifo *fifo, int fd)
+{
+ char buf[TRACE_FIFO_SIZE];
+ unsigned int total;
+ int ret;
+
+ total = sizeof(buf);
+ if (total > fifo_room(fifo))
+ total = fifo_room(fifo);
+
+ ret = read(fd, buf, total);
+ if (ret < 0) {
+ td_verror(td, errno, "read blktrace file");
+ return -1;
+ }
+
+ if (ret > 0)
+ ret = fifo_put(fifo, buf, ret);
+
+ return ret;
+}
+
+/*
+ * Retrieve 'len' bytes from the fifo, refilling if necessary.
+ */
+static int trace_fifo_get(struct thread_data *td, struct fifo *fifo, int fd,
+ void *buf, unsigned int len)
+{
+ if (fifo_len(fifo) < len) {
+ int ret = refill_fifo(td, fifo, fd);
+
+ if (ret < 0)
+ return ret;
+ }
+
+ return fifo_get(fifo, buf, len);
+}
+
+/*
+ * Just discard the pdu by seeking past it.
+ */
+static int discard_pdu(struct thread_data *td, struct fifo *fifo, int fd,
+ struct blk_io_trace *t)