X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=init.c;h=3041ac45fed2ac66a77af0f6a811747eaa74cf34;hp=8dc57845ee24605ea316e6252ca8f5684365d74c;hb=35c0ba7ff55bbd438cdc171945c61d501a4e693e;hpb=85af57948a9c0d5c2ece9c680a41c1670888a09e diff --git a/init.c b/init.c index 8dc57845..3041ac45 100644 --- a/init.c +++ b/init.c @@ -221,6 +221,7 @@ static void free_shm(void) threads = NULL; file_hash_exit(); + flow_exit(); fio_debug_jobp = NULL; shmdt(tp); shmctl(shm_id, IPC_RMID, &sbuf); @@ -277,6 +278,9 @@ static int setup_thread_area(void) fio_debug_jobp = (void *) hash + file_hash_size; *fio_debug_jobp = -1; file_hash_init(hash); + + flow_init(); + return 0; } @@ -324,6 +328,7 @@ static void put_job(struct thread_data *td) return; profile_td_exit(td); + flow_exit_job(td); if (td->error) log_info("fio: %s\n", td->verror); @@ -550,6 +555,28 @@ static int fixup_options(struct thread_data *td) } #endif +#ifdef WIN32 + /* + * Windows doesn't support O_DIRECT or O_SYNC with the _open interface, + * so fail if we're passed those flags + */ + if ((td->io_ops->flags & FIO_SYNCIO) && (td->o.odirect || td->o.sync_io)) { + log_err("fio: Windows does not support direct or non-buffered io with" + " the synchronous ioengines. Use the 'windowsaio' ioengine" + " with 'direct=1' and 'iodepth=1' instead.\n"); + ret = 1; + } +#endif + + /* + * For fully compressible data, just zero them at init time. + * It's faster than repeatedly filling it. + */ + if (td->o.compress_percentage == 100) { + td->o.zero_buffers = 1; + td->o.compress_percentage = 0; + } + return ret; } @@ -655,31 +682,6 @@ void td_fill_rand_seeds(struct thread_data *td) init_rand_seed(&td->buf_state, td->rand_seeds[7]); } -/* - * 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) -{ - int fd; - - fd = open("/dev/urandom", O_RDONLY); - if (fd == -1) { - td_verror(td, errno, "open"); - return 1; - } - - 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); - td_fill_rand_seeds(td); - return 0; -} /* * Initializes the ioengine configured for a job, if it has not been done so @@ -742,10 +744,9 @@ int ioengine_load(struct thread_data *td) * to make sure we don't have conflicts, and initializes various * members of td. */ -static int add_job(struct thread_data *td, const char *jobname, int job_add_num) +static int add_job(struct thread_data *td, const char *jobname, int job_add_num, + int recursed) { - const char *ddir_str[] = { NULL, "read", "write", "rw", NULL, - "randread", "randwrite", "randrw" }; unsigned int i; char fname[PATH_MAX]; int numjobs, file_alloced; @@ -796,6 +797,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (fixup_options(td)) goto err; + flow_init_job(td); + /* * IO engines only need this for option callbacks, and the address may * change in subprocesses. @@ -832,8 +835,10 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) td->groupid = groupid; prev_group_jobs++; - if (init_random_state(td)) + if (init_random_state(td, td->rand_seeds, sizeof(td->rand_seeds))) { + td_verror(td, errno, "init_random_state"); goto err; + } if (setup_rate(td)) goto err; @@ -853,6 +858,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (!terse_output) { if (!job_add_num) { + if (is_backend && !recursed) + fio_server_send_add_job(&td->o, td->io_ops->name); + if (!strcmp(td->io_ops->name, "cpuio")) { log_info("%s: ioengine=cpu, cpuload=%u," " cpucycle=%u\n", td->o.name, @@ -869,7 +877,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) log_info("%s: (g=%d): rw=%s, bs=%s-%s/%s-%s," " ioengine=%s, iodepth=%u\n", td->o.name, td->groupid, - ddir_str[td->o.td_ddir], + ddir_str(td->o.td_ddir), c1, c2, c3, c4, td->io_ops->name, td->o.iodepth); @@ -907,7 +915,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) job_add_num = numjobs - 1; - if (add_job(td_new, jobname, job_add_num)) + if (add_job(td_new, jobname, job_add_num, 1)) goto err; } @@ -932,7 +940,7 @@ void add_job_opts(const char **o) if (!strncmp(o[i], "name", 4)) { in_global = 0; if (td) - add_job(td, jobname, 0); + add_job(td, jobname, 0, 0); td = NULL; sprintf(jobname, "%s", o[i] + 5); } @@ -951,7 +959,7 @@ void add_job_opts(const char **o) } if (td) - add_job(td, jobname, 0); + add_job(td, jobname, 0, 0); } static int skip_this_section(const char *name) @@ -1133,7 +1141,7 @@ int parse_jobs_ini(char *file, int is_buf, int stonewall_flag) for (i = 0; i < num_opts; i++) log_info("--%s ", opts[i]); - ret = add_job(td, name, 0); + ret = add_job(td, name, 0, 0); } else { log_err("fio: job %s dropped\n", name); put_job(td); @@ -1218,20 +1226,62 @@ static void usage(const char *name) #ifdef FIO_INC_DEBUG struct debug_level debug_levels[] = { - { .name = "process", .shift = FD_PROCESS, }, - { .name = "file", .shift = FD_FILE, }, - { .name = "io", .shift = FD_IO, }, - { .name = "mem", .shift = FD_MEM, }, - { .name = "blktrace", .shift = FD_BLKTRACE }, - { .name = "verify", .shift = FD_VERIFY }, - { .name = "random", .shift = FD_RANDOM }, - { .name = "parse", .shift = FD_PARSE }, - { .name = "diskutil", .shift = FD_DISKUTIL }, - { .name = "job", .shift = FD_JOB }, - { .name = "mutex", .shift = FD_MUTEX }, - { .name = "profile", .shift = FD_PROFILE }, - { .name = "time", .shift = FD_TIME }, - { .name = "net", .shift = FD_NET }, + { .name = "process", + .help = "Process creation/exit logging", + .shift = FD_PROCESS, + }, + { .name = "file", + .help = "File related action logging", + .shift = FD_FILE, + }, + { .name = "io", + .help = "IO and IO engine action logging (offsets, queue, completions, etc)", + .shift = FD_IO, + }, + { .name = "mem", + .help = "Memory allocation/freeing logging", + .shift = FD_MEM, + }, + { .name = "blktrace", + .help = "blktrace action logging", + .shift = FD_BLKTRACE, + }, + { .name = "verify", + .help = "IO verification action logging", + .shift = FD_VERIFY, + }, + { .name = "random", + .help = "Random generation logging", + .shift = FD_RANDOM, + }, + { .name = "parse", + .help = "Parser logging", + .shift = FD_PARSE, + }, + { .name = "diskutil", + .help = "Disk utility logging actions", + .shift = FD_DISKUTIL, + }, + { .name = "job", + .help = "Logging related to creating/destroying jobs", + .shift = FD_JOB, + }, + { .name = "mutex", + .help = "Mutex logging", + .shift = FD_MUTEX + }, + { .name = "profile", + .help = "Logging related to profiles", + .shift = FD_PROFILE, + }, + { .name = "time", + .help = "Logging related to time keeping functions", + .shift = FD_TIME, + }, + { .name = "net", + .help = "Network logging", + .shift = FD_NET, + }, { .name = NULL, }, }; @@ -1457,7 +1507,7 @@ int parse_cmd_line(int argc, char *argv[]) char *val = optarg; if (!strncmp(opt, "name", 4) && td) { - ret = add_job(td, td->o.name ?: "fio", 0); + ret = add_job(td, td->o.name ?: "fio", 0, 0); if (ret) return 0; td = NULL; @@ -1529,7 +1579,7 @@ int parse_cmd_line(int argc, char *argv[]) exit_val = 1; break; } - if (fio_client_add(optarg, &cur_client)) { + if (fio_client_add(&fio_client_ops, optarg, &cur_client)) { log_err("fio: failed adding client %s\n", optarg); do_exit++; exit_val = 1; @@ -1561,7 +1611,7 @@ int parse_cmd_line(int argc, char *argv[]) if (td) { if (!ret) - ret = add_job(td, td->o.name ?: "fio", 0); + ret = add_job(td, td->o.name ?: "fio", 0, 0); } while (!ret && optind < argc) { @@ -1574,10 +1624,8 @@ int parse_cmd_line(int argc, char *argv[]) return ini_idx; } -int parse_options(int argc, char *argv[]) +int fio_init_options(void) { - int job_files, i; - f_out = stdout; f_err = stderr; @@ -1589,6 +1637,20 @@ int parse_options(int argc, char *argv[]) if (fill_def_thread()) return 1; + return 0; +} + +extern int fio_check_options(struct thread_options *); + +int parse_options(int argc, char *argv[]) +{ + int job_files, i; + + if (fio_init_options()) + return 1; + if (fio_test_cconv(&def_thread.o)) + log_err("fio: failed internal cconv test\n"); + job_files = parse_cmd_line(argc, argv); if (job_files > 0) {