From: Sitsofe Wheeler Date: Sat, 3 Dec 2016 09:24:30 +0000 (+0000) Subject: iolog: add support for replay_scale option X-Git-Tag: fio-2.16~8 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=a79f17bf3bfa20b83424c2301de092bdcfbaaea4 iolog: add support for replay_scale option 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 --- diff --git a/blktrace.c b/blktrace.c index dcddd4f2..a3474cb5 100644 --- a/blktrace.c +++ b/blktrace.c @@ -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 0c3382d3..93938905 100644 --- 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 ee289448..60ee3e92 100644 --- 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);