test: improve run-fio-tests.py file open method
[fio.git] / iolog.c
diff --git a/iolog.c b/iolog.c
index 42d2b0e909ce29716d35ce5a796ee6f03cb9874a..aa9c3bb1e4eca43fa0cf1c9794df39656ba80972 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -47,10 +47,10 @@ void log_io_u(const struct thread_data *td, const struct io_u *io_u)
                return;
 
        fio_gettime(&now, NULL);
-       fprintf(td->iolog_f, "%lu %s %s %llu %llu\n",
-                       (unsigned long) 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);
+       fprintf(td->iolog_f, "%llu %s %s %llu %llu\n",
+               (unsigned long long) 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);
 
 }
 
@@ -73,9 +73,9 @@ void log_file(struct thread_data *td, struct fio_file *f,
                return;
 
        fio_gettime(&now, NULL);
-       fprintf(td->iolog_f, "%lu %s %s\n",
-                       (unsigned long) utime_since_now(&td->io_log_start_time),
-                       f->file_name, act[what]);
+       fprintf(td->iolog_f, "%llu %s %s\n",
+               (unsigned long long) utime_since_now(&td->io_log_start_time),
+               f->file_name, act[what]);
 }
 
 static void iolog_delay(struct thread_data *td, unsigned long delay)
@@ -1218,7 +1218,7 @@ int iolog_file_inflate(const char *file)
        void *buf;
        FILE *f;
 
-       f = fopen(file, "r");
+       f = fopen(file, "rb");
        if (!f) {
                perror("fopen");
                return 1;
@@ -1300,10 +1300,21 @@ void flush_log(struct io_log *log, bool do_append)
        void *buf;
        FILE *f;
 
+       /*
+        * If log_gz_store is true, we are writing a binary file.
+        * Set the mode appropriately (on all platforms) to avoid issues
+        * on windows (line-ending conversions, etc.)
+        */
        if (!do_append)
-               f = fopen(log->filename, "w");
+               if (log->log_gz_store)
+                       f = fopen(log->filename, "wb");
+               else
+                       f = fopen(log->filename, "w");
        else
-               f = fopen(log->filename, "a");
+               if (log->log_gz_store)
+                       f = fopen(log->filename, "ab");
+               else
+                       f = fopen(log->filename, "a");
        if (!f) {
                perror("fopen log");
                return;
@@ -1574,14 +1585,14 @@ void iolog_compress_exit(struct thread_data *td)
  * Queue work item to compress the existing log entries. We reset the
  * current log to a small size, and reference the existing log in the
  * data that we queue for compression. Once compression has been done,
- * this old log is freed. If called with finish == true, will not return
- * until the log compression has completed, and will flush all previous
- * logs too
+ * this old log is freed. Will not return until the log compression
+ * has completed, and will flush all previous logs too
  */
 static int iolog_flush(struct io_log *log)
 {
        struct iolog_flush_data *data;
 
+       workqueue_flush(&log->td->log_compress_wq);
        data = malloc(sizeof(*data));
        if (!data)
                return 1;