[PATCH] Fix random io truncate on 32-bit archs
authorJens Axboe <axboe@suse.de>
Thu, 1 Jun 2006 22:54:09 +0000 (15:54 -0700)
committerJens Axboe <axboe@suse.de>
Thu, 1 Jun 2006 22:54:09 +0000 (15:54 -0700)
fio.c

diff --git a/fio.c b/fio.c
index bedad68fa385bbcd66008780bac12d6386429dfd..864bcb451d6c2e9cda0292669f7effb0696d1c6a 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -288,12 +288,12 @@ static int get_next_offset(struct thread_data *td, unsigned long long *offset)
        long r;
 
        if (!td->sequential) {
        long r;
 
        if (!td->sequential) {
-               unsigned long max_blocks = td->io_size / td->min_bs;
+               unsigned long long max_blocks = td->io_size / td->min_bs;
                int loops = 50;
 
                do {
                        lrand48_r(&td->random_state, &r);
                int loops = 50;
 
                do {
                        lrand48_r(&td->random_state, &r);
-                       b = ((max_blocks - 1) * r / (RAND_MAX+1.0));
+                       b = ((max_blocks - 1) * r / (unsigned long long) (RAND_MAX+1.0));
                        rb = b + (td->file_offset / td->min_bs);
                        loops--;
                } while (!random_map_free(td, rb) && loops);
                        rb = b + (td->file_offset / td->min_bs);
                        loops--;
                } while (!random_map_free(td, rb) && loops);