X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=backend.c;h=e20a2e07766eabf4ea0f86dfde6db40e9ed621f7;hb=90711edc3d0fb70fd94104831d7bb305780b8619;hp=0e454cdd1e9a4f2979320e7b913cc5f242d4b362;hpb=0c153a89ce498bf8c9e330165b6971d88ca2b12e;p=fio.git diff --git a/backend.c b/backend.c index 0e454cdd..e20a2e07 100644 --- a/backend.c +++ b/backend.c @@ -62,8 +62,9 @@ struct io_log *agg_io_log[DDIR_RWDIR_CNT]; int groupid = 0; unsigned int thread_number = 0; +unsigned int nr_segments = 0; +unsigned int cur_segment = 0; unsigned int stat_number = 0; -int shm_id = 0; int temp_stall_ts; unsigned long done_secs = 0; #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP @@ -76,7 +77,7 @@ pthread_mutex_t overlap_check = PTHREAD_MUTEX_INITIALIZER; static void sig_int(int sig) { - if (threads) { + if (nr_segments) { if (is_backend) fio_server_got_signal(sig); else { @@ -223,12 +224,10 @@ static bool check_min_rate(struct thread_data *td, struct timespec *now) { bool ret = false; - if (td->bytes_done[DDIR_READ]) - ret |= __check_min_rate(td, now, DDIR_READ); - if (td->bytes_done[DDIR_WRITE]) - ret |= __check_min_rate(td, now, DDIR_WRITE); - if (td->bytes_done[DDIR_TRIM]) - ret |= __check_min_rate(td, now, DDIR_TRIM); + for_each_rw_ddir(ddir) { + if (td->bytes_done[ddir]) + ret |= __check_min_rate(td, now, ddir); + } return ret; } @@ -440,7 +439,7 @@ static int wait_for_completions(struct thread_data *td, struct timespec *time) if ((full && !min_evts) || !td->o.iodepth_batch_complete_min) min_evts = 1; - if (time && __should_check_rate(td)) + if (time && should_check_rate(td)) fio_gettime(time, NULL); do { @@ -495,7 +494,7 @@ int io_queue_event(struct thread_data *td, struct io_u *io_u, int *ret, requeue_io_u(td, &io_u); } else { sync_done: - if (comp_time && __should_check_rate(td)) + if (comp_time && should_check_rate(td)) fio_gettime(comp_time, NULL); *ret = io_u_sync_complete(td, io_u); @@ -1460,16 +1459,17 @@ static bool keep_running(struct thread_data *td) return false; } -static int exec_string(struct thread_options *o, const char *string, const char *mode) +static int exec_string(struct thread_options *o, const char *string, + const char *mode) { - size_t newlen = strlen(string) + strlen(o->name) + strlen(mode) + 13 + 1; int ret; char *str; - str = malloc(newlen); - sprintf(str, "%s > %s.%s.txt 2>&1", string, o->name, mode); + if (asprintf(&str, "%s > %s.%s.txt 2>&1", string, o->name, mode) < 0) + return -1; - log_info("%s : Saving output of %s in %s.%s.txt\n",o->name, mode, o->name, mode); + log_info("%s : Saving output of %s in %s.%s.txt\n", o->name, mode, + o->name, mode); ret = system(str); if (ret == -1) log_err("fio: exec of cmd <%s> failed\n", str); @@ -1733,7 +1733,7 @@ static void *thread_main(void *data) if (!init_random_map(td)) goto err; - if (o->exec_prerun && exec_string(o, o->exec_prerun, (const char *)"prerun")) + if (o->exec_prerun && exec_string(o, o->exec_prerun, "prerun")) goto err; if (o->pre_read && !pre_read_files(td)) @@ -1876,9 +1876,9 @@ static void *thread_main(void *data) update_rusage_stat(td); td->ts.total_run_time = mtime_since_now(&td->epoch); - td->ts.io_bytes[DDIR_READ] = td->io_bytes[DDIR_READ]; - td->ts.io_bytes[DDIR_WRITE] = td->io_bytes[DDIR_WRITE]; - td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM]; + for_each_rw_ddir(ddir) { + td->ts.io_bytes[ddir] = td->io_bytes[ddir]; + } if (td->o.verify_state_save && !(td->flags & TD_F_VSTATE_SAVED) && (td->o.verify != VERIFY_NONE && td_write(td))) @@ -1892,7 +1892,7 @@ static void *thread_main(void *data) rate_submit_exit(td); if (o->exec_postrun) - exec_string(o, o->exec_postrun, (const char *)"postrun"); + exec_string(o, o->exec_postrun, "postrun"); if (exitall_on_terminate || (o->exitall_error && td->error)) fio_terminate_threads(td->groupid, td->o.exit_what); @@ -2044,6 +2044,7 @@ reaped: done_secs += mtime_since_now(&td->epoch) / 1000; profile_td_exit(td); + flow_exit_job(td); } if (*nr_running == cputhreads && !pending && realthreads)