X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=fio.c;h=c609f55d8e9520672e8c1e67e8c7b811dbceb002;hp=6e25c5fe6feb6df17a530b283612e695224437c6;hb=24ffd2c2bca53f4de85ab6defd52a812be1f2429;hpb=a1dedc1f6347a33fd1265348db86a9258cadefd2 diff --git a/fio.c b/fio.c index 6e25c5fe..c609f55d 100644 --- a/fio.c +++ b/fio.c @@ -49,7 +49,7 @@ int nr_thread = 0; int shm_id = 0; int temp_stall_ts; -static struct fio_sem *startup_sem; +static struct fio_mutex *startup_mutex; static volatile int fio_abort; static int exit_value; @@ -82,8 +82,12 @@ static void terminate_threads(int group_id) */ if (td->runstate < TD_RUNNING) kill(td->pid, SIGQUIT); - else if (td->io_ops->flags & FIO_SIGQUIT) - kill(td->pid, SIGQUIT); + else { + struct ioengine_ops *ops = td->io_ops; + + if (ops && (ops->flags & FIO_SIGQUIT)) + kill(td->pid, SIGQUIT); + } } } } @@ -783,8 +787,7 @@ static int clear_io_state(struct thread_data *td) if (td->o.time_based || td->o.loops) td->nr_done_files = 0; - for_each_file(td, f, i) - td_io_close_file(td, f); + close_files(td); ret = 0; for_each_file(td, f, i) { @@ -822,14 +825,14 @@ static void *thread_main(void *data) td->io_hist_tree = RB_ROOT; td_set_runstate(td, TD_INITIALIZED); - fio_sem_up(startup_sem); - fio_sem_down(td->mutex); + fio_mutex_up(startup_mutex); + fio_mutex_down(td->mutex); /* - * the ->mutex semaphore is now no longer used, close it to avoid + * the ->mutex mutex is now no longer used, close it to avoid * eating a file descriptor */ - fio_sem_remove(td->mutex); + fio_mutex_remove(td->mutex); /* * May alter parameters that init_io_u() will use, so we need to @@ -962,7 +965,7 @@ static void *thread_main(void *data) err: if (td->error) printf("fio: pid=%d, err=%d/%s\n", td->pid, td->error, td->verror); - close_files(td); + close_and_free_files(td); close_ioengine(td); cleanup_io_u(td); @@ -1213,7 +1216,7 @@ static void run_threads(void) exit(ret); } } - fio_sem_down(startup_sem); + fio_mutex_down(startup_mutex); } /* @@ -1268,7 +1271,7 @@ static void run_threads(void) m_rate += td->o.ratemin; t_rate += td->o.rate; todo--; - fio_sem_up(td->mutex); + fio_mutex_up(td->mutex); } reap_threads(&nr_running, &t_rate, &m_rate); @@ -1317,7 +1320,7 @@ int main(int argc, char *argv[]) setup_log(&agg_io_log[DDIR_WRITE]); } - startup_sem = fio_sem_init(0); + startup_mutex = fio_mutex_init(0); set_genesis_time(); @@ -1333,6 +1336,6 @@ int main(int argc, char *argv[]) } } - fio_sem_remove(startup_sem); + fio_mutex_remove(startup_mutex); return exit_value; }