iolog: check for thread termination in long delays
authorJens Axboe <axboe@fb.com>
Thu, 10 Apr 2014 22:03:32 +0000 (00:03 +0200)
committerJens Axboe <axboe@fb.com>
Thu, 10 Apr 2014 22:03:32 +0000 (00:03 +0200)
If we are doing a long delay now, fio won't be able to kill
the thread when you ctrl-c the job. Split the delay into .5s
intervals, and check for signal in between.

Signed-off-by: Jens Axboe <axboe@fb.com>
iolog.c

diff --git a/iolog.c b/iolog.c
index 1eb89b29171c2796ce0df8743cdb40b866a1b5e6..f49895929c34fcc3313a9ce6b6500d1e3277c9b6 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -58,6 +58,7 @@ void log_file(struct thread_data *td, struct fio_file *f,
 static void iolog_delay(struct thread_data *td, unsigned long delay)
 {
        unsigned long usec = utime_since_now(&td->last_issue);
 static void iolog_delay(struct thread_data *td, unsigned long delay)
 {
        unsigned long usec = utime_since_now(&td->last_issue);
+       unsigned long this_delay;
 
        if (delay < usec)
                return;
 
        if (delay < usec)
                return;
@@ -70,7 +71,14 @@ static void iolog_delay(struct thread_data *td, unsigned long delay)
        if (delay < 100)
                return;
 
        if (delay < 100)
                return;
 
-       usec_sleep(td, delay);
+       while (delay && !td->terminate) {
+               this_delay = delay;
+               if (this_delay > 500000)
+                       this_delay = 500000;
+
+               usec_sleep(td, this_delay);
+               delay -= this_delay;
+       }
 }
 
 static int ipo_special(struct thread_data *td, struct io_piece *ipo)
 }
 
 static int ipo_special(struct thread_data *td, struct io_piece *ipo)