From 3939fe853fd146378811a05b78731d7f20d0152f Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 11 Mar 2014 20:16:38 -0600 Subject: [PATCH] Add exceeds_number_ios() helper Commit 26251d8d open-coded the logic in two places, collapse that into one function. Signed-off-by: Jens Axboe --- backend.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/backend.c b/backend.c index bab20266..1ff8b3f6 100644 --- a/backend.c +++ b/backend.c @@ -623,9 +623,21 @@ reap: dprint(FD_VERIFY, "exiting loop\n"); } +static unsigned int exceeds_number_ios(struct thread_data *td) +{ + unsigned long long number_ios; + + if (!td->o.number_ios) + return 0; + + number_ios = ddir_rw_sum(td->this_io_blocks); + number_ios += td->io_u_queued + td->io_u_in_flight; + + return number_ios >= td->o.number_ios; +} + static int io_bytes_exceeded(struct thread_data *td) { - unsigned long long number_ios = 0; unsigned long long bytes; if (td_rw(td)) @@ -637,13 +649,7 @@ static int io_bytes_exceeded(struct thread_data *td) else bytes = td->this_io_bytes[DDIR_TRIM]; - if (td->o.number_ios) { - number_ios = ddir_rw_sum(td->this_io_blocks); - number_ios += td->io_u_queued + td->io_u_in_flight; - } - - return bytes >= td->o.size || - (number_ios && number_ios >= td->o.number_ios); + return bytes >= td->o.size || exceeds_number_ios(td); } /* @@ -1134,14 +1140,8 @@ static int keep_running(struct thread_data *td) td->o.loops--; return 1; } - - if (td->o.number_ios) { - unsigned long long number_ios = ddir_rw_sum(td->this_io_blocks); - - number_ios += td->io_u_queued + td->io_u_in_flight; - if (number_ios >= td->o.number_ios) - return 0; - } + if (exceeds_number_ios(td)) + return 0; if (td->o.size != -1ULL && ddir_rw_sum(td->io_bytes) < td->o.size) { uint64_t diff; -- 2.25.1