Fix integer overflow in rate_iops
authorJens Axboe <axboe@fb.com>
Fri, 25 Sep 2015 02:35:44 +0000 (20:35 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 25 Sep 2015 02:35:44 +0000 (20:35 -0600)
For the following job file:

[bla]
rw=randread
bs=1024m
rate_iops=100

We end up overflowing in multiplication, making the bps field 0.
Fio exits by reporting:

rate lower than supported

Fix this by casting to uint64_t, the type of the output.

Signed-off-by: Jens Axboe <axboe@fb.com>
init.c

diff --git a/init.c b/init.c
index cdb98c57231066b5e71c7c7ce2636c7870215d15..684cd60042809ff473843f1f846b3bff3565d00e 100644 (file)
--- a/init.c
+++ b/init.c
@@ -465,7 +465,7 @@ static int __setup_rate(struct thread_data *td, enum fio_ddir ddir)
        if (td->o.rate[ddir])
                td->rate_bps[ddir] = td->o.rate[ddir];
        else
-               td->rate_bps[ddir] = td->o.rate_iops[ddir] * bs;
+               td->rate_bps[ddir] = (uint64_t) td->o.rate_iops[ddir] * bs;
 
        if (!td->rate_bps[ddir]) {
                log_err("rate lower than supported\n");