Ensure that stat outputs are serialized
Two issues:
- We don't want potentially two stat outputs running at the same time.
This could potentially happen if USR1 or interval stats race with
the thread exit.
- We could potentially crash if the interval or USR1 signaled stat
output trigger when fio is tearing down. Let the main thread wait
for any in-progress output in that case.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/backend.c b/backend.c
index 4d4e8ef..89ffee1 100644
--- a/backend.c
+++ b/backend.c
@@ -1895,6 +1895,7 @@
return 1;
set_genesis_time();
+ stat_init();
create_disk_util_thread();
cgroup_list = smalloc(sizeof(*cgroup_list));
@@ -1924,5 +1925,6 @@
fio_mutex_remove(startup_mutex);
fio_mutex_remove(writeout_mutex);
fio_mutex_remove(disk_thread_mutex);
+ stat_exit();
return exit_value;
}