summaryrefslogtreecommitdiff
path: root/flow.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2017-10-12 10:54:27 -0600
committerJens Axboe <axboe@kernel.dk>2017-10-12 10:54:27 -0600
commitc13a60ce72aaf5b07b93977ab86e7522d167ec28 (patch)
tree7aa931d831def78f1d61beab0ccc0504dde818a2 /flow.c
parent939bb94fd1f1431128e3009fc68c79f973be6de8 (diff)
flow: fix bad overflowing math
No point in multiplying with a 1/-1 integer, just assign a local variable appropriately. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'flow.c')
-rw-r--r--flow.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/flow.c b/flow.c
index 42b6dd7..384187e 100644
--- a/flow.c
+++ b/flow.c
@@ -16,13 +16,17 @@ static struct fio_mutex *flow_lock;
int flow_threshold_exceeded(struct thread_data *td)
{
struct fio_flow *flow = td->flow;
- int sign;
+ long long flow_counter;
if (!flow)
return 0;
- sign = td->o.flow > 0 ? 1 : -1;
- if (sign * flow->flow_counter > td->o.flow_watermark) {
+ if (td->o.flow > 0)
+ flow_counter = flow->flow_counter;
+ else
+ flow_counter = -flow->flow_counter;
+
+ if (flow_counter > td->o.flow_watermark) {
if (td->o.flow_sleep) {
io_u_quiesce(td);
usleep(td->o.flow_sleep);