8 struct flist_head list;
10 long long int flow_counter;
13 static struct flist_head *flow_list;
14 static struct fio_mutex *flow_lock;
16 int flow_threshold_exceeded(struct thread_data *td)
18 struct fio_flow *flow = td->flow;
24 sign = td->o.flow > 0 ? 1 : -1;
25 if (sign * flow->flow_counter > td->o.flow_watermark) {
27 usleep(td->o.flow_sleep);
31 /* No synchronization needed because it doesn't
32 * matter if the flow count is slightly inaccurate */
33 flow->flow_counter += td->o.flow;
37 static struct fio_flow *flow_get(unsigned int id)
39 struct fio_flow *flow = NULL;
42 fio_mutex_down(flow_lock);
44 flist_for_each(n, flow_list) {
45 flow = flist_entry(n, struct fio_flow, list);
53 flow = smalloc(sizeof(*flow));
55 INIT_FLIST_HEAD(&flow->list);
57 flow->flow_counter = 0;
59 flist_add_tail(&flow->list, flow_list);
63 fio_mutex_up(flow_lock);
67 static void flow_put(struct fio_flow *flow)
69 fio_mutex_down(flow_lock);
72 flist_del(&flow->list);
76 fio_mutex_up(flow_lock);
79 void flow_init_job(struct thread_data *td)
82 td->flow = flow_get(td->o.flow_id);
85 void flow_exit_job(struct thread_data *td)
95 flow_lock = fio_mutex_init(1);
96 flow_list = smalloc(sizeof(*flow_list));
97 INIT_FLIST_HEAD(flow_list);
102 fio_mutex_remove(flow_lock);