Make switch_ioscheduler() return 0 if FIO_HAVE_IOSCHED_SWITCH is undefined
[fio.git] / backend.c
index 45ee156948ed03e9ba63055e20f82c20a44fc6c1..2f290d2d7d1358429c1a66440f79de648bfd88c9 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -603,6 +603,15 @@ static void do_verify(struct thread_data *td, uint64_t verify_bytes)
        if (td->error)
                return;
 
+       /*
+        * verify_state needs to be reset before verification
+        * proceeds so that expected random seeds match actual
+        * random seeds in headers. The main loop will reset
+        * all random number generators if randrepeat is set.
+        */
+       if (!td->o.rand_repeatable)
+               td_fill_verify_state_seed(td);
+
        td_set_runstate(td, TD_VERIFYING);
 
        io_u = NULL;
@@ -1252,6 +1261,7 @@ static int init_io_u(struct thread_data *td)
 
 static int switch_ioscheduler(struct thread_data *td)
 {
+#ifdef FIO_HAVE_IOSCHED_SWITCH
        char tmp[256], tmp2[128];
        FILE *f;
        int ret;
@@ -1310,6 +1320,9 @@ static int switch_ioscheduler(struct thread_data *td)
 
        fclose(f);
        return 0;
+#else
+       return 0;
+#endif
 }
 
 static bool keep_running(struct thread_data *td)
@@ -1428,8 +1441,6 @@ static void *thread_main(void *data)
        struct thread_data *td = fd->td;
        struct thread_options *o = &td->o;
        struct sk_out *sk_out = fd->sk_out;
-       pthread_condattr_t attr;
-       pthread_mutexattr_t mattr;
        int clear_state;
        int ret;
 
@@ -1456,34 +1467,16 @@ static void *thread_main(void *data)
        INIT_FLIST_HEAD(&td->next_rand_list);
        td->io_hist_tree = RB_ROOT;
 
-       ret = pthread_mutexattr_init(&mattr);
-       if (ret) {
-               td_verror(td, ret, "pthread_mutexattr_init");
-               goto err;
-       }
-#ifdef FIO_HAVE_PSHARED_MUTEX
-       ret = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
-       if (ret) {
-               td_verror(td, ret, "pthread_mutexattr_setpshared");
-               goto err;
-       }
-#endif
-       pthread_mutex_init(&td->io_u_lock, &mattr);
-
-       ret = pthread_condattr_init(&attr);
+       ret = mutex_cond_init_pshared(&td->io_u_lock, &td->free_cond);
        if (ret) {
-               td_verror(td, ret, "pthread_condattr_init");
+               td_verror(td, ret, "mutex_cond_init_pshared");
                goto err;
        }
-#ifdef FIO_HAVE_PSHARED_MUTEX
-       ret = pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+       ret = cond_init_pshared(&td->verify_cond);
        if (ret) {
-               td_verror(td, ret, "pthread_condattr_setpshared");
+               td_verror(td, ret, "mutex_cond_pshared");
                goto err;
        }
-#endif
-       pthread_cond_init(&td->verify_cond, &attr);
-       pthread_cond_init(&td->free_cond, &attr);
 
        td_set_runstate(td, TD_INITIALIZED);
        dprint(FD_MUTEX, "up startup_mutex\n");
@@ -2376,7 +2369,7 @@ int fio_backend(struct sk_out *sk_out)
                        for (i = 0; i < DDIR_RWDIR_CNT; i++) {
                                struct io_log *log = agg_io_log[i];
 
-                               flush_log(log, 0);
+                               flush_log(log, false);
                                free_log(log);
                        }
                }