projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
init: don't set did_arg just for an engine option
[fio.git]
/
flow.c
diff --git
a/flow.c
b/flow.c
index 2993f4e8f8c48dbdc86ad25afc0653fcef31a481..f9d868d8e7505c3a0cdb3adc8a7b2bb806526984 100644
(file)
--- a/
flow.c
+++ b/
flow.c
@@
-23,8
+23,11
@@
int flow_threshold_exceeded(struct thread_data *td)
sign = td->o.flow > 0 ? 1 : -1;
if (sign * flow->flow_counter > td->o.flow_watermark) {
sign = td->o.flow > 0 ? 1 : -1;
if (sign * flow->flow_counter > td->o.flow_watermark) {
- if (td->o.flow_sleep)
+ if (td->o.flow_sleep) {
+ io_u_quiesce(td);
usleep(td->o.flow_sleep);
usleep(td->o.flow_sleep);
+ }
+
return 1;
}
return 1;
}
@@
-39,6
+42,9
@@
static struct fio_flow *flow_get(unsigned int id)
struct fio_flow *flow = NULL;
struct flist_head *n;
struct fio_flow *flow = NULL;
struct flist_head *n;
+ if (!flow_lock)
+ return NULL;
+
fio_mutex_down(flow_lock);
flist_for_each(n, flow_list) {
fio_mutex_down(flow_lock);
flist_for_each(n, flow_list) {
@@
-51,6
+57,10
@@
static struct fio_flow *flow_get(unsigned int id)
if (!flow) {
flow = smalloc(sizeof(*flow));
if (!flow) {
flow = smalloc(sizeof(*flow));
+ if (!flow) {
+ log_err("fio: smalloc pool exhausted\n");
+ return NULL;
+ }
flow->refs = 0;
INIT_FLIST_HEAD(&flow->list);
flow->id = id;
flow->refs = 0;
INIT_FLIST_HEAD(&flow->list);
flow->id = id;
@@
-66,6
+76,9
@@
static struct fio_flow *flow_get(unsigned int id)
static void flow_put(struct fio_flow *flow)
{
static void flow_put(struct fio_flow *flow)
{
+ if (!flow_lock)
+ return;
+
fio_mutex_down(flow_lock);
if (!--flow->refs) {
fio_mutex_down(flow_lock);
if (!--flow->refs) {
@@
-92,13
+105,26
@@
void flow_exit_job(struct thread_data *td)
void flow_init(void)
{
void flow_init(void)
{
- flow_lock = fio_mutex_init(FIO_MUTEX_UNLOCKED);
flow_list = smalloc(sizeof(*flow_list));
flow_list = smalloc(sizeof(*flow_list));
+ if (!flow_list) {
+ log_err("fio: smalloc pool exhausted\n");
+ return;
+ }
+
+ flow_lock = fio_mutex_init(FIO_MUTEX_UNLOCKED);
+ if (!flow_lock) {
+ log_err("fio: failed to allocate flow lock\n");
+ sfree(flow_list);
+ return;
+ }
+
INIT_FLIST_HEAD(flow_list);
}
void flow_exit(void)
{
INIT_FLIST_HEAD(flow_list);
}
void flow_exit(void)
{
- fio_mutex_remove(flow_lock);
- sfree(flow_list);
+ if (flow_lock)
+ fio_mutex_remove(flow_lock);
+ if (flow_list)
+ sfree(flow_list);
}
}