Fix issue with random offset being off if io_size != real_file_size
authorRadha Ramachandran <radha@google.com>
Wed, 22 Apr 2009 06:17:42 +0000 (08:17 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 22 Apr 2009 06:17:42 +0000 (08:17 +0200)
get_next_free_block() would generate offset that were larger than the
requested size, either causing failures or just causing the test
to exit prematurely.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
io_u.c

diff --git a/io_u.c b/io_u.c
index d92d940..c0beafd 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -113,7 +113,8 @@ static int get_next_free_block(struct thread_data *td, struct fio_file *f,
 
        i = f->last_free_lookup;
        *b = (i * BLOCKS_PER_MAP);
-       while ((*b) * min_bs < f->real_file_size) {
+       while ((*b) * min_bs < f->real_file_size &&
+               (*b) * min_bs < f->io_size) {
                if (f->file_map[i] != (unsigned int) -1) {
                        *b += ffz(f->file_map[i]);
                        if (*b > last_block(td, f, ddir))