iolog: allocate 'cur_log's out of shared pool
authorJens Axboe <axboe@fb.com>
Sun, 12 Jun 2016 03:38:51 +0000 (21:38 -0600)
committerJens Axboe <axboe@fb.com>
Sun, 12 Jun 2016 03:38:51 +0000 (21:38 -0600)
Different process, so we need to ensure we can write to them
properly.

Signed-off-by: Jens Axboe <axboe@fb.com>
iolog.c
stat.c

diff --git a/iolog.c b/iolog.c
index 9391507940112d372c644c6180575a7a4e523398..4ecf39abe914f4afdfda4b181452a9ba775edf5a 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -988,6 +988,7 @@ void flush_log(struct io_log *log, int do_append)
                cur_log = flist_first_entry(&log->io_logs, struct io_logs, list);
                flist_del_init(&cur_log->list);
                flush_samples(f, cur_log->log, cur_log->nr_samples * log_entry_sz(log));
+               sfree(cur_log);
        }
 
        fclose(f);
diff --git a/stat.c b/stat.c
index a8ccd9ab2133bc0a67f1a38de6157f8513f384f2..26d8d537df9eac65c23cb1b6e5ffc19d9fc5af54 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -16,6 +16,7 @@
 #include "lib/pow2.h"
 #include "lib/output_buffer.h"
 #include "helper_thread.h"
+#include "smalloc.h"
 
 struct fio_mutex *stat_mutex;
 
@@ -1877,7 +1878,7 @@ static struct io_logs *get_new_log(struct io_log *iolog)
 
        new_size = new_samples * log_entry_sz(iolog);
 
-       cur_log = malloc(sizeof(*cur_log));
+       cur_log = smalloc(sizeof(*cur_log));
        if (cur_log) {
                INIT_FLIST_HEAD(&cur_log->list);
                cur_log->log = malloc(new_size);
@@ -1888,7 +1889,7 @@ static struct io_logs *get_new_log(struct io_log *iolog)
                        iolog->cur_log_max = new_samples;
                        return cur_log;
                }
-               free(cur_log);
+               sfree(cur_log);
        }
 
        return NULL;