X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=options.c;h=8a6a433833582552983ffadf4b2d9e596aa514d5;hp=055fbab7a14180a91062635a4176a9603b0fd8d2;hb=15ca150e8dbfd68aa5beb479fcb3f07447417a04;hpb=564ca97254984165e06d5fd4b1270bac95ca55fb diff --git a/options.c b/options.c index 055fbab7..8a6a4338 100644 --- a/options.c +++ b/options.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "fio.h" #include "parse.h" @@ -66,7 +67,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, "/"); @@ -251,7 +254,6 @@ static int str_cpus_allowed_cb(void *data, const char *input) free(p); td->o.cpumask_set = 1; - exit(0); return 0; } #endif @@ -268,6 +270,36 @@ 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; + struct stat sb; + int elen = 0; + + if (td->o.directory) { + strcpy(file, td->o.directory); + elen = strlen(file); + } + + sprintf(file + elen, "/%s", fname); + dir = dirname(file); + + 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; + } + + return 0; +} + static int str_filename_cb(void *data, const char *input) { struct thread_data *td = data; @@ -284,6 +316,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++; } @@ -298,8 +334,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)) { @@ -333,27 +371,12 @@ static int str_verify_offset_cb(void *data, unsigned int *off) return 0; } -static int str_verify_cb(void *data, const char *mem) +static int str_verify_pattern_cb(void *data, unsigned int *off) { struct thread_data *td = data; - unsigned int nr, msb; - char *pat; - - if (td->o.verify != VERIFY_PATTERN) - return 0; - - pat = get_opt_postfix(mem); - if (!pat) { - log_err("fio: missing pattern\n"); - return 1; - } + unsigned int msb; - if (strstr(pat, "0x") || strstr(pat, "0X")) - nr = strtol(pat, NULL, 16); - else - nr = strtol(pat, NULL, 16); - - msb = fls(nr); + msb = fls(*off); if (msb <= 8) td->o.verify_pattern_bytes = 1; else if (msb <= 16) @@ -363,7 +386,19 @@ static int str_verify_cb(void *data, const char *mem) else td->o.verify_pattern_bytes = 4; - td->o.verify_pattern = nr; + td->o.verify_pattern = *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; } @@ -400,6 +435,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, @@ -455,6 +514,9 @@ static struct fio_option options[] = { { .ival = "psync", .help = "Use pread/pwrite", }, + { .ival = "vsync", + .help = "Use readv/writev", + }, #ifdef FIO_HAVE_LIBAIO { .ival = "libaio", .help = "Linux native asynchronous IO", @@ -519,6 +581,8 @@ static struct fio_option options[] = { .off1 = td_var_offset(iodepth_batch), .help = "Number of IO to submit in one go", .parent = "iodepth", + .minval = 1, + .def = "1", }, { .name = "iodepth_low", @@ -534,6 +598,13 @@ static struct fio_option options[] = { .minval = 1, .help = "Total size of device or files", }, + { + .name = "fill_device", + .type = FIO_OPT_BOOL, + .off1 = td_var_offset(fill_device), + .help = "Write until an ENOSPC error occurs", + .def = "0", + }, { .name = "filesize", .type = FIO_OPT_STR_VAL, @@ -603,6 +674,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, @@ -745,7 +824,6 @@ static struct fio_option options[] = { .name = "verify", .type = FIO_OPT_STR, .off1 = td_var_offset(verify), - .cb = str_verify_cb, .help = "Verify data written", .def = "0", .posval = { @@ -785,10 +863,6 @@ static struct fio_option options[] = { .oval = VERIFY_META, .help = "Use io information", }, - { .ival = "pattern", - .oval = VERIFY_PATTERN, - .help = "Verify a specific buffer pattern", - }, { .ival = "null", .oval = VERIFY_NULL, @@ -825,7 +899,14 @@ 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", + }, + { + .name = "verify_pattern", + .type = FIO_OPT_INT, + .cb = str_verify_pattern_cb, + .help = "Fill pattern for IO buffers", .parent = "verify", }, { @@ -907,11 +988,7 @@ static struct fio_option options[] = { }, { .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", @@ -1016,7 +1093,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", }, { @@ -1120,7 +1198,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),