X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=init.c;h=f0768ba304197a01b7d91a014fa633ef51a7a238;hp=f00ced32100d0886307ea6e3a885037af48865d3;hb=3b5ccd399357b971ccabe08743d1efdffbbb9b3f;hpb=860a8a6724f6660ee0e1232c3a980f0e1ef567ec diff --git a/init.c b/init.c index f00ced32..f0768ba3 100644 --- a/init.c +++ b/init.c @@ -19,7 +19,7 @@ #include "smalloc.h" #include "filehash.h" -static char fio_version_string[] = "fio 1.23"; +static char fio_version_string[] = "fio 1.26.3"; #define FIO_RANDSEED (0xb1899bedUL) @@ -27,7 +27,7 @@ static char **ini_file; static int max_jobs = MAX_JOBS; static int dump_cmdline; -struct thread_data def_thread; +static struct thread_data def_thread; struct thread_data *threads = NULL; int exitall_on_terminate = 0; @@ -206,6 +206,13 @@ static int setup_rate(struct thread_data *td) return 0; } +static int fixed_block_size(struct thread_options *o) +{ + return o->min_bs[DDIR_READ] == o->max_bs[DDIR_READ] && + o->min_bs[DDIR_WRITE] == o->max_bs[DDIR_WRITE] && + o->min_bs[DDIR_READ] == o->min_bs[DDIR_WRITE]; +} + /* * Lazy way of fixing up options that depend on each other. We could also * define option callback handlers, but this is easier. @@ -214,6 +221,23 @@ static int fixup_options(struct thread_data *td) { struct thread_options *o = &td->o; +#ifndef FIO_HAVE_PSHARED_MUTEX + if (!td->o.use_thread) { + log_info("fio: this platform does not support process shared" + " mutexes, forcing use of threads. Use the 'thread'" + " option to get rid of this warning.\n"); + td->o.use_thread = 1; + } +#endif + +#ifndef FIO_HAVE_CPU_AFFINITY + if (td->o.gtod_cpu) { + log_err("fio: platform must support CPU affinity for" + "gettimeofday() offloading\n"); + return 1; + } +#endif + if (read_only && td_write(td)) { log_err("fio: job <%s> has write bit set, but fio is in" " read-only mode\n", td->o.name); @@ -249,11 +273,28 @@ static int fixup_options(struct thread_data *td) o->rw_min_bs = min(o->min_bs[DDIR_READ], o->min_bs[DDIR_WRITE]); + /* + * For random IO, allow blockalign offset other than min_bs. + */ + if (!o->ba[DDIR_READ] || !td_random(td)) + o->ba[DDIR_READ] = o->min_bs[DDIR_READ]; + if (!o->ba[DDIR_WRITE] || !td_random(td)) + o->ba[DDIR_WRITE] = o->min_bs[DDIR_WRITE]; + + if ((o->ba[DDIR_READ] != o->min_bs[DDIR_READ] || + o->ba[DDIR_WRITE] != o->min_bs[DDIR_WRITE]) && + !td->o.norandommap) { + log_err("fio: Any use of blockalign= turns off randommap\n"); + td->o.norandommap = 1; + } + if (!o->file_size_high) o->file_size_high = o->file_size_low; - if (o->norandommap && o->verify != VERIFY_NONE) { - log_err("fio: norandommap given, verify disabled\n"); + if (o->norandommap && o->verify != VERIFY_NONE + && !fixed_block_size(o)) { + log_err("fio: norandommap given for variable block sizes, " + "verify disabled\n"); o->verify = VERIFY_NONE; } if (o->bs_unaligned && (o->odirect || td->io_ops->flags & FIO_RAWIO)) @@ -367,13 +408,32 @@ static int exists_and_not_file(const char *filename) return 1; } +void td_fill_rand_seeds(struct thread_data *td) +{ + os_random_seed(td->rand_seeds[0], &td->bsrange_state); + os_random_seed(td->rand_seeds[1], &td->verify_state); + os_random_seed(td->rand_seeds[2], &td->rwmix_state); + + if (td->o.file_service_type == FIO_FSERVICE_RANDOM) + os_random_seed(td->rand_seeds[3], &td->next_file_state); + + os_random_seed(td->rand_seeds[5], &td->file_size_state); + + if (!td_random(td)) + return; + + if (td->o.rand_repeatable) + td->rand_seeds[4] = FIO_RANDSEED * td->thread_number; + + os_random_seed(td->rand_seeds[4], &td->random_state); +} + /* * Initialize the various random states we need (random io, block size ranges, * read/write mix, etc). */ static int init_random_state(struct thread_data *td) { - unsigned long seeds[6]; int fd; fd = open("/dev/urandom", O_RDONLY); @@ -382,30 +442,15 @@ static int init_random_state(struct thread_data *td) return 1; } - if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) { + if (read(fd, td->rand_seeds, sizeof(td->rand_seeds)) < + (int) sizeof(td->rand_seeds)) { td_verror(td, EIO, "read"); close(fd); return 1; } close(fd); - - os_random_seed(seeds[0], &td->bsrange_state); - os_random_seed(seeds[1], &td->verify_state); - os_random_seed(seeds[2], &td->rwmix_state); - - if (td->o.file_service_type == FIO_FSERVICE_RANDOM) - os_random_seed(seeds[3], &td->next_file_state); - - os_random_seed(seeds[5], &td->file_size_state); - - if (!td_random(td)) - return 0; - - if (td->o.rand_repeatable) - seeds[4] = FIO_RANDSEED * td->thread_number; - - os_random_seed(seeds[4], &td->random_state); + td_fill_rand_seeds(td); return 0; } @@ -559,6 +604,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (file_alloced) { td_new->o.filename = NULL; td_new->files_index = 0; + td_new->files_size = 0; td_new->files = NULL; } @@ -581,7 +627,7 @@ static int skip_this_section(const char *name) if (!strncmp(name, "global", 6)) return 0; - return strncmp(job_section, name, strlen(job_section)); + return strcmp(job_section, name); } static int is_empty_or_comment(char *line) @@ -878,6 +924,7 @@ struct debug_level debug_levels[] = { { .name = "parse", .shift = FD_PARSE }, { .name = "diskutil", .shift = FD_DISKUTIL }, { .name = "job", .shift = FD_JOB }, + { .name = "mutex", .shift = FD_MUTEX }, { .name = NULL, }, }; @@ -1104,5 +1151,11 @@ int parse_options(int argc, char *argv[]) return 1; } + if (def_thread.o.gtod_offload) { + fio_gtod_init(); + fio_gtod_offload = 1; + fio_gtod_cpu = def_thread.o.gtod_cpu; + } + return 0; }