From: Jens Axboe Date: Wed, 12 Mar 2014 02:16:38 +0000 (-0600) Subject: Add exceeds_number_ios() helper X-Git-Tag: fio-2.1.7~14^2 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=3939fe853fd146378811a05b78731d7f20d0152f Add exceeds_number_ios() helper Commit 26251d8d open-coded the logic in two places, collapse that into one function. Signed-off-by: Jens Axboe --- 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;