From c27cc65f33f4f39e33e5203199048e0a85a8921c Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Sat, 2 Dec 2017 09:18:46 -0700 Subject: [PATCH] steadystate: add free helper Also fix a style issue. Signed-off-by: Jens Axboe --- backend.c | 7 +------ helper_thread.c | 3 +-- steadystate.c | 8 ++++++++ steadystate.h | 1 + 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/backend.c b/backend.c index 10eb90e2..6c805c7f 100644 --- a/backend.c +++ b/backend.c @@ -2480,12 +2480,7 @@ int fio_backend(struct sk_out *sk_out) } for_each_td(td, i) { - if (td->ss.dur) { - if (td->ss.iops_data != NULL) { - free(td->ss.iops_data); - free(td->ss.bw_data); - } - } + steadystate_free(td); fio_options_free(td); if (td->rusage_sem) { fio_mutex_remove(td->rusage_sem); diff --git a/helper_thread.c b/helper_thread.c index 9c6e0a2b..64e5a3c9 100644 --- a/helper_thread.c +++ b/helper_thread.c @@ -134,8 +134,7 @@ static void *helper_thread_main(void *data) next_ss = STEADYSTATE_MSEC - (since_ss - STEADYSTATE_MSEC); else next_ss = STEADYSTATE_MSEC; - } - else + } else next_ss = STEADYSTATE_MSEC - since_ss; } diff --git a/steadystate.c b/steadystate.c index 05ce0299..d0abb47c 100644 --- a/steadystate.c +++ b/steadystate.c @@ -6,6 +6,14 @@ bool steadystate_enabled = false; +void steadystate_free(struct thread_data *td) +{ + free(td->ss.iops_data); + free(td->ss.bw_data); + td->ss.iops_data = NULL; + td->ss.bw_data = NULL; +} + static void steadystate_alloc(struct thread_data *td) { td->ss.bw_data = calloc(td->ss.dur, sizeof(uint64_t)); diff --git a/steadystate.h b/steadystate.h index eaba0d7c..9fd88ee8 100644 --- a/steadystate.h +++ b/steadystate.h @@ -5,6 +5,7 @@ #include "thread_options.h" #include "lib/ieee754.h" +extern void steadystate_free(struct thread_data *); extern void steadystate_check(void); extern void steadystate_setup(void); extern int td_steadystate_init(struct thread_data *); -- 2.25.1