stat: make next log time decision cleaner
authorJens Axboe <axboe@fb.com>
Wed, 26 Apr 2017 00:14:00 +0000 (18:14 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 26 Apr 2017 00:14:00 +0000 (18:14 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
stat.c

diff --git a/stat.c b/stat.c
index fde7af299de449d3f63afec10a548d8984ddc14c..27d1feac9e01c0e90fbd17d277d1712bec95f09e 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -2479,9 +2479,10 @@ static int add_bw_samples(struct thread_data *td, struct timeval *t)
        td_io_u_unlock(td);
 
        if (spent <= td->o.bw_avg_time)
        td_io_u_unlock(td);
 
        if (spent <= td->o.bw_avg_time)
-               return min(next_log, td->o.bw_avg_time);
+               next = td->o.bw_avg_time;
+       else
+               next = td->o.bw_avg_time - (1 + spent - td->o.bw_avg_time);
 
 
-       next = td->o.bw_avg_time - (1 + spent - td->o.bw_avg_time);
        return min(next, next_log);
 }
 
        return min(next, next_log);
 }
 
@@ -2554,9 +2555,10 @@ static int add_iops_samples(struct thread_data *td, struct timeval *t)
        td_io_u_unlock(td);
 
        if (spent <= td->o.iops_avg_time)
        td_io_u_unlock(td);
 
        if (spent <= td->o.iops_avg_time)
-               return min(next_log, td->o.iops_avg_time);
+               next = td->o.iops_avg_time;
+       else
+               next = td->o.iops_avg_time - (1 + spent - td->o.iops_avg_time);
 
 
-       next = td->o.iops_avg_time - (1 + spent - td->o.iops_avg_time);
        return min(next, next_log);
 }
 
        return min(next, next_log);
 }