X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=options.c;h=3c37e9105698cbabb0f46d66816de93762d8cd3e;hp=b59dd221fba5220667be82bb062c7ab74ce452e9;hb=3c48c2c1c702047f8a92fa21fdd1471781b9dab4;hpb=c475da759dbd06648277060d72dced84bfcde348 diff --git a/options.c b/options.c index b59dd221..3c37e910 100644 --- a/options.c +++ b/options.c @@ -5,6 +5,10 @@ #include #include #include +#include +#include +#include +#include #include "fio.h" #include "parse.h" @@ -66,7 +70,9 @@ static int str_bssplit_cb(void *data, const char *input) */ if (i == td->o.bssplit_nr) { td->o.bssplit_nr <<= 1; - td->o.bssplit = realloc(td->o.bssplit, td->o.bssplit_nr * sizeof(struct bssplit)); + td->o.bssplit = realloc(td->o.bssplit, + td->o.bssplit_nr + * sizeof(struct bssplit)); } perc_str = strstr(fname, "/"); @@ -175,6 +181,24 @@ static int str_lockmem_cb(void fio_unused *data, unsigned long *val) return 0; } +static int str_rwmix_read_cb(void *data, unsigned int *val) +{ + struct thread_data *td = data; + + td->o.rwmix[DDIR_READ] = *val; + td->o.rwmix[DDIR_WRITE] = 100 - *val; + return 0; +} + +static int str_rwmix_write_cb(void *data, unsigned int *val) +{ + struct thread_data *td = data; + + td->o.rwmix[DDIR_WRITE] = *val; + td->o.rwmix[DDIR_READ] = 100 - *val; + return 0; +} + #ifdef FIO_HAVE_IOPRIO static int str_prioclass_cb(void *data, unsigned int *val) { @@ -267,6 +291,45 @@ static int str_fst_cb(void *data, const char *str) return 0; } +static int check_dir(struct thread_data *td, char *fname) +{ + char file[PATH_MAX], *dir; + int elen = 0; + + if (td->o.directory) { + strcpy(file, td->o.directory); + strcat(file, "/"); + elen = strlen(file); + } + + sprintf(file + elen, "%s", fname); + dir = dirname(file); + +#if 0 + { + struct stat sb; + /* + * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded + * yet, so we can't do this check right here... + */ + if (lstat(dir, &sb) < 0) { + int ret = errno; + + log_err("fio: %s is not a directory\n", dir); + td_verror(td, ret, "lstat"); + return 1; + } + + if (!S_ISDIR(sb.st_mode)) { + log_err("fio: %s is not a directory\n", dir); + return 1; + } + } +#endif + + return 0; +} + static int str_filename_cb(void *data, const char *input) { struct thread_data *td = data; @@ -283,6 +346,10 @@ static int str_filename_cb(void *data, const char *input) while ((fname = strsep(&str, ":")) != NULL) { if (!strlen(fname)) break; + if (check_dir(td, fname)) { + free(p); + return 1; + } add_file(td, fname); td->o.nr_files++; } @@ -297,8 +364,10 @@ static int str_directory_cb(void *data, const char fio_unused *str) struct stat sb; if (lstat(td->o.directory, &sb) < 0) { + int ret = errno; + log_err("fio: %s is not a directory\n", td->o.directory); - td_verror(td, errno, "lstat"); + td_verror(td, ret, "lstat"); return 1; } if (!S_ISDIR(sb.st_mode)) { @@ -337,7 +406,7 @@ static int str_verify_pattern_cb(void *data, unsigned int *off) struct thread_data *td = data; unsigned int msb; - msb = fls(*off); + msb = __fls(*off); if (msb <= 8) td->o.verify_pattern_bytes = 1; else if (msb <= 16) @@ -351,6 +420,18 @@ static int str_verify_pattern_cb(void *data, unsigned int *off) return 0; } +static int str_lockfile_cb(void *data, const char *str) +{ + struct thread_data *td = data; + char *nr = get_opt_postfix(str); + + td->o.lockfile_batch = 1; + if (nr) + td->o.lockfile_batch = atoi(nr); + + return 0; +} + #define __stringify_1(x) #x #define __stringify(x) __stringify_1(x) @@ -384,6 +465,30 @@ static struct fio_option options[] = { .cb = str_filename_cb, .help = "File(s) to use for the workload", }, + { + .name = "lockfile", + .type = FIO_OPT_STR, + .cb = str_lockfile_cb, + .off1 = td_var_offset(file_lock_mode), + .help = "Lock file when doing IO to it", + .parent = "filename", + .def = "none", + .posval = { + { .ival = "none", + .oval = FILE_LOCK_NONE, + .help = "No file locking", + }, + { .ival = "exclusive", + .oval = FILE_LOCK_EXCLUSIVE, + .help = "Exclusive file lock", + }, + { + .ival = "readwrite", + .oval = FILE_LOCK_READWRITE, + .help = "Read vs write lock", + }, + }, + }, { .name = "opendir", .type = FIO_OPT_STR_STORE, @@ -451,6 +556,11 @@ static struct fio_option options[] = { { .ival = "posixaio", .help = "POSIX asynchronous IO", }, +#endif +#ifdef FIO_HAVE_SOLARISAIO + { .ival = "solarisaio", + .help = "Solaris native asynchronous IO", + }, #endif { .ival = "mmap", .help = "Memory mapped IO", @@ -599,6 +709,14 @@ static struct fio_option options[] = { .help = "Accept potential duplicate random blocks", .parent = "rw", }, + { + .name = "softrandommap", + .type = FIO_OPT_BOOL, + .off1 = td_var_offset(softrandommap), + .help = "Allow randommap to fail and continue witout", + .parent = "norandommap", + .def = "0", + }, { .name = "nrfiles", .type = FIO_OPT_INT, @@ -816,7 +934,7 @@ static struct fio_option options[] = { .type = FIO_OPT_STR_VAL_INT, .help = "Offset verify header location by N bytes", .def = "0", - .cb = str_verify_offset_cb, + .cb = str_verify_offset_cb, .parent = "verify", }, { @@ -890,7 +1008,7 @@ static struct fio_option options[] = { { .name = "rwmixread", .type = FIO_OPT_INT, - .off1 = td_var_offset(rwmix[DDIR_READ]), + .cb = str_rwmix_read_cb, .maxval = 100, .help = "Percentage of mixed workload that is reads", .def = "50", @@ -898,18 +1016,14 @@ static struct fio_option options[] = { { .name = "rwmixwrite", .type = FIO_OPT_INT, - .off1 = td_var_offset(rwmix[DDIR_WRITE]), + .cb = str_rwmix_write_cb, .maxval = 100, .help = "Percentage of mixed workload that is writes", .def = "50", }, { .name = "rwmixcycle", - .type = FIO_OPT_INT, - .off1 = td_var_offset(rwmixcycle), - .help = "Cycle period for mixed read/write workloads (msec)", - .def = "500", - .parent = "rwmixread", + .type = FIO_OPT_DEPRECATED, }, { .name = "nice", @@ -1014,7 +1128,8 @@ static struct fio_option options[] = { .name = "bwavgtime", .type = FIO_OPT_INT, .off1 = td_var_offset(bw_avg_time), - .help = "Time window over which to calculate bandwidth (msec)", + .help = "Time window over which to calculate bandwidth" + " (msec)", .def = "500", }, { @@ -1118,7 +1233,7 @@ static struct fio_option options[] = { }, { .name = "hugepage-size", - .type = FIO_OPT_STR_VAL, + .type = FIO_OPT_STR_VAL_INT, .off1 = td_var_offset(hugepage_size), .help = "When using hugepages, specify size of each page", .def = __stringify(FIO_HUGE_PAGE), @@ -1135,6 +1250,12 @@ static struct fio_option options[] = { .off1 = td_var_offset(zero_buffers), .help = "Init IO buffers to all zeroes", }, + { + .name = "refill_buffers", + .type = FIO_OPT_STR_SET, + .off1 = td_var_offset(refill_buffers), + .help = "Refill IO buffers on every IO submit", + }, #ifdef FIO_HAVE_DISK_UTIL { .name = "disk_util", @@ -1162,7 +1283,7 @@ void fio_options_dup_and_init(struct option *long_options) o = &options[0]; while (o->name) { - long_options[i].name = o->name; + long_options[i].name = (char *) o->name; long_options[i].val = FIO_GETOPT_JOB; if (o->type == FIO_OPT_STR_SET) long_options[i].has_arg = no_argument;