diff options
author | Jens Axboe <axboe@kernel.dk> | 2013-02-07 12:54:10 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2013-02-07 12:54:10 +0100 |
commit | 0d73a2f983c2ec7b4498d92ef1f0f79f2445a2f8 (patch) | |
tree | 9a52bf603488de4a68f45ce002d0d9817f0455a2 /eta.c | |
parent | 10a6b3c67042914fe9d287027bf8792f69e84524 (diff) | |
download | fio-0d73a2f983c2ec7b4498d92ef1f0f79f2445a2f8.tar.gz |
Fix crash and precision of ETA with zones
If zonesize was bigger than zoneskip, we could encounter a divide by
zero when calculating the number of bytes.
Additionally, the math was just wrong for most cases of zone settings.
Improve that.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'eta.c')
-rw-r--r-- | eta.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -139,6 +139,15 @@ static int thread_eta(struct thread_data *td) bytes_total = td->fill_device_size; } + if (td->o.zone_size && td->o.zone_skip && bytes_total) { + unsigned int nr_zones; + uint64_t zone_bytes; + + zone_bytes = bytes_total + td->o.zone_size + td->o.zone_skip; + nr_zones = (zone_bytes - 1) / (td->o.zone_size + td->o.zone_skip); + bytes_total -= nr_zones * td->o.zone_skip; + } + /* * if writing and verifying afterwards, bytes_total will be twice the * size. In a mixed workload, verify phase will be the size of the @@ -156,9 +165,6 @@ static int thread_eta(struct thread_data *td) bytes_total <<= 1; } - if (td->o.zone_size && td->o.zone_skip) - bytes_total /= (td->o.zone_skip / td->o.zone_size); - if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING) { double perc, perc_t; |