Fix cases where td->terminate is set, but terminate clock not marked
authorJens Axboe <axboe@fb.com>
Wed, 9 Jul 2014 09:24:12 +0000 (11:24 +0200)
committerJens Axboe <axboe@fb.com>
Wed, 9 Jul 2014 09:24:12 +0000 (11:24 +0200)
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c
fio.h
libfio.c
verify.c

index d9ece4c7bd5079eae66030e501b4b6ec9fff6666..30f78b72f9d15acdca6c04930a8e26db53fa2d5e 100644 (file)
--- 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 199610c7468cc5bdb0e19d7f8e4ffcdceaa4529e..c694f2cf40f1c48a9d332e36d25517878e5c02b1 100644 (file)
--- 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
index 9245688a029b7771c300df0c923ce680f426e04b..5a996f9cbd6e9f35d09709ad70ff78d3a3365c69 100644 (file)
--- 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
index 11963e15072d78b43d263cbe258bda90cbf4c0b9..e59a4b29051065cd9ebd1caf0ab1b9494f313211 100644 (file)
--- 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: