Re: about get_rand_file_size()

From: ljzhang,Yaxin Hu,Jianchao Tang <nonggia_at_sjtu.edu.cn>
Date: Fri, 27 Jul 2007 21:53:30 +0800

On Fri, 2007-07-27 at 15:39 +0200, Jens Axboe wrote:
> On Fri, Jul 27 2007, ljzhang,Yaxin Hu,Jianchao Tang wrote:
> > Jens:
> > When I was test my previous fix for 'offset', I encounter another
> > problem. The files created with a random size by get_rand_file_size()
> > doesn't in accordance with option 'filesize'.
> > So I wonder if the function should be fixed like this:
> > -------------------------------------------
> > diff -Nraup fio-7.27/filesetup.c fio-7.27-randsize/filesetup.c
> > --- fio-7.27/filesetup.c 2007-07-27 19:25:06.000000000 +0800
> > +++ fio-7.27-randsize/filesetup.c 2007-07-27 21:05:51.000000000 +0800
> > @@ -104,7 +104,7 @@ static unsigned long long get_rand_file_
> > long r;
> >
> > r = os_random_long(&td->file_size_state);
> > - ret = td->o.file_size_low + (unsigned long long) ((double)
> > td->o.file_size_high * (r / (RAND_MAX + 1.0)));
> > + ret = td->o.file_size_low + (unsigned long long) ((double)
> > (td->o.file_size_high - td->o.file_size_low) * (r / (RAND_MAX + 1.0)));
> > ret -= (ret % td->o.rw_min_bs);
> > return ret;
> > }
> > -------------------------------------------
>
> Hmm, what does this fix? The options are meant to indicate the smallest
> file we will generate (file_size_low), and the largest (file_size_high).
>
Yes. That's what I think the option mean.
I think before the change the ret generated is in the range:

[file_size_low, file_size_low+file_size_high]

And after the fix, it is:

[file_size_low, file_size_high]

Because r is in the range from 0 to RAND_MAX. Is that right? Or I made a
mistake?
Received on Fri Jul 27 2007 - 15:53:30 CEST

This archive was generated by hypermail 2.2.0 : Fri Jul 27 2007 - 16:00:01 CEST