Fix overlap io_u into outside regions

Test case is a job file ala this:

[global]
ioengine=posixaio
direct=0
filename=testfile
iodepth=128
size=50M
loops=10000000000
group_reporting=1
readwrite=randwrite
do_verify=1
verify=md5
verify_fatal=1
numjobs=1
thread
bsrange=4k:1M

[thread0]
offset=0G

[thread1]
offset=50M

[thread2]
offset=100M

[thread3]
offset=150M

[thread4]
offset=200M

[thread5]
offset=250M

[thread6]
offset=300M

[thread7]
offset=350M

where io_u units from threadN ends up crossing into the zone of threadN+1.
This is due to using file->real_file_size as the boundary check for the
buffer length, where the offset itself is correctly calculated. When
using mixed block sizes, this can cause a blocksize larger than the
minimum size to span into the next region.

Fix this by using file->io_size + offset as the end delimeter. Also
improve the logic of dropping to a smaller allowed block size if we do
end up being close to spanning into the next region.

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 file changed