X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;ds=sidebyside;f=backend.c;h=698940791201dadf9b021145eca60dee5d04494c;hb=59d8f4125b0871cc26ad60150bcf4cd29f7daac7;hp=1dcdcf049026db4f1ae33d04284ade793b76d77f;hpb=92330695e64a42fd5dc54a6970a4b8122d3cd80e;p=fio.git diff --git a/backend.c b/backend.c index 1dcdcf04..69894079 100644 --- a/backend.c +++ b/backend.c @@ -55,6 +55,7 @@ #include "err.h" #include "lib/tp.h" #include "workqueue.h" +#include "lib/mountcheck.h" static pthread_t helper_thread; static pthread_mutex_t helper_lock; @@ -372,6 +373,9 @@ static inline void update_runtime(struct thread_data *td, unsigned long long *elapsed_us, const enum fio_ddir ddir) { + if (ddir == DDIR_WRITE && td_write(td) && td->o.verify_only) + return; + td->ts.runtime[ddir] -= (elapsed_us[ddir] + 999) / 1000; elapsed_us[ddir] += utime_since_now(&td->start); td->ts.runtime[ddir] += (elapsed_us[ddir] + 999) / 1000; @@ -1171,13 +1175,17 @@ static int switch_ioscheduler(struct thread_data *td) /* * Read back and check that the selected scheduler is now the default. */ + memset(tmp, 0, sizeof(tmp)); ret = fread(tmp, sizeof(tmp), 1, f); if (ferror(f) || ret < 0) { td_verror(td, errno, "fread"); fclose(f); return 1; } - tmp[sizeof(tmp) - 1] = '\0'; + /* + * either a list of io schedulers or "none\n" is expected. + */ + tmp[strlen(tmp) - 1] = '\0'; sprintf(tmp2, "[%s]", td->o.ioscheduler); @@ -1234,7 +1242,8 @@ static int keep_running(struct thread_data *td) static int exec_string(struct thread_options *o, const char *string, const char *mode) { - int ret, newlen = strlen(string) + strlen(o->name) + strlen(mode) + 9 + 1; + size_t newlen = strlen(string) + strlen(o->name) + strlen(mode) + 9 + 1; + int ret; char *str; str = malloc(newlen); @@ -1877,11 +1886,12 @@ static int fio_verify_load_state(struct thread_data *td) if (is_backend) { void *data; + int ver; ret = fio_server_get_verify_state(td->o.name, - td->thread_number - 1, &data); + td->thread_number - 1, &data, &ver); if (!ret) - verify_convert_assign_state(td, data); + verify_convert_assign_state(td, data, ver); } else ret = verify_load_state(td, "local"); @@ -1895,6 +1905,27 @@ static void do_usleep(unsigned int usecs) usleep(usecs); } +static int check_mount_writes(struct thread_data *td) +{ + struct fio_file *f; + unsigned int i; + + if (!td_write(td) || td->o.allow_mounted_write) + return 0; + + for_each_file(td, f, i) { + if (f->filetype != FIO_TYPE_BD) + continue; + if (device_is_mounted(f->file_name)) + goto mounted; + } + + return 0; +mounted: + log_err("fio: %s appears mounted, and 'allow_mounted_write' isn't set. Aborting.", f->file_name); + return 1; +} + /* * Main function for kicking off and reaping jobs, as needed. */ @@ -1913,6 +1944,8 @@ static void run_threads(void) nr_thread = nr_process = 0; for_each_td(td, i) { + if (check_mount_writes(td)) + return; if (td->o.use_thread) nr_thread++; else @@ -2261,7 +2294,7 @@ int fio_backend(void) for (i = 0; i < DDIR_RWDIR_CNT; i++) { struct io_log *log = agg_io_log[i]; - flush_log(log); + flush_log(log, 0); free_log(log); } }