backend: fix potential division-by-zero
authorJens Axboe <axboe@fb.com>
Tue, 15 Apr 2014 14:26:57 +0000 (08:26 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 15 Apr 2014 14:26:57 +0000 (08:26 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c

index 62bca29194ed08a80af9c68afdc1fbda75b164ef..12e562b2a369fc9338001d7b8e8f4254704bf4f6 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -204,7 +204,11 @@ static int __check_min_rate(struct thread_data *td, struct timeval *now,
                                                td->o.name, rate_iops);
                                return 1;
                        } else {
-                               rate = ((iops - td->rate_blocks[ddir]) * 1000) / spent;
+                               if (spent)
+                                       rate = ((iops - td->rate_blocks[ddir]) * 1000) / spent;
+                               else
+                                       rate = 0;
+
                                if (rate < rate_iops_min ||
                                    iops < td->rate_blocks[ddir]) {
                                        log_err("%s: min iops rate %u not met,"