examples/libpmem.fio: clean up example
[fio.git] / flow.c
diff --git a/flow.c b/flow.c
index f9d868d8e7505c3a0cdb3adc8a7b2bb806526984..384187ef0a59095d7754c6435132afe00ef9fd09 100644 (file)
--- 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);
@@ -58,7 +62,7 @@ static struct fio_flow *flow_get(unsigned int id)
        if (!flow) {
                flow = smalloc(sizeof(*flow));
                if (!flow) {
-                       log_err("fio: smalloc pool exhausted\n");
+                       fio_mutex_up(flow_lock);
                        return NULL;
                }
                flow->refs = 0;