- INIT_LIST_HEAD(&td->io_u_freelist);
- INIT_LIST_HEAD(&td->io_u_busylist);
- INIT_LIST_HEAD(&td->io_u_requeues);
- INIT_LIST_HEAD(&td->io_hist_list);
- INIT_LIST_HEAD(&td->io_log_list);
+ dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid);
+
+ INIT_FLIST_HEAD(&td->io_u_freelist);
+ INIT_FLIST_HEAD(&td->io_u_busylist);
+ INIT_FLIST_HEAD(&td->io_u_requeues);
+ INIT_FLIST_HEAD(&td->io_log_list);
+ INIT_FLIST_HEAD(&td->io_hist_list);
+ INIT_FLIST_HEAD(&td->verify_list);
+ pthread_mutex_init(&td->io_u_lock, NULL);
+ td->io_hist_tree = RB_ROOT;
+
+ pthread_condattr_init(&attr);
+ 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");
+ fio_mutex_up(startup_mutex);
+ dprint(FD_MUTEX, "wait on td->mutex\n");
+ fio_mutex_down(td->mutex);
+ dprint(FD_MUTEX, "done waiting on td->mutex\n");
+
+ /*
+ * the ->mutex mutex is now no longer used, close it to avoid
+ * eating a file descriptor
+ */
+ fio_mutex_remove(td->mutex);
+
+ if (td->o.uid != -1U && setuid(td->o.uid)) {
+ td_verror(td, errno, "setuid");
+ goto err;
+ }
+ if (td->o.gid != -1U && setgid(td->o.gid)) {
+ td_verror(td, errno, "setgid");
+ goto err;
+ }
+
+ /*
+ * May alter parameters that init_io_u() will use, so we need to
+ * do this first.
+ */
+ if (init_iolog(td))
+ goto err;