X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=backend.c;h=5ac365925fdd469a948643bd9ed14bc9759b3f94;hp=bab202662ca5356ec3b6993ee2af76922565d95d;hb=bc4f5ef67d26ef98f4822d5f798cb8c4e2d2fce5;hpb=26251d8d635bc9b9d31de2427095684b0c87b836 diff --git a/backend.c b/backend.c index bab20266..5ac36592 100644 --- a/backend.c +++ b/backend.c @@ -57,7 +57,6 @@ static pthread_t disk_util_thread; static struct fio_mutex *disk_thread_mutex; static struct fio_mutex *startup_mutex; -static struct fio_mutex *writeout_mutex; static struct flist_head *cgroup_list; static char *cgroup_mnt; static int exit_value; @@ -623,9 +622,21 @@ reap: dprint(FD_VERIFY, "exiting loop\n"); } +static unsigned int exceeds_number_ios(struct thread_data *td) +{ + unsigned long long number_ios; + + if (!td->o.number_ios) + return 0; + + number_ios = ddir_rw_sum(td->this_io_blocks); + number_ios += td->io_u_queued + td->io_u_in_flight; + + return number_ios >= td->o.number_ios; +} + static int io_bytes_exceeded(struct thread_data *td) { - unsigned long long number_ios = 0; unsigned long long bytes; if (td_rw(td)) @@ -637,13 +648,7 @@ static int io_bytes_exceeded(struct thread_data *td) else bytes = td->this_io_bytes[DDIR_TRIM]; - if (td->o.number_ios) { - number_ios = ddir_rw_sum(td->this_io_blocks); - number_ios += td->io_u_queued + td->io_u_in_flight; - } - - return bytes >= td->o.size || - (number_ios && number_ios >= td->o.number_ios); + return bytes >= td->o.size || exceeds_number_ios(td); } /* @@ -1134,14 +1139,8 @@ static int keep_running(struct thread_data *td) td->o.loops--; return 1; } - - if (td->o.number_ios) { - unsigned long long number_ios = ddir_rw_sum(td->this_io_blocks); - - number_ios += td->io_u_queued + td->io_u_in_flight; - if (number_ios >= td->o.number_ios) - return 0; - } + if (exceeds_number_ios(td)) + return 0; if (td->o.size != -1ULL && ddir_rw_sum(td->io_bytes) < td->o.size) { uint64_t diff; @@ -1490,45 +1489,8 @@ static void *thread_main(void *data) fio_unpin_memory(td); - fio_mutex_down(writeout_mutex); - finalize_logs(td); - if (td->bw_log) { - if (o->bw_log_file) { - finish_log_named(td, td->bw_log, - o->bw_log_file, "bw"); - } else - finish_log(td, td->bw_log, "bw"); - } - if (td->lat_log) { - if (o->lat_log_file) { - finish_log_named(td, td->lat_log, - o->lat_log_file, "lat"); - } else - finish_log(td, td->lat_log, "lat"); - } - if (td->slat_log) { - if (o->lat_log_file) { - finish_log_named(td, td->slat_log, - o->lat_log_file, "slat"); - } else - finish_log(td, td->slat_log, "slat"); - } - if (td->clat_log) { - if (o->lat_log_file) { - finish_log_named(td, td->clat_log, - o->lat_log_file, "clat"); - } else - finish_log(td, td->clat_log, "clat"); - } - if (td->iops_log) { - if (o->iops_log_file) { - finish_log_named(td, td->iops_log, - o->iops_log_file, "iops"); - } else - finish_log(td, td->iops_log, "iops"); - } + fio_writeout_logs(td); - fio_mutex_up(writeout_mutex); if (o->exec_postrun) exec_string(o, o->exec_postrun, (const char *)"postrun"); @@ -2033,9 +1995,6 @@ int fio_backend(void) startup_mutex = fio_mutex_init(FIO_MUTEX_LOCKED); if (startup_mutex == NULL) return 1; - writeout_mutex = fio_mutex_init(FIO_MUTEX_UNLOCKED); - if (writeout_mutex == NULL) - return 1; set_genesis_time(); stat_init(); @@ -2066,7 +2025,6 @@ int fio_backend(void) sfree(cgroup_mnt); fio_mutex_remove(startup_mutex); - fio_mutex_remove(writeout_mutex); fio_mutex_remove(disk_thread_mutex); stat_exit(); return exit_value;