X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=fio.c;h=bdf9fd188dde338bcffe13a4eb43df938993fbf6;hp=f0665e072ccbd5f6ac3f4dcd52a5edfe015cbf31;hb=c592b9fe12d4739d99d5bece517e304804876df6;hpb=0fe2187702d5d65e2b0f47e23824f41572eb4446 diff --git a/fio.c b/fio.c index f0665e07..bdf9fd18 100644 --- a/fio.c +++ b/fio.c @@ -37,6 +37,8 @@ #include "fio.h" #include "hash.h" #include "smalloc.h" +#include "verify.h" +#include "diskutil.h" unsigned long page_mask; unsigned long page_size; @@ -52,6 +54,7 @@ int temp_stall_ts; unsigned long done_secs = 0; static struct fio_mutex *startup_mutex; +static struct fio_mutex *writeout_mutex; static volatile int fio_abort; static int exit_value; static struct itimerval itimer; @@ -382,7 +385,7 @@ static void do_verify(struct thread_data *td) * read from disk. */ for_each_file(td, f, i) { - if (!(f->flags & FIO_FILE_OPEN)) + if (!fio_file_open(f)) continue; if (fio_io_sync(td, f)) break; @@ -699,7 +702,7 @@ sync_done: td_set_runstate(td, TD_FSYNCING); for_each_file(td, f, i) { - if (!(f->flags & FIO_FILE_OPEN)) + if (!fio_file_open(f)) continue; fio_io_sync(td, f); } @@ -921,7 +924,23 @@ static void clear_io_state(struct thread_data *td) close_files(td); for_each_file(td, f, i) - f->flags &= ~FIO_FILE_DONE; + fio_file_clear_done(f); +} + +static int exec_string(const char *string) +{ + int ret, newlen = strlen(string) + 1 + 8; + char *str; + + str = malloc(newlen); + sprintf(str, "sh -c %s", string); + + ret = system(str); + if (ret == -1) + log_err("fio: exec of cmd <%s> failed\n", str); + + free(str); + return ret; } /* @@ -1013,7 +1032,12 @@ static void *thread_main(void *data) goto err; if (td->o.exec_prerun) { - if (system(td->o.exec_prerun) < 0) + if (exec_string(td->o.exec_prerun)) + goto err; + } + + if (td->o.pre_read) { + if (pre_read_files(td) < 0) goto err; } @@ -1086,6 +1110,7 @@ static void *thread_main(void *data) td->ts.io_bytes[0] = td->io_bytes[0]; td->ts.io_bytes[1] = td->io_bytes[1]; + fio_mutex_down(writeout_mutex); if (td->ts.bw_log) { if (td->o.bw_log_file) { finish_log_named(td, td->ts.bw_log, @@ -1107,10 +1132,9 @@ static void *thread_main(void *data) } else finish_log(td, td->ts.clat_log, "clat"); } - if (td->o.exec_postrun) { - if (system(td->o.exec_postrun) < 0) - log_err("fio: postrun %s failed\n", td->o.exec_postrun); - } + fio_mutex_up(writeout_mutex); + if (td->o.exec_postrun) + exec_string(td->o.exec_postrun); if (exitall_on_terminate) terminate_threads(td->groupid); @@ -1554,6 +1578,7 @@ int main(int argc, char *argv[]) } startup_mutex = fio_mutex_init(0); + writeout_mutex = fio_mutex_init(1); set_genesis_time(); @@ -1571,5 +1596,6 @@ int main(int argc, char *argv[]) } fio_mutex_remove(startup_mutex); + fio_mutex_remove(writeout_mutex); return exit_value; }