iolog: add support for replay_scale option
authorSitsofe Wheeler <sitsofe@yahoo.com>
Sat, 3 Dec 2016 09:24:30 +0000 (09:24 +0000)
committerSitsofe Wheeler <sitsofe@yahoo.com>
Mon, 12 Dec 2016 22:23:28 +0000 (22:23 +0000)
Enable replay_scale (and replay_align) when playing back fio's log
format by making ipo_bytes_align() available from a header.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
blktrace.c
iolog.c
iolog.h

index dcddd4f..a3474cb 100644 (file)
@@ -216,15 +216,6 @@ static void t_bytes_align(struct thread_options *o, struct blk_io_trace *t)
        t->bytes = (t->bytes + o->replay_align - 1) & ~(o->replay_align - 1);
 }
 
-static void ipo_bytes_align(struct thread_options *o, struct io_piece *ipo)
-{
-       if (!o->replay_align)
-               return;
-
-       ipo->offset &= ~(o->replay_align - (uint64_t)1);
-}
-
-
 /*
  * Store blk_io_trace data in an ipo for later retrieval.
  */
@@ -239,7 +230,7 @@ static void store_ipo(struct thread_data *td, unsigned long long offset,
        ipo->offset = offset * bs;
        if (td->o.replay_scale)
                ipo->offset = ipo->offset / td->o.replay_scale;
-       ipo_bytes_align(&td->o, ipo);
+       ipo_bytes_align(td->o.replay_align, ipo);
        ipo->len = bytes;
        ipo->delay = ttime / 1000;
        if (rw)
@@ -297,7 +288,7 @@ static void handle_trace_discard(struct thread_data *td,
        ipo->offset = t->sector * bs;
        if (td->o.replay_scale)
                ipo->offset = ipo->offset / td->o.replay_scale;
-       ipo_bytes_align(&td->o, ipo);
+       ipo_bytes_align(td->o.replay_align, ipo);
        ipo->len = t->bytes;
        ipo->delay = ttime / 1000;
        ipo->ddir = DDIR_TRIM;
diff --git a/iolog.c b/iolog.c
index 0c3382d..9393890 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -454,7 +454,12 @@ static int read_iolog2(struct thread_data *td, FILE *f)
                if (rw == DDIR_WAIT) {
                        ipo->delay = offset;
                } else {
-                       ipo->offset = offset;
+                       if (td->o.replay_scale)
+                               ipo->offset = offset / td->o.replay_scale;
+                       else
+                               ipo->offset = offset;
+                       ipo_bytes_align(td->o.replay_align, ipo);
+
                        ipo->len = bytes;
                        if (rw != DDIR_INVAL && bytes > td->o.max_bs[rw])
                                td->o.max_bs[rw] = bytes;
diff --git a/iolog.h b/iolog.h
index ee28944..60ee3e9 100644 (file)
--- a/iolog.h
+++ b/iolog.h
@@ -269,6 +269,14 @@ static inline bool inline_log(struct io_log *log)
                log->log_type == IO_LOG_TYPE_SLAT;
 }
 
+static inline void ipo_bytes_align(unsigned int replay_align, struct io_piece *ipo)
+{
+       if (replay_align)
+               return;
+
+       ipo->offset &= ~(replay_align - (uint64_t)1);
+}
+
 extern void finalize_logs(struct thread_data *td, bool);
 extern void setup_log(struct io_log **, struct log_params *, const char *);
 extern void flush_log(struct io_log *, bool);