Cleanup should_check_rate()
authorJens Axboe <axboe@kernel.dk>
Tue, 5 Jun 2018 19:21:36 +0000 (13:21 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 5 Jun 2018 19:21:36 +0000 (13:21 -0600)
Don't need to check direction for __should_check_rate(), so
clean up the logic.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
backend.c
fio.h

index 180348f841267df45bb2c9d7852d3e70097545ba..e3ff777ba73a478bf344e400fbb2f00a196f0663 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -432,9 +432,7 @@ static int wait_for_completions(struct thread_data *td, struct timespec *time)
        if ((full && !min_evts) || !td->o.iodepth_batch_complete_min)
                min_evts = 1;
 
-       if (time && (__should_check_rate(td, DDIR_READ) ||
-           __should_check_rate(td, DDIR_WRITE) ||
-           __should_check_rate(td, DDIR_TRIM)))
+       if (time && __should_check_rate(td))
                fio_gettime(time, NULL);
 
        do {
@@ -489,9 +487,7 @@ int io_queue_event(struct thread_data *td, struct io_u *io_u, int *ret,
                        requeue_io_u(td, &io_u);
                } else {
 sync_done:
-                       if (comp_time && (__should_check_rate(td, DDIR_READ) ||
-                           __should_check_rate(td, DDIR_WRITE) ||
-                           __should_check_rate(td, DDIR_TRIM)))
+                       if (comp_time && __should_check_rate(td))
                                fio_gettime(comp_time, NULL);
 
                        *ret = io_u_sync_complete(td, io_u);
diff --git a/fio.h b/fio.h
index 6c897fc6fe9e9a4cad5473e1c0641305772a4136..9f3140a97af6c26bf0fbff22be3429d938686c8b 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -721,22 +721,17 @@ static inline bool option_check_rate(struct thread_data *td, enum fio_ddir ddir)
        return false;
 }
 
-static inline bool __should_check_rate(struct thread_data *td,
-                                      enum fio_ddir ddir)
+static inline bool __should_check_rate(struct thread_data *td)
 {
        return (td->flags & TD_F_CHECK_RATE) != 0;
 }
 
 static inline bool should_check_rate(struct thread_data *td)
 {
-       if (__should_check_rate(td, DDIR_READ) && td->bytes_done[DDIR_READ])
-               return true;
-       if (__should_check_rate(td, DDIR_WRITE) && td->bytes_done[DDIR_WRITE])
-               return true;
-       if (__should_check_rate(td, DDIR_TRIM) && td->bytes_done[DDIR_TRIM])
-               return true;
+       if (!__should_check_rate(td))
+               return false;
 
-       return false;
+       return ddir_rw_sum(td->bytes_done) != 0;
 }
 
 static inline unsigned int td_max_bs(struct thread_data *td)