Work-around too large block count

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/io_u.c b/io_u.c
index ce08c59..c728168 100644
--- a/io_u.c
+++ b/io_u.c
@@ -79,8 +79,16 @@
 					    enum fio_ddir ddir)
 {
 	unsigned long long max_blocks;
+	unsigned long long max_size;
 
-	max_blocks = f->io_size / (unsigned long long) td->o.min_bs[ddir];
+	/*
+	 * Hmm, should we make sure that ->io_size <= ->real_file_size?
+	 */
+	max_size = f->io_size;
+	if (max_size > f->real_file_size)
+		max_size = f->real_file_size;
+
+	max_blocks = max_size / (unsigned long long) td->o.min_bs[ddir];
 	if (!max_blocks)
 		return 0;