From f4f9dd6eb3b81f2cb79aa3c41fd4d131cca91b6c Mon Sep 17 00:00:00 2001
From: Justin Eno <jeno@micron.com>
Date: Tue, 27 Jan 2015 14:23:20 -0800
Subject: [PATCH] Better accommodate random writes larger than blockalign

fill_io_u() fails prematurely if the randomly-chosen offset satisfies
blockalign but not min_bs, i.e., the offset lies too near the end of
the target region.  This change honors both parameters.

Signed-off-by: Justin Eno <jeno@micron.com>
---
 io_u.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/io_u.c b/io_u.c
index 5971d78..77a3abf 100644
--- a/io_u.c
+++ b/io_u.c
@@ -68,6 +68,9 @@ static uint64_t last_block(struct thread_data *td, struct fio_file *f,
 	if (td->o.zone_range)
 		max_size = td->o.zone_range;
 
+	if (td->o.min_bs[ddir] > td->o.ba[ddir])
+		max_size -= td->o.min_bs[ddir] - td->o.ba[ddir];
+
 	max_blocks = max_size / (uint64_t) td->o.ba[ddir];
 	if (!max_blocks)
 		return 0;
-- 
1.7.1

