Add an asprintf() implementation
[fio.git] / verify.c
index b178450714d18bde73c2d52746393d1499364f7f..d10670bb0c328b8ff520ec3e719876b7707ae775 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -241,7 +241,6 @@ struct vcont {
 };
 
 #define DUMP_BUF_SZ    255
-static int dump_buf_warned;
 
 static void dump_buf(char *buf, unsigned int len, unsigned long long offset,
                     const char *type, struct fio_file *f)
@@ -260,10 +259,8 @@ static void dump_buf(char *buf, unsigned int len, unsigned long long offset,
 
        buf_left -= strlen(fname);
        if (buf_left <= 0) {
-               if (!dump_buf_warned) {
+               if (!fio_did_warn(FIO_WARN_VERIFY_BUF))
                        log_err("fio: verify failure dump buffer too small\n");
-                       dump_buf_warned = 1;
-               }
                free(ptr);
                return;
        }
@@ -751,9 +748,9 @@ int verify_io_u_async(struct thread_data *td, struct io_u **io_u_ptr)
        }
        flist_add_tail(&io_u->verify_list, &td->verify_list);
        *io_u_ptr = NULL;
-       pthread_mutex_unlock(&td->io_u_lock);
 
        pthread_cond_signal(&td->verify_cond);
+       pthread_mutex_unlock(&td->io_u_lock);
        return 0;
 }
 
@@ -1310,7 +1307,7 @@ int get_next_verify(struct thread_data *td, struct io_u *io_u)
                return 0;
 
        if (!RB_EMPTY_ROOT(&td->io_hist_tree)) {
-               struct rb_node *n = rb_first(&td->io_hist_tree);
+               struct fio_rb_node *n = rb_first(&td->io_hist_tree);
 
                ipo = rb_entry(n, struct io_piece, rb_node);
 
@@ -1457,9 +1454,9 @@ static void *verify_async_thread(void *data)
 done:
        pthread_mutex_lock(&td->io_u_lock);
        td->nr_verify_threads--;
+       pthread_cond_signal(&td->free_cond);
        pthread_mutex_unlock(&td->io_u_lock);
 
-       pthread_cond_signal(&td->free_cond);
        return NULL;
 }
 
@@ -1495,9 +1492,12 @@ int verify_async_init(struct thread_data *td)
 
        if (i != td->o.verify_async) {
                log_err("fio: only %d verify threads started, exiting\n", i);
+
+               pthread_mutex_lock(&td->io_u_lock);
                td->verify_thread_exit = 1;
-               write_barrier();
                pthread_cond_broadcast(&td->verify_cond);
+               pthread_mutex_unlock(&td->io_u_lock);
+
                return 1;
        }
 
@@ -1506,12 +1506,10 @@ int verify_async_init(struct thread_data *td)
 
 void verify_async_exit(struct thread_data *td)
 {
+       pthread_mutex_lock(&td->io_u_lock);
        td->verify_thread_exit = 1;
-       write_barrier();
        pthread_cond_broadcast(&td->verify_cond);
 
-       pthread_mutex_lock(&td->io_u_lock);
-
        while (td->nr_verify_threads)
                pthread_cond_wait(&td->free_cond, &td->io_u_lock);