X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=init.c;h=ee6c139db28c03da7f77727e403c5d6c3acb36a8;hp=f25bbe657374dc3e965af366e9c4dd794c1de663;hb=823ba54bfc91f18fdd847e6efc41b422529bc4f8;hpb=60862e579e7f47ceede8f8d105413c2114687c2a diff --git a/init.c b/init.c index f25bbe65..ee6c139d 100644 --- a/init.c +++ b/init.c @@ -26,11 +26,11 @@ #include "fio_version.h" #if FIO_PATCH > 0 -static char fio_version_string[] = __fio_stringify(FIO_MAJOR) "." \ +const char fio_version_string[] = __fio_stringify(FIO_MAJOR) "." \ __fio_stringify(FIO_MINOR) "." \ __fio_stringify(FIO_PATCH); #else -static char fio_version_string[] = __fio_stringify(FIO_MAJOR) "." \ +const char fio_version_string[] = __fio_stringify(FIO_MAJOR) "." \ __fio_stringify(FIO_MINOR); #endif @@ -54,7 +54,7 @@ char **job_sections = NULL; int nr_job_sections = 0; char *exec_profile = NULL; int warnings_fatal = 0; -int terse_version = 2; +int terse_version = 3; int is_backend = 0; int nr_clients = 0; int log_syslog = 0; @@ -194,7 +194,7 @@ static struct option l_opts[FIO_NR_OPTIONS] = { .val = 'S', }, { .name = (char *) "daemonize", - .has_arg = no_argument, + .has_arg = required_argument, .val = 'D', }, { @@ -318,6 +318,8 @@ static void put_job(struct thread_data *td) if (td->error) log_info("fio: %s\n", td->verror); + fio_options_free(td); + memset(&threads[td->thread_number - 1], 0, sizeof(*td)); thread_number--; } @@ -962,7 +964,7 @@ int parse_jobs_ini(char *file, int is_buf, int stonewall_flag) if (is_buf) p = strsep(&file, "\n"); else - p = fgets(string, 4095, f); + p = fgets(string, 4096, f); if (!p) break; } @@ -1070,6 +1072,12 @@ int parse_jobs_ini(char *file, int is_buf, int stonewall_flag) if (dump_cmdline) log_info("\n"); + i = 0; + while (i < nr_job_sections) { + free(job_sections[i]); + i++; + } + for (i = 0; i < num_opts; i++) free(opts[i]); @@ -1099,31 +1107,34 @@ static void usage(const char *name) { printf("fio %s\n", fio_version_string); printf("%s [options] [job options] \n", name); - printf("\t--debug=options\tEnable debug logging\n"); - printf("\t--output\tWrite output to file\n"); - printf("\t--timeout\tRuntime in seconds\n"); - printf("\t--latency-log\tGenerate per-job latency logs\n"); - printf("\t--bandwidth-log\tGenerate per-job bandwidth logs\n"); - printf("\t--minimal\tMinimal (terse) output\n"); - printf("\t--version\tPrint version info and exit\n"); - printf("\t--terse-version=x Terse version output format\n"); - printf("\t--help\t\tPrint this page\n"); - printf("\t--cmdhelp=cmd\tPrint command help, \"all\" for all of" + printf(" --debug=options\tEnable debug logging. May be one/more of:\n" + "\t\t\tprocess,file,io,mem,blktrace,verify,random,parse,\n" + "\t\t\tdiskutil,job,mutex,profile,time,net\n"); + printf(" --output\t\tWrite output to file\n"); + printf(" --timeout\t\tRuntime in seconds\n"); + printf(" --latency-log\t\tGenerate per-job latency logs\n"); + printf(" --bandwidth-log\tGenerate per-job bandwidth logs\n"); + printf(" --minimal\t\tMinimal (terse) output\n"); + printf(" --version\t\tPrint version info and exit\n"); + printf(" --terse-version=x\tTerse version output format to 'x'\n"); + printf(" --help\t\tPrint this page\n"); + printf(" --cmdhelp=cmd\t\tPrint command help, \"all\" for all of" " them\n"); - printf("\t--showcmd\tTurn a job file into command line options\n"); - printf("\t--eta=when\tWhen ETA estimate should be printed\n"); - printf("\t \tMay be \"always\", \"never\" or \"auto\"\n"); - printf("\t--readonly\tTurn on safety read-only checks, preventing" + printf(" --showcmd\t\tTurn a job file into command line options\n"); + printf(" --eta=when\t\tWhen ETA estimate should be printed\n"); + printf(" \t\tMay be \"always\", \"never\" or \"auto\"\n"); + printf(" --readonly\t\tTurn on safety read-only checks, preventing" " writes\n"); - printf("\t--section=name\tOnly run specified section in job file\n"); - printf("\t--alloc-size=kb\tSet smalloc pool to this size in kb" + printf(" --section=name\tOnly run specified section in job file\n"); + printf(" --alloc-size=kb\tSet smalloc pool to this size in kb" " (def 1024)\n"); - printf("\t--warnings-fatal Fio parser warnings are fatal\n"); - printf("\t--max-jobs\tMaximum number of threads/processes to support\n"); - printf("\t--server=args\tStart a backend fio server\n"); - printf("\t--client=hostname Talk to remote backend fio server at hostname\n"); + printf(" --warnings-fatal\tFio parser warnings are fatal\n"); + printf(" --max-jobs=nr\t\tMaximum number of threads/processes to support\n"); + printf(" --server=args\t\tStart a backend fio server\n"); + printf(" --daemonize=pidfile\tBackground fio server, write pid to file\n"); + printf(" --client=hostname\tTalk to remote backend fio server at hostname\n"); printf("\nFio was written by Jens Axboe "); - printf("\n Jens Axboe \n"); + printf("\n Jens Axboe \n"); } #ifdef FIO_INC_DEBUG @@ -1253,7 +1264,7 @@ int parse_cmd_line(int argc, char *argv[]) struct thread_data *td = NULL; int c, ini_idx = 0, lidx, ret = 0, do_exit = 0, exit_val = 0; char *ostr = cmd_optstr; - int daemonize_server = 0; + void *pid_file = NULL; void *cur_client = NULL; int backend = 0; @@ -1321,7 +1332,7 @@ int parse_cmd_line(int argc, char *argv[]) break; case 'V': terse_version = atoi(optarg); - if (terse_version != 2) { + if (!(terse_version == 2 || terse_version == 3)) { log_err("fio: bad terse version format\n"); exit_val = 1; do_exit++; @@ -1408,7 +1419,7 @@ int parse_cmd_line(int argc, char *argv[]) backend = 1; break; case 'D': - daemonize_server = 1; + pid_file = strdup(optarg); break; case 'C': if (is_backend) { @@ -1445,7 +1456,7 @@ int parse_cmd_line(int argc, char *argv[]) } if (is_backend && backend) - return fio_start_server(daemonize_server); + return fio_start_server(pid_file); if (td) { if (!ret) @@ -1496,7 +1507,7 @@ int parse_options(int argc, char *argv[]) } free(ini_file); - options_mem_free(&def_thread); + fio_options_free(&def_thread); if (!thread_number) { if (dump_cmdline) @@ -1524,6 +1535,8 @@ int parse_options(int argc, char *argv[]) fio_gtod_cpu = def_thread.o.gtod_cpu; } - log_info("fio %s\n", fio_version_string); + if (!terse_output) + log_info("fio %s\n", fio_version_string); + return 0; }