X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=init.c;h=742262867a3d51ecd529b033264789ee00c947d0;hp=d4a4f339d2a8358de22850fa59f523dca9632181;hb=203160d52b866497caef35335a7032fb9702a4af;hpb=2f122b135b7319ff8dd04dadf31ff28b301051a3 diff --git a/init.c b/init.c index d4a4f339..74226286 100644 --- a/init.c +++ b/init.c @@ -25,14 +25,7 @@ #include "fio_version.h" -#if FIO_PATCH > 0 -const char fio_version_string[] = __fio_stringify(FIO_MAJOR) "." \ - __fio_stringify(FIO_MINOR) "." \ - __fio_stringify(FIO_PATCH); -#else -const char fio_version_string[] = __fio_stringify(FIO_MAJOR) "." \ - __fio_stringify(FIO_MINOR); -#endif +const char fio_version_string[] = FIO_VERSION; #define FIO_RANDSEED (0xb1899bedUL) @@ -47,7 +40,6 @@ struct thread_data *threads = NULL; int exitall_on_terminate = 0; int terse_output = 0; int eta_print; -unsigned long long mlock_size = 0; FILE *f_out = NULL; FILE *f_err = NULL; char **job_sections = NULL; @@ -74,21 +66,23 @@ static char cmd_optstr[256]; static int did_arg; const fio_fp64_t def_percentile_list[FIO_IO_U_LIST_MAX_LEN] = { - { .u.f = 1.0 }, - { .u.f = 5.0 }, - { .u.f = 10.0 }, - { .u.f = 20.0 }, - { .u.f = 30.0 }, - { .u.f = 40.0 }, - { .u.f = 50.0 }, - { .u.f = 60.0 }, - { .u.f = 70.0 }, - { .u.f = 80.0 }, - { .u.f = 90.0 }, - { .u.f = 95.0 }, - { .u.f = 99.0 }, - { .u.f = 99.5 }, - { .u.f = 99.9 }, + { .u.f = 1.00 }, + { .u.f = 5.00 }, + { .u.f = 10.00 }, + { .u.f = 20.00 }, + { .u.f = 30.00 }, + { .u.f = 40.00 }, + { .u.f = 50.00 }, + { .u.f = 60.00 }, + { .u.f = 70.00 }, + { .u.f = 80.00 }, + { .u.f = 90.00 }, + { .u.f = 95.00 }, + { .u.f = 99.00 }, + { .u.f = 99.50 }, + { .u.f = 99.90 }, + { .u.f = 99.95 }, + { .u.f = 99.99 }, }; #define FIO_CLIENT_FLAG (1 << 16) @@ -212,7 +206,7 @@ static struct option l_opts[FIO_NR_OPTIONS] = { }, }; -static void free_shm(void) +void free_threads_shm(void) { struct shmid_ds sbuf; @@ -220,11 +214,19 @@ static void free_shm(void) void *tp = threads; threads = NULL; + shmdt(tp); + shmctl(shm_id, IPC_RMID, &sbuf); + shm_id = -1; + } +} + +void free_shm(void) +{ + if (threads) { file_hash_exit(); flow_exit(); fio_debug_jobp = NULL; - shmdt(tp); - shmctl(shm_id, IPC_RMID, &sbuf); + free_threads_shm(); } scleanup(); @@ -583,7 +585,7 @@ static int fixup_options(struct thread_data *td) /* * This function leaks the buffer */ -static char *to_kmg(unsigned int val) +char *fio_uint_to_kmg(unsigned int val) { char *buf = malloc(32); char post[] = { 0, 'K', 'M', 'G', 'P', 'E', 0 }; @@ -773,11 +775,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, if (ioengine_load(td)) goto err; - if (td->o.use_thread) - nr_thread++; - else - nr_process++; - if (td->o.odirect) td->io_ops->flags |= FIO_RAWIO; @@ -845,14 +842,14 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, if (setup_rate(td)) goto err; - if (td->o.write_lat_log) { + if (td->o.lat_log_file) { setup_log(&td->lat_log, td->o.log_avg_msec, IO_LOG_TYPE_LAT); setup_log(&td->slat_log, td->o.log_avg_msec, IO_LOG_TYPE_SLAT); setup_log(&td->clat_log, td->o.log_avg_msec, IO_LOG_TYPE_CLAT); } - if (td->o.write_bw_log) + if (td->o.bw_log_file) setup_log(&td->bw_log, td->o.log_avg_msec, IO_LOG_TYPE_BW); - if (td->o.write_iops_log) + if (td->o.iops_log_file) setup_log(&td->iops_log, td->o.log_avg_msec, IO_LOG_TYPE_IOPS); if (!td->o.name) @@ -863,18 +860,13 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, if (is_backend && !recursed) fio_server_send_add_job(td); - if (!strcmp(td->io_ops->name, "cpuio")) { - log_info("%s: ioengine=cpu, cpuload=%u," - " cpucycle=%u\n", td->o.name, - td->o.cpuload, - td->o.cpucycle); - } else { + if (!(td->io_ops->flags & FIO_NOIO)) { char *c1, *c2, *c3, *c4; - c1 = to_kmg(td->o.min_bs[DDIR_READ]); - c2 = to_kmg(td->o.max_bs[DDIR_READ]); - c3 = to_kmg(td->o.min_bs[DDIR_WRITE]); - c4 = to_kmg(td->o.max_bs[DDIR_WRITE]); + c1 = fio_uint_to_kmg(td->o.min_bs[DDIR_READ]); + c2 = fio_uint_to_kmg(td->o.max_bs[DDIR_READ]); + c3 = fio_uint_to_kmg(td->o.min_bs[DDIR_WRITE]); + c4 = fio_uint_to_kmg(td->o.max_bs[DDIR_WRITE]); log_info("%s: (g=%d): rw=%s, bs=%s-%s/%s-%s," " ioengine=%s, iodepth=%u\n", @@ -1190,7 +1182,7 @@ static int fill_def_thread(void) static void usage(const char *name) { - printf("fio %s\n", fio_version_string); + printf("%s\n", fio_version_string); printf("%s [options] [job options] \n", name); printf(" --debug=options\tEnable debug logging. May be one/more of:\n" "\t\t\tprocess,file,io,mem,blktrace,verify,random,parse,\n" @@ -1463,7 +1455,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type) break; case 'v': if (!cur_client) { - log_info("fio %s\n", fio_version_string); + log_info("%s\n", fio_version_string); do_exit++; } break; @@ -1702,7 +1694,12 @@ int parse_options(int argc, char *argv[]) } if (!terse_output) - log_info("fio %s\n", fio_version_string); + log_info("%s\n", fio_version_string); return 0; } + +void options_default_fill(struct thread_options *o) +{ + memcpy(o, &def_thread.o, sizeof(*o)); +}