file_service_type=random fix
authorJens Axboe <jens.axboe@oracle.com>
Thu, 8 Mar 2007 12:33:36 +0000 (13:33 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 8 Mar 2007 12:33:36 +0000 (13:33 +0100)
It generated 0..n-1, where we wanted 0..n.

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

diff --git a/io_u.c b/io_u.c
index 0c604df..9f3bb22 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -335,7 +335,7 @@ static struct fio_file *get_next_file_rand(struct thread_data *td)
        do {
                long r = os_random_long(&td->next_file_state);
 
-               fileno = (unsigned int) ((double) (td->open_files - 1) * r / (RAND_MAX + 1.0));
+               fileno = (unsigned int) ((double) (td->open_files * r) / (RAND_MAX + 1.0));
                f = &td->files[fileno];
                if (f->fd != -1)
                        return f;