From ebea21332ee7d7d12f17cbe9718611bcec558210 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 9 Jul 2014 11:24:12 +0200 Subject: [PATCH] Fix cases where td->terminate is set, but terminate clock not marked Signed-off-by: Jens Axboe --- backend.c | 8 ++++---- fio.h | 1 + libfio.c | 10 ++++++++-- verify.c | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/backend.c b/backend.c index d9ece4c7..30f78b72 100644 --- a/backend.c +++ b/backend.c @@ -391,7 +391,7 @@ static int break_on_this_error(struct thread_data *td, enum fio_ddir ddir, * fill_device option is set. */ td_clear_error(td); - td->terminate = 1; + fio_mark_td_terminate(td); return 1; } else { /* @@ -460,7 +460,7 @@ static void do_verify(struct thread_data *td, uint64_t verify_bytes) if (runtime_exceeded(td, &td->tv_cache)) { __update_tv_cache(td); if (runtime_exceeded(td, &td->tv_cache)) { - td->terminate = 1; + fio_mark_td_terminate(td); break; } } @@ -714,7 +714,7 @@ static uint64_t do_io(struct thread_data *td) if (runtime_exceeded(td, &td->tv_cache)) { __update_tv_cache(td); if (runtime_exceeded(td, &td->tv_cache)) { - td->terminate = 1; + fio_mark_td_terminate(td); break; } } @@ -922,7 +922,7 @@ reap: if (td->o.fill_device && td->error == ENOSPC) { td->error = 0; - td->terminate = 1; + fio_mark_td_terminate(td); } if (!td->error) { struct fio_file *f; diff --git a/fio.h b/fio.h index 199610c7..c694f2cf 100644 --- a/fio.h +++ b/fio.h @@ -495,6 +495,7 @@ extern void td_restore_runstate(struct thread_data *, int); #define TERMINATE_ALL (-1) extern void fio_terminate_threads(int); +extern void fio_mark_td_terminate(struct thread_data *); /* * Memory helpers diff --git a/libfio.c b/libfio.c index 9245688a..5a996f9c 100644 --- a/libfio.c +++ b/libfio.c @@ -187,6 +187,13 @@ void td_restore_runstate(struct thread_data *td, int old_state) td_set_runstate(td, old_state); } +void fio_mark_td_terminate(struct thread_data *td) +{ + fio_gettime(&td->terminate_time, NULL); + write_barrier(); + td->terminate = 1; +} + void fio_terminate_threads(int group_id) { struct thread_data *td; @@ -203,9 +210,8 @@ void fio_terminate_threads(int group_id) if (td->terminate) continue; - td->terminate = 1; + fio_mark_td_terminate(td); td->o.start_delay = 0; - fio_gettime(&td->terminate_time, NULL); /* * if the thread is running, just let it exit diff --git a/verify.c b/verify.c index 11963e15..e59a4b29 100644 --- a/verify.c +++ b/verify.c @@ -847,7 +847,7 @@ int verify_io_u(struct thread_data *td, struct io_u *io_u) done: if (ret && td->o.verify_fatal) - td->terminate = 1; + fio_mark_td_terminate(td); return ret; } @@ -1205,7 +1205,7 @@ static void *verify_async_thread(void *data) if (ret) { td_verror(td, ret, "async_verify"); if (td->o.verify_fatal) - td->terminate = 1; + fio_mark_td_terminate(td); } done: -- 2.25.1