[PATCH] fio: remember to adjust pending sleep down in case of over time
authorJens Axboe <axboe@suse.de>
Fri, 14 Oct 2005 08:37:02 +0000 (10:37 +0200)
committerJens Axboe <axboe@suse.de>
Fri, 14 Oct 2005 08:37:02 +0000 (10:37 +0200)
fio.c

diff --git a/fio.c b/fio.c
index 998a9fc059ab77c22faa4d0110566883b6386b3f..e4cd6ed5d1c845b5f6d23330dc7abe3c6eec5279 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -325,6 +325,13 @@ void rate_throttle(struct thread_data *td, unsigned long time_spent)
                        usec_sleep(td->rate_pending_usleep);
                        td->rate_pending_usleep = 0;
                }
+       } else if (td->rate_pending_usleep) {
+               long overtime = time_spent - td->rate_usec_cycle;
+
+               if (overtime > td->rate_pending_usleep)
+                       td->rate_pending_usleep = 0;
+               else
+                       td->rate_pending_usleep -= overtime;
        }
 }