* [PATCH] Fix initialization of lastrate when using ratemin
@ 2011-11-18 21:37 Josh Carter
2011-11-22 8:36 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Josh Carter @ 2011-11-18 21:37 UTC (permalink / raw)
To: fio
fio was copying td->bw_sample_time (single timeval) into td->lastrate
(array of two timevals) using the latter's size. Thus is would get one
timeval worth of good data plus who-knows-what for the second timeval.
I'm pretty sure the intent of this code was to copy bw_sample_time
into both members of lastrate.
---
fio.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/fio.c b/fio.c
index 9063c03..6ba445d 100644
--- a/fio.c
+++ b/fio.c
@@ -1284,9 +1284,12 @@ static void *thread_main(void *data)
memcpy(&td->iops_sample_time, &td->start, sizeof(td->start));
memcpy(&td->tv_cache, &td->start, sizeof(td->start));
- if (td->o.ratemin[0] || td->o.ratemin[1])
- memcpy(&td->lastrate, &td->bw_sample_time,
- sizeof(td->lastrate));
+ if (td->o.ratemin[0] || td->o.ratemin[1]) {
+ memcpy(&td->lastrate[0], &td->bw_sample_time,
+ sizeof(td->bw_sample_time));
+ memcpy(&td->lastrate[1], &td->bw_sample_time,
+ sizeof(td->bw_sample_time));
+ }
if (clear_state)
clear_io_state(td);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix initialization of lastrate when using ratemin
2011-11-18 21:37 [PATCH] Fix initialization of lastrate when using ratemin Josh Carter
@ 2011-11-22 8:36 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2011-11-22 8:36 UTC (permalink / raw)
To: Josh Carter; +Cc: fio
On 2011-11-18 22:37, Josh Carter wrote:
> fio was copying td->bw_sample_time (single timeval) into td->lastrate
> (array of two timevals) using the latter's size. Thus is would get one
> timeval worth of good data plus who-knows-what for the second timeval.
> I'm pretty sure the intent of this code was to copy bw_sample_time
> into both members of lastrate.
Thanks, applied!
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-22 8:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-18 21:37 [PATCH] Fix initialization of lastrate when using ratemin Josh Carter
2011-11-22 8:36 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox