iolog: add iolog_write for version 3
authorMohamad Gebai <mogeb@fb.com>
Thu, 7 Apr 2022 17:40:30 +0000 (10:40 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 8 Apr 2022 18:29:48 +0000 (12:29 -0600)
Add timestamps to all actions for iolog version 3. Fio now generates iolog
files using version 3 by default, and only supports writing using that
version. Reading iolog v2 still works as expected.

Signed-off-by: Mohamad Gebai <mogeb@fb.com>
Link: https://lore.kernel.org/r/20220407174031.599117-3-mogeb@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fio.h
iolog.c

diff --git a/fio.h b/fio.h
index 8830ff34ad428d98bf920ac04f492365b02fbf8d..de7eca79cb1a42c53dcbd0e6d4ca9d6a89f75eff 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -432,6 +432,7 @@ struct thread_data {
        unsigned int io_log_blktrace;
        unsigned int io_log_blktrace_swap;
        unsigned long long io_log_last_ttime;
        unsigned int io_log_blktrace;
        unsigned int io_log_blktrace_swap;
        unsigned long long io_log_last_ttime;
+       struct timespec io_log_start_time;
        unsigned int io_log_current;
        unsigned int io_log_checkmark;
        unsigned int io_log_highmark;
        unsigned int io_log_current;
        unsigned int io_log_checkmark;
        unsigned int io_log_highmark;
diff --git a/iolog.c b/iolog.c
index f6023ee2ce6241398138d39134eaafe26e140998..51aecd4325e31e62e83dfff629331b376fda3659 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -41,18 +41,24 @@ void queue_io_piece(struct thread_data *td, struct io_piece *ipo)
 
 void log_io_u(const struct thread_data *td, const struct io_u *io_u)
 {
 
 void log_io_u(const struct thread_data *td, const struct io_u *io_u)
 {
+       struct timespec now;
+
        if (!td->o.write_iolog_file)
                return;
 
        if (!td->o.write_iolog_file)
                return;
 
-       fprintf(td->iolog_f, "%s %s %llu %llu\n", io_u->file->file_name,
+       fio_gettime(&now, NULL);
+       fprintf(td->iolog_f, "%lu %s %s %llu %llu\n", utime_since_now(&td->io_log_start_time),
+                                               io_u->file->file_name,
                                                io_ddir_name(io_u->ddir),
                                                io_u->offset, io_u->buflen);
                                                io_ddir_name(io_u->ddir),
                                                io_u->offset, io_u->buflen);
+
 }
 
 void log_file(struct thread_data *td, struct fio_file *f,
              enum file_log_act what)
 {
        const char *act[] = { "add", "open", "close" };
 }
 
 void log_file(struct thread_data *td, struct fio_file *f,
              enum file_log_act what)
 {
        const char *act[] = { "add", "open", "close" };
+       struct timespec now;
 
        assert(what < 3);
 
 
        assert(what < 3);
 
@@ -66,7 +72,9 @@ void log_file(struct thread_data *td, struct fio_file *f,
        if (!td->iolog_f)
                return;
 
        if (!td->iolog_f)
                return;
 
-       fprintf(td->iolog_f, "%s %s\n", f->file_name, act[what]);
+       fio_gettime(&now, NULL);
+       fprintf(td->iolog_f, "%lu %s %s\n", utime_since_now(&td->io_log_start_time),
+                                               f->file_name, act[what]);
 }
 
 static void iolog_delay(struct thread_data *td, unsigned long delay)
 }
 
 static void iolog_delay(struct thread_data *td, unsigned long delay)
@@ -738,11 +746,12 @@ static bool init_iolog_write(struct thread_data *td)
        td->iolog_f = f;
        td->iolog_buf = malloc(8192);
        setvbuf(f, td->iolog_buf, _IOFBF, 8192);
        td->iolog_f = f;
        td->iolog_buf = malloc(8192);
        setvbuf(f, td->iolog_buf, _IOFBF, 8192);
+       fio_gettime(&td->io_log_start_time, NULL);
 
        /*
         * write our version line
         */
 
        /*
         * write our version line
         */
-       if (fprintf(f, "%s\n", iolog_ver2) < 0) {
+       if (fprintf(f, "%s\n", iolog_ver3) < 0) {
                perror("iolog init\n");
                return false;
        }
                perror("iolog init\n");
                return false;
        }