zipf/pareto: use min of file size and io size for init
authorJens Axboe <axboe@kernel.dk>
Fri, 4 Jan 2013 12:09:29 +0000 (13:09 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 4 Jan 2013 12:13:37 +0000 (13:13 +0100)
It is valid to use size=foo, where foo is larger than the size
of the file or device. For that case, we don't want offsets
larger than the size of the file. So use the minimum of the
real or given size.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
filesetup.c

index be2eba52e38936a74224267c18eb26b7d1303f7c..41809093ffd92b8eac8f5b2e5e89f16facfab12a 100644 (file)
@@ -907,10 +907,12 @@ static int __init_rand_distribution(struct thread_data *td, struct fio_file *f)
 {
        unsigned int range_size, seed;
        unsigned long nranges;
 {
        unsigned int range_size, seed;
        unsigned long nranges;
+       uint64_t file_size;
 
        range_size = min(td->o.min_bs[DDIR_READ], td->o.min_bs[DDIR_WRITE]);
 
        range_size = min(td->o.min_bs[DDIR_READ], td->o.min_bs[DDIR_WRITE]);
+       file_size = min(f->real_file_size, f->io_size);
 
 
-       nranges = (f->io_size + range_size - 1) / range_size;
+       nranges = (file_size + range_size - 1) / range_size;
 
        seed = jhash(f->file_name, strlen(f->file_name), 0) * td->thread_number;
        if (!td->o.rand_repeatable)
 
        seed = jhash(f->file_name, strlen(f->file_name), 0) * td->thread_number;
        if (!td->o.rand_repeatable)