Merge branch 'manpage' of https://github.com/sitsofe/fio
authorJens Axboe <axboe@kernel.dk>
Fri, 4 Oct 2013 15:48:15 +0000 (09:48 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 4 Oct 2013 15:48:15 +0000 (09:48 -0600)
iolog.h
stat.c

diff --git a/iolog.h b/iolog.h
index 8fedc192cd6298be13c229b955b7d651fae2da96..6503acffd10659b2ff4e5d5f187b9d5c516de28b 100644 (file)
--- a/iolog.h
+++ b/iolog.h
@@ -49,6 +49,11 @@ struct io_log {
 
        unsigned int log_type;
 
+       /*
+        * If we fail extending the log, stop collecting more entries.
+        */
+       unsigned int disabled;
+
        /*
         * Windowed average, for logging single entries average over some
         * period of time.
diff --git a/stat.c b/stat.c
index 10d9efead57176bee8aeba9abfbccc617520e2c4..fec363964f29270a374bc0732423d13e8194bbc6 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1504,13 +1504,23 @@ static void __add_log_sample(struct io_log *iolog, unsigned long val,
 {
        const int nr_samples = iolog->nr_samples;
 
+       if (iolog->disabled)
+               return;
+
        if (!iolog->nr_samples)
                iolog->avg_last = t;
 
        if (iolog->nr_samples == iolog->max_samples) {
                int new_size = sizeof(struct io_sample) * iolog->max_samples*2;
+               void *new_log;
 
-               iolog->log = realloc(iolog->log, new_size);
+               new_log = realloc(iolog->log, new_size);
+               if (!new_log) {
+                       log_err("fio: failed extending iolog! Will stop logging.\n");
+                       iolog->disabled = 1;
+                       return;
+               }
+               iolog->log = new_log;
                iolog->max_samples <<= 1;
        }