From: Jens Axboe Date: Fri, 4 Jan 2013 12:09:29 +0000 (+0100) Subject: zipf/pareto: use min of file size and io size for init X-Git-Tag: fio-2.0.13~8 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=21415db9f1689a5c47fda5e710879c4739707442 zipf/pareto: use min of file size and io size for init 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 --- diff --git a/filesetup.c b/filesetup.c index be2eba52..41809093 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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; + uint64_t file_size; 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)