From 74f4b020b3c8053ff319c3da900a5cf07e51c8eb Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 22 Mar 2013 22:56:55 -0600 Subject: [PATCH] Consider the maximum block size difference the minimum for loop exit For mixed block sizes, we can hit the condition where we decided to stop even if we could have done a small block size. Don't do another loop for those cases. Signed-off-by: Jens Axboe --- backend.c | 5 ++--- fio.h | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/backend.c b/backend.c index 3567990b..ae4216db 100644 --- a/backend.c +++ b/backend.c @@ -884,8 +884,7 @@ static int init_io_u(struct thread_data *td) char *p; max_units = td->o.iodepth; - max_bs = max(td->o.max_bs[DDIR_READ], td->o.max_bs[DDIR_WRITE]); - max_bs = max(td->o.max_bs[DDIR_TRIM], max_bs); + max_bs = td_max_bs(td); min_write = td->o.min_bs[DDIR_WRITE]; td->orig_buffer_size = (unsigned long long) max_bs * (unsigned long long) max_units; @@ -1042,7 +1041,7 @@ static int keep_running(struct thread_data *td) * are done. */ diff = td->o.size - ddir_rw_sum(td->io_bytes); - if (diff < td->o.rw_min_bs) + if (diff < td_max_bs(td)) return 0; return 1; diff --git a/fio.h b/fio.h index 4478eb6f..621ed606 100644 --- a/fio.h +++ b/fio.h @@ -805,6 +805,14 @@ static inline int should_check_rate(struct thread_data *td, return ret; } +static inline unsigned int td_max_bs(struct thread_data *td) +{ + unsigned int max_bs; + + max_bs = max(td->o.max_bs[DDIR_READ], td->o.max_bs[DDIR_WRITE]); + return max(td->o.max_bs[DDIR_TRIM], max_bs); +} + static inline int is_power_of_2(unsigned int val) { return (val != 0 && ((val & (val - 1)) == 0)); -- 2.25.1