Fio 2.2.9
[fio.git] / iolog.c
diff --git a/iolog.c b/iolog.c
index b867583a27bc1f11e649ab8d88936507affcee53..82b2b8a3ec40084853655a42d5494a4e9bbf91bf 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -291,6 +291,18 @@ void unlog_io_piece(struct thread_data *td, struct io_u *io_u)
 {
        struct io_piece *ipo = io_u->ipo;
 
+       if (td->ts.nr_block_infos) {
+               uint32_t *info = io_u_block_info(td, io_u);
+               if (BLOCK_INFO_STATE(*info) < BLOCK_STATE_TRIM_FAILURE) {
+                       if (io_u->ddir == DDIR_TRIM)
+                               *info = BLOCK_INFO_SET_STATE(*info,
+                                               BLOCK_STATE_TRIM_FAILURE);
+                       else if (io_u->ddir == DDIR_WRITE)
+                               *info = BLOCK_INFO_SET_STATE(*info,
+                                               BLOCK_STATE_WRITE_FAILURE);
+               }
+       }
+
        if (!ipo)
                return;
 
@@ -876,10 +888,12 @@ int iolog_file_inflate(const char *file)
        if (ret < 0) {
                perror("fread");
                fclose(f);
+               free(buf);
                return 1;
        } else if (ret != 1) {
                log_err("fio: short read on reading log\n");
                fclose(f);
+               free(buf);
                return 1;
        }
 
@@ -931,12 +945,15 @@ int iolog_file_inflate(const char *file)
 
 #endif
 
-void flush_log(struct io_log *log)
+void flush_log(struct io_log *log, int do_append)
 {
        void *buf;
        FILE *f;
 
-       f = fopen(log->filename, "w");
+       if (!do_append)
+               f = fopen(log->filename, "w");
+       else
+               f = fopen(log->filename, "a");
        if (!f) {
                perror("fopen log");
                return;
@@ -966,7 +983,7 @@ static int finish_log(struct thread_data *td, struct io_log *log, int trylock)
        if (td->client_type == FIO_CLIENT_TYPE_GUI)
                fio_send_iolog(td, log, log->filename);
        else
-               flush_log(log);
+               flush_log(log, !td->o.per_job_logs);
 
        fio_unlock_file(log->filename);
        free_log(log);