iolog: fix two bugs in deferred growing
authorJens Axboe <axboe@fb.com>
Fri, 20 May 2016 19:57:42 +0000 (13:57 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 20 May 2016 19:57:42 +0000 (13:57 -0600)
1) Setup a new current log, if the log doesn't have one.
2) Bump size of pending log. Should be depth + 1, let's just
   use the default size of a log (1024).

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

diff --git a/iolog.c b/iolog.c
index 3723e0a86025afe460c11a7585e14a365f37022b..d9a17a5bcc44537778aa646c0b731a3443fe77ee 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -591,7 +591,7 @@ void setup_log(struct io_log **log, struct log_params *p,
                struct io_logs *p;
 
                p = calloc(1, sizeof(*l->pending));
-               p->max_samples = l->td->o.iodepth;
+               p->max_samples = DEF_LOG_ENTRIES;
                p->log = calloc(p->max_samples, log_entry_sz(l));
                l->pending = p;
        }
diff --git a/stat.c b/stat.c
index f55cb2f5cc8dfdd4fcc3087d6435134e7405c07b..146090e7f168d232fd055bb1a110229e35c0466a 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1901,6 +1901,12 @@ static struct io_logs *regrow_log(struct io_log *iolog)
                return NULL;
 
        cur_log = iolog_cur_log(iolog);
+       if (!cur_log) {
+               cur_log = get_new_log(iolog);
+               if (!cur_log)
+                       return NULL;
+       }
+
        if (cur_log->nr_samples < cur_log->max_samples)
                return cur_log;