Add exceeds_number_ios() helper

Commit 26251d8d open-coded the logic in two places, collapse
that into one function.

Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/backend.c b/backend.c
index bab2026..1ff8b3f 100644
--- a/backend.c
+++ b/backend.c
@@ -623,9 +623,21 @@
 	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 @@
 	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 @@
 		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;