18 #include "crc/crc32c.h"
21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
23 static char *get_opt_postfix(const char *str)
25 char *p = strstr(str, ":");
31 strip_blank_front(&p);
36 static int converthexchartoint(char a)
56 static int bs_cmp(const void *p1, const void *p2)
58 const struct bssplit *bsp1 = p1;
59 const struct bssplit *bsp2 = p2;
61 return bsp1->perc < bsp2->perc;
64 static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
66 struct bssplit *bssplit;
67 unsigned int i, perc, perc_missing;
68 unsigned int max_bs, min_bs;
72 td->o.bssplit_nr[ddir] = 4;
73 bssplit = malloc(4 * sizeof(struct bssplit));
78 while ((fname = strsep(&str, ":")) != NULL) {
85 * grow struct buffer, if needed
87 if (i == td->o.bssplit_nr[ddir]) {
88 td->o.bssplit_nr[ddir] <<= 1;
89 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
90 * sizeof(struct bssplit));
93 perc_str = strstr(fname, "/");
97 perc = atoi(perc_str);
105 if (str_to_decimal(fname, &val, 1, td)) {
106 log_err("fio: bssplit conversion failed\n");
117 bssplit[i].perc = perc;
121 td->o.bssplit_nr[ddir] = i;
124 * Now check if the percentages add up, and how much is missing
126 perc = perc_missing = 0;
127 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
128 struct bssplit *bsp = &bssplit[i];
130 if (bsp->perc == (unsigned char) -1)
137 log_err("fio: bssplit percentages add to more than 100%%\n");
142 * If values didn't have a percentage set, divide the remains between
146 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
147 struct bssplit *bsp = &bssplit[i];
149 if (bsp->perc == (unsigned char) -1)
150 bsp->perc = (100 - perc) / perc_missing;
154 td->o.min_bs[ddir] = min_bs;
155 td->o.max_bs[ddir] = max_bs;
158 * now sort based on percentages, for ease of lookup
160 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
161 td->o.bssplit[ddir] = bssplit;
166 static int str_bssplit_cb(void *data, const char *input)
168 struct thread_data *td = data;
169 char *str, *p, *odir;
172 p = str = strdup(input);
174 strip_blank_front(&str);
175 strip_blank_end(str);
177 odir = strchr(str, ',');
179 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
182 ret = bssplit_ddir(td, DDIR_READ, str);
189 ret = bssplit_ddir(td, DDIR_READ, str);
191 ret = bssplit_ddir(td, DDIR_WRITE, op);
200 static int str_rw_cb(void *data, const char *str)
202 struct thread_data *td = data;
203 char *nr = get_opt_postfix(str);
205 td->o.ddir_seq_nr = 1;
207 td->o.ddir_seq_nr = atoi(nr);
214 static int str_mem_cb(void *data, const char *mem)
216 struct thread_data *td = data;
218 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
219 td->mmapfile = get_opt_postfix(mem);
220 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
221 log_err("fio: mmaphuge:/path/to/file\n");
229 static int str_verify_cb(void *data, const char *mem)
231 struct thread_data *td = data;
233 if (td->o.verify != VERIFY_CRC32C_INTEL)
236 if (!crc32c_intel_works()) {
237 log_info("fio: System does not support hw accelerated crc32c. Falling back to sw crc32c.\n");
238 td->o.verify = VERIFY_CRC32C;
244 static int fio_clock_source_cb(void *data, const char *str)
246 struct thread_data *td = data;
248 fio_clock_source = td->o.clocksource;
253 static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
259 static int str_rwmix_read_cb(void *data, unsigned long long *val)
261 struct thread_data *td = data;
263 td->o.rwmix[DDIR_READ] = *val;
264 td->o.rwmix[DDIR_WRITE] = 100 - *val;
268 static int str_rwmix_write_cb(void *data, unsigned long long *val)
270 struct thread_data *td = data;
272 td->o.rwmix[DDIR_WRITE] = *val;
273 td->o.rwmix[DDIR_READ] = 100 - *val;
277 #ifdef FIO_HAVE_IOPRIO
278 static int str_prioclass_cb(void *data, unsigned long long *val)
280 struct thread_data *td = data;
284 * mask off old class bits, str_prio_cb() may have set a default class
286 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
289 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
294 static int str_prio_cb(void *data, unsigned long long *val)
296 struct thread_data *td = data;
301 * If no class is set, assume BE
303 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
304 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
311 static int str_exitall_cb(void)
313 exitall_on_terminate = 1;
317 #ifdef FIO_HAVE_CPU_AFFINITY
318 static int str_cpumask_cb(void *data, unsigned long long *val)
320 struct thread_data *td = data;
325 ret = fio_cpuset_init(&td->o.cpumask);
327 log_err("fio: cpuset_init failed\n");
328 td_verror(td, ret, "fio_cpuset_init");
332 max_cpu = cpus_online();
334 for (i = 0; i < sizeof(int) * 8; i++) {
335 if ((1 << i) & *val) {
337 log_err("fio: CPU %d too large (max=%ld)\n", i,
341 dprint(FD_PARSE, "set cpu allowed %d\n", i);
342 fio_cpu_set(&td->o.cpumask, i);
346 td->o.cpumask_set = 1;
350 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
357 ret = fio_cpuset_init(mask);
359 log_err("fio: cpuset_init failed\n");
360 td_verror(td, ret, "fio_cpuset_init");
364 p = str = strdup(input);
366 strip_blank_front(&str);
367 strip_blank_end(str);
369 max_cpu = cpus_online();
371 while ((cpu = strsep(&str, ",")) != NULL) {
380 while ((cpu2 = strsep(&str2, "-")) != NULL) {
390 while (icpu <= icpu2) {
391 if (icpu >= FIO_MAX_CPUS) {
392 log_err("fio: your OS only supports up to"
393 " %d CPUs\n", (int) FIO_MAX_CPUS);
397 if (icpu > max_cpu) {
398 log_err("fio: CPU %d too large (max=%ld)\n",
404 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
405 fio_cpu_set(mask, icpu);
414 td->o.cpumask_set = 1;
418 static int str_cpus_allowed_cb(void *data, const char *input)
420 struct thread_data *td = data;
423 ret = set_cpus_allowed(td, &td->o.cpumask, input);
425 td->o.cpumask_set = 1;
430 static int str_verify_cpus_allowed_cb(void *data, const char *input)
432 struct thread_data *td = data;
435 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
437 td->o.verify_cpumask_set = 1;
444 static int str_verify_trim_cb(void *data, unsigned long long *val)
446 struct thread_data *td = data;
448 td->o.trim_percentage = *val;
453 static int str_fst_cb(void *data, const char *str)
455 struct thread_data *td = data;
456 char *nr = get_opt_postfix(str);
458 td->file_service_nr = 1;
460 td->file_service_nr = atoi(nr);
467 #ifdef FIO_HAVE_SYNC_FILE_RANGE
468 static int str_sfr_cb(void *data, const char *str)
470 struct thread_data *td = data;
471 char *nr = get_opt_postfix(str);
473 td->sync_file_range_nr = 1;
475 td->sync_file_range_nr = atoi(nr);
483 static int check_dir(struct thread_data *td, char *fname)
486 char file[PATH_MAX], *dir;
489 if (td->o.directory) {
490 strcpy(file, td->o.directory);
495 sprintf(file + elen, "%s", fname);
501 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
502 * yet, so we can't do this check right here...
504 if (lstat(dir, &sb) < 0) {
507 log_err("fio: %s is not a directory\n", dir);
508 td_verror(td, ret, "lstat");
512 if (!S_ISDIR(sb.st_mode)) {
513 log_err("fio: %s is not a directory\n", dir);
523 * Return next file in the string. Files are separated with ':'. If the ':'
524 * is escaped with a '\', then that ':' is part of the filename and does not
525 * indicate a new file.
527 static char *get_next_file_name(char **ptr)
532 if (!str || !strlen(str))
538 * No colon, we are done
540 p = strchr(str, ':');
547 * We got a colon, but it's the first character. Skip and
555 if (*(p - 1) != '\\') {
561 memmove(p - 1, p, strlen(p) + 1);
568 static int str_filename_cb(void *data, const char *input)
570 struct thread_data *td = data;
571 char *fname, *str, *p;
573 p = str = strdup(input);
575 strip_blank_front(&str);
576 strip_blank_end(str);
578 if (!td->files_index)
581 while ((fname = get_next_file_name(&str)) != NULL) {
584 if (check_dir(td, fname)) {
596 static int str_directory_cb(void *data, const char fio_unused *str)
598 struct thread_data *td = data;
601 if (lstat(td->o.directory, &sb) < 0) {
604 log_err("fio: %s is not a directory\n", td->o.directory);
605 td_verror(td, ret, "lstat");
608 if (!S_ISDIR(sb.st_mode)) {
609 log_err("fio: %s is not a directory\n", td->o.directory);
616 static int str_opendir_cb(void *data, const char fio_unused *str)
618 struct thread_data *td = data;
620 if (!td->files_index)
623 return add_dir_files(td, td->o.opendir);
626 static int str_verify_offset_cb(void *data, unsigned long long *off)
628 struct thread_data *td = data;
630 if (*off && *off < sizeof(struct verify_header)) {
631 log_err("fio: verify_offset too small\n");
635 td->o.verify_offset = *off;
639 static int str_verify_pattern_cb(void *data, const char *input)
641 struct thread_data *td = data;
643 int i = 0, j = 0, len, k, base = 10;
646 loc1 = strstr(input, "0x");
647 loc2 = strstr(input, "0X");
650 off = strtol(input, NULL, base);
651 if (off != LONG_MAX || errno != ERANGE) {
653 td->o.verify_pattern[i] = off & 0xff;
662 j = loc1 - input + 2;
664 j = loc2 - input + 2;
667 if (len - j < MAX_PATTERN_SIZE * 2) {
669 off = converthexchartoint(input[k--]);
671 off += (converthexchartoint(input[k--])
673 td->o.verify_pattern[i++] = (char) off;
677 td->o.verify_pattern_bytes = i;
679 * VERIFY_META could already be set
681 if (td->o.verify == VERIFY_NONE)
682 td->o.verify = VERIFY_PATTERN;
686 static int str_lockfile_cb(void *data, const char *str)
688 struct thread_data *td = data;
689 char *nr = get_opt_postfix(str);
691 td->o.lockfile_batch = 1;
693 td->o.lockfile_batch = atoi(nr);
700 static int str_write_bw_log_cb(void *data, const char *str)
702 struct thread_data *td = data;
705 td->o.bw_log_file = strdup(str);
707 td->o.write_bw_log = 1;
711 static int str_write_lat_log_cb(void *data, const char *str)
713 struct thread_data *td = data;
716 td->o.lat_log_file = strdup(str);
718 td->o.write_lat_log = 1;
722 static int str_gtod_reduce_cb(void *data, int *il)
724 struct thread_data *td = data;
727 td->o.disable_lat = !!val;
728 td->o.disable_clat = !!val;
729 td->o.disable_slat = !!val;
730 td->o.disable_bw = !!val;
732 td->tv_cache_mask = 63;
737 static int str_gtod_cpu_cb(void *data, long long *il)
739 struct thread_data *td = data;
742 td->o.gtod_cpu = val;
743 td->o.gtod_offload = 1;
747 static int rw_verify(struct fio_option *o, void *data)
749 struct thread_data *td = data;
751 if (read_only && td_write(td)) {
752 log_err("fio: job <%s> has write bit set, but fio is in"
753 " read-only mode\n", td->o.name);
760 static int gtod_cpu_verify(struct fio_option *o, void *data)
762 #ifndef FIO_HAVE_CPU_AFFINITY
763 struct thread_data *td = data;
765 if (td->o.gtod_cpu) {
766 log_err("fio: platform must support CPU affinity for"
767 "gettimeofday() offloading\n");
775 static int kb_base_verify(struct fio_option *o, void *data)
777 struct thread_data *td = data;
779 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
780 log_err("fio: kb_base set to nonsensical value: %u\n",
788 #define __stringify_1(x) #x
789 #define __stringify(x) __stringify_1(x)
792 * Map of job/command line options
794 static struct fio_option options[FIO_MAX_OPTS] = {
796 .name = "description",
797 .type = FIO_OPT_STR_STORE,
798 .off1 = td_var_offset(description),
799 .help = "Text job description",
803 .type = FIO_OPT_STR_STORE,
804 .off1 = td_var_offset(name),
805 .help = "Name of this job",
809 .type = FIO_OPT_STR_STORE,
810 .off1 = td_var_offset(directory),
811 .cb = str_directory_cb,
812 .help = "Directory to store files in",
816 .type = FIO_OPT_STR_STORE,
817 .off1 = td_var_offset(filename),
818 .cb = str_filename_cb,
819 .prio = -1, /* must come after "directory" */
820 .help = "File(s) to use for the workload",
825 .off1 = td_var_offset(kb_base),
826 .verify = kb_base_verify,
829 .help = "How many bytes per KB for reporting (1000 or 1024)",
834 .cb = str_lockfile_cb,
835 .off1 = td_var_offset(file_lock_mode),
836 .help = "Lock file when doing IO to it",
837 .parent = "filename",
841 .oval = FILE_LOCK_NONE,
842 .help = "No file locking",
844 { .ival = "exclusive",
845 .oval = FILE_LOCK_EXCLUSIVE,
846 .help = "Exclusive file lock",
850 .oval = FILE_LOCK_READWRITE,
851 .help = "Read vs write lock",
857 .type = FIO_OPT_STR_STORE,
858 .off1 = td_var_offset(opendir),
859 .cb = str_opendir_cb,
860 .help = "Recursively add files from this directory and down",
864 .alias = "readwrite",
867 .off1 = td_var_offset(td_ddir),
868 .help = "IO direction",
873 .oval = TD_DDIR_READ,
874 .help = "Sequential read",
877 .oval = TD_DDIR_WRITE,
878 .help = "Sequential write",
880 { .ival = "randread",
881 .oval = TD_DDIR_RANDREAD,
882 .help = "Random read",
884 { .ival = "randwrite",
885 .oval = TD_DDIR_RANDWRITE,
886 .help = "Random write",
890 .help = "Sequential read and write mix",
893 .oval = TD_DDIR_RANDRW,
894 .help = "Random read and write mix"
899 .name = "rw_sequencer",
901 .off1 = td_var_offset(rw_seq),
902 .help = "IO offset generator modifier",
905 { .ival = "sequential",
907 .help = "Generate sequential offsets",
909 { .ival = "identical",
910 .oval = RW_SEQ_IDENT,
911 .help = "Generate identical offsets",
918 .type = FIO_OPT_STR_STORE,
919 .off1 = td_var_offset(ioengine),
920 .help = "IO engine to use",
921 .def = FIO_PREFERRED_ENGINE,
924 .help = "Use read/write",
927 .help = "Use pread/pwrite",
930 .help = "Use readv/writev",
932 #ifdef FIO_HAVE_LIBAIO
934 .help = "Linux native asynchronous IO",
937 #ifdef FIO_HAVE_POSIXAIO
938 { .ival = "posixaio",
939 .help = "POSIX asynchronous IO",
942 #ifdef FIO_HAVE_SOLARISAIO
943 { .ival = "solarisaio",
944 .help = "Solaris native asynchronous IO",
947 #ifdef FIO_HAVE_WINDOWSAIO
948 { .ival = "windowsaio",
949 .help = "Windows native asynchronous IO"
953 .help = "Memory mapped IO"
955 #ifdef FIO_HAVE_SPLICE
957 .help = "splice/vmsplice based IO",
959 { .ival = "netsplice",
960 .help = "splice/vmsplice to/from the network",
965 .help = "SCSI generic v3 IO",
969 .help = "Testing engine (no data transfer)",
972 .help = "Network IO",
974 #ifdef FIO_HAVE_SYSLET
975 { .ival = "syslet-rw",
976 .help = "syslet enabled async pread/pwrite IO",
980 .help = "CPU cycle burner engine",
982 #ifdef FIO_HAVE_GUASI
984 .help = "GUASI IO engine",
987 #ifdef FIO_HAVE_BINJECT
989 .help = "binject direct inject block engine",
992 { .ival = "external",
993 .help = "Load external engine (append name)",
1000 .off1 = td_var_offset(iodepth),
1001 .help = "Number of IO buffers to keep in flight",
1006 .name = "iodepth_batch",
1007 .alias = "iodepth_batch_submit",
1008 .type = FIO_OPT_INT,
1009 .off1 = td_var_offset(iodepth_batch),
1010 .help = "Number of IO buffers to submit in one go",
1011 .parent = "iodepth",
1016 .name = "iodepth_batch_complete",
1017 .type = FIO_OPT_INT,
1018 .off1 = td_var_offset(iodepth_batch_complete),
1019 .help = "Number of IO buffers to retrieve in one go",
1020 .parent = "iodepth",
1025 .name = "iodepth_low",
1026 .type = FIO_OPT_INT,
1027 .off1 = td_var_offset(iodepth_low),
1028 .help = "Low water mark for queuing depth",
1029 .parent = "iodepth",
1033 .type = FIO_OPT_STR_VAL,
1034 .off1 = td_var_offset(size),
1036 .help = "Total size of device or files",
1039 .name = "fill_device",
1041 .type = FIO_OPT_BOOL,
1042 .off1 = td_var_offset(fill_device),
1043 .help = "Write until an ENOSPC error occurs",
1048 .type = FIO_OPT_STR_VAL,
1049 .off1 = td_var_offset(file_size_low),
1050 .off2 = td_var_offset(file_size_high),
1052 .help = "Size of individual files",
1056 .alias = "fileoffset",
1057 .type = FIO_OPT_STR_VAL,
1058 .off1 = td_var_offset(start_offset),
1059 .help = "Start IO from this offset",
1064 .alias = "blocksize",
1065 .type = FIO_OPT_INT,
1066 .off1 = td_var_offset(bs[DDIR_READ]),
1067 .off2 = td_var_offset(bs[DDIR_WRITE]),
1069 .help = "Block size unit",
1075 .alias = "blockalign",
1076 .type = FIO_OPT_INT,
1077 .off1 = td_var_offset(ba[DDIR_READ]),
1078 .off2 = td_var_offset(ba[DDIR_WRITE]),
1080 .help = "IO block offset alignment",
1085 .alias = "blocksize_range",
1086 .type = FIO_OPT_RANGE,
1087 .off1 = td_var_offset(min_bs[DDIR_READ]),
1088 .off2 = td_var_offset(max_bs[DDIR_READ]),
1089 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1090 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1092 .help = "Set block size range (in more detail than bs)",
1097 .type = FIO_OPT_STR,
1098 .cb = str_bssplit_cb,
1099 .help = "Set a specific mix of block sizes",
1103 .name = "bs_unaligned",
1104 .alias = "blocksize_unaligned",
1105 .type = FIO_OPT_STR_SET,
1106 .off1 = td_var_offset(bs_unaligned),
1107 .help = "Don't sector align IO buffer sizes",
1111 .name = "randrepeat",
1112 .type = FIO_OPT_BOOL,
1113 .off1 = td_var_offset(rand_repeatable),
1114 .help = "Use repeatable random IO pattern",
1119 .name = "use_os_rand",
1120 .type = FIO_OPT_BOOL,
1121 .off1 = td_var_offset(use_os_rand),
1122 .help = "Set to use OS random generator",
1127 .name = "norandommap",
1128 .type = FIO_OPT_STR_SET,
1129 .off1 = td_var_offset(norandommap),
1130 .help = "Accept potential duplicate random blocks",
1134 .name = "softrandommap",
1135 .type = FIO_OPT_BOOL,
1136 .off1 = td_var_offset(softrandommap),
1137 .help = "Set norandommap if randommap allocation fails",
1138 .parent = "norandommap",
1143 .alias = "nr_files",
1144 .type = FIO_OPT_INT,
1145 .off1 = td_var_offset(nr_files),
1146 .help = "Split job workload between this number of files",
1150 .name = "openfiles",
1151 .type = FIO_OPT_INT,
1152 .off1 = td_var_offset(open_files),
1153 .help = "Number of files to keep open at the same time",
1156 .name = "file_service_type",
1157 .type = FIO_OPT_STR,
1159 .off1 = td_var_offset(file_service_type),
1160 .help = "How to select which file to service next",
1161 .def = "roundrobin",
1164 .oval = FIO_FSERVICE_RANDOM,
1165 .help = "Choose a file at random",
1167 { .ival = "roundrobin",
1168 .oval = FIO_FSERVICE_RR,
1169 .help = "Round robin select files",
1171 { .ival = "sequential",
1172 .oval = FIO_FSERVICE_SEQ,
1173 .help = "Finish one file before moving to the next",
1176 .parent = "nrfiles",
1178 #ifdef FIO_HAVE_FALLOCATE
1180 .name = "fallocate",
1181 .type = FIO_OPT_STR,
1182 .off1 = td_var_offset(fallocate_mode),
1183 .help = "Whether pre-allocation is performed when laying out files",
1187 .oval = FIO_FALLOCATE_NONE,
1188 .help = "Do not pre-allocate space",
1191 .oval = FIO_FALLOCATE_POSIX,
1192 .help = "Use posix_fallocate()",
1194 #ifdef FIO_HAVE_LINUX_FALLOCATE
1196 .oval = FIO_FALLOCATE_KEEP_SIZE,
1197 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1200 /* Compatibility with former boolean values */
1202 .oval = FIO_FALLOCATE_NONE,
1203 .help = "Alias for 'none'",
1206 .oval = FIO_FALLOCATE_POSIX,
1207 .help = "Alias for 'posix'",
1211 #endif /* FIO_HAVE_FALLOCATE */
1213 .name = "fadvise_hint",
1214 .type = FIO_OPT_BOOL,
1215 .off1 = td_var_offset(fadvise_hint),
1216 .help = "Use fadvise() to advise the kernel on IO pattern",
1221 .type = FIO_OPT_INT,
1222 .off1 = td_var_offset(fsync_blocks),
1223 .help = "Issue fsync for writes every given number of blocks",
1227 .name = "fdatasync",
1228 .type = FIO_OPT_INT,
1229 .off1 = td_var_offset(fdatasync_blocks),
1230 .help = "Issue fdatasync for writes every given number of blocks",
1234 .name = "write_barrier",
1235 .type = FIO_OPT_INT,
1236 .off1 = td_var_offset(barrier_blocks),
1237 .help = "Make every Nth write a barrier write",
1240 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1242 .name = "sync_file_range",
1244 { .ival = "wait_before",
1245 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1246 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1250 .oval = SYNC_FILE_RANGE_WRITE,
1251 .help = "SYNC_FILE_RANGE_WRITE",
1255 .ival = "wait_after",
1256 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1257 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1261 .type = FIO_OPT_STR_MULTI,
1263 .off1 = td_var_offset(sync_file_range),
1264 .help = "Use sync_file_range()",
1269 .type = FIO_OPT_BOOL,
1270 .off1 = td_var_offset(odirect),
1271 .help = "Use O_DIRECT IO (negates buffered)",
1276 .type = FIO_OPT_BOOL,
1277 .off1 = td_var_offset(odirect),
1279 .help = "Use buffered IO (negates direct)",
1283 .name = "overwrite",
1284 .type = FIO_OPT_BOOL,
1285 .off1 = td_var_offset(overwrite),
1286 .help = "When writing, set whether to overwrite current data",
1291 .type = FIO_OPT_INT,
1292 .off1 = td_var_offset(loops),
1293 .help = "Number of times to run the job",
1298 .type = FIO_OPT_INT,
1299 .off1 = td_var_offset(numjobs),
1300 .help = "Duplicate this job this many times",
1304 .name = "startdelay",
1305 .type = FIO_OPT_STR_VAL_TIME,
1306 .off1 = td_var_offset(start_delay),
1307 .help = "Only start job when this period has passed",
1313 .type = FIO_OPT_STR_VAL_TIME,
1314 .off1 = td_var_offset(timeout),
1315 .help = "Stop workload when this amount of time has passed",
1319 .name = "time_based",
1320 .type = FIO_OPT_STR_SET,
1321 .off1 = td_var_offset(time_based),
1322 .help = "Keep running until runtime/timeout is met",
1325 .name = "ramp_time",
1326 .type = FIO_OPT_STR_VAL_TIME,
1327 .off1 = td_var_offset(ramp_time),
1328 .help = "Ramp up time before measuring performance",
1331 .name = "clocksource",
1332 .type = FIO_OPT_STR,
1333 .cb = fio_clock_source_cb,
1334 .off1 = td_var_offset(clocksource),
1335 .help = "What type of timing source to use",
1337 { .ival = "gettimeofday",
1339 .help = "Use gettimeofday(2) for timing",
1341 { .ival = "clock_gettime",
1342 .oval = CS_CGETTIME,
1343 .help = "Use clock_gettime(2) for timing",
1345 #ifdef ARCH_HAVE_CPU_CLOCK
1347 .oval = CS_CPUCLOCK,
1348 .help = "Use CPU private clock",
1356 .type = FIO_OPT_STR,
1358 .off1 = td_var_offset(mem_type),
1359 .help = "Backing type for IO buffers",
1364 .help = "Use malloc(3) for IO buffers",
1368 .help = "Use shared memory segments for IO buffers",
1370 #ifdef FIO_HAVE_HUGETLB
1371 { .ival = "shmhuge",
1372 .oval = MEM_SHMHUGE,
1373 .help = "Like shm, but use huge pages",
1378 .help = "Use mmap(2) (file or anon) for IO buffers",
1380 #ifdef FIO_HAVE_HUGETLB
1381 { .ival = "mmaphuge",
1382 .oval = MEM_MMAPHUGE,
1383 .help = "Like mmap, but use huge pages",
1389 .name = "iomem_align",
1390 .alias = "mem_align",
1391 .type = FIO_OPT_INT,
1392 .off1 = td_var_offset(mem_align),
1394 .help = "IO memory buffer offset alignment",
1400 .type = FIO_OPT_STR,
1401 .off1 = td_var_offset(verify),
1402 .help = "Verify data written",
1403 .cb = str_verify_cb,
1407 .oval = VERIFY_NONE,
1408 .help = "Don't do IO verification",
1412 .help = "Use md5 checksums for verification",
1415 .oval = VERIFY_CRC64,
1416 .help = "Use crc64 checksums for verification",
1419 .oval = VERIFY_CRC32,
1420 .help = "Use crc32 checksums for verification",
1422 { .ival = "crc32c-intel",
1423 .oval = VERIFY_CRC32C_INTEL,
1424 .help = "Use hw crc32c checksums for verification",
1427 .oval = VERIFY_CRC32C,
1428 .help = "Use crc32c checksums for verification",
1431 .oval = VERIFY_CRC16,
1432 .help = "Use crc16 checksums for verification",
1435 .oval = VERIFY_CRC7,
1436 .help = "Use crc7 checksums for verification",
1439 .oval = VERIFY_SHA1,
1440 .help = "Use sha1 checksums for verification",
1443 .oval = VERIFY_SHA256,
1444 .help = "Use sha256 checksums for verification",
1447 .oval = VERIFY_SHA512,
1448 .help = "Use sha512 checksums for verification",
1451 .oval = VERIFY_META,
1452 .help = "Use io information",
1456 .oval = VERIFY_NULL,
1457 .help = "Pretend to verify",
1462 .name = "do_verify",
1463 .type = FIO_OPT_BOOL,
1464 .off1 = td_var_offset(do_verify),
1465 .help = "Run verification stage after write",
1470 .name = "verifysort",
1471 .type = FIO_OPT_BOOL,
1472 .off1 = td_var_offset(verifysort),
1473 .help = "Sort written verify blocks for read back",
1478 .name = "verify_interval",
1479 .type = FIO_OPT_INT,
1480 .off1 = td_var_offset(verify_interval),
1481 .minval = 2 * sizeof(struct verify_header),
1482 .help = "Store verify buffer header every N bytes",
1486 .name = "verify_offset",
1487 .type = FIO_OPT_INT,
1488 .help = "Offset verify header location by N bytes",
1490 .cb = str_verify_offset_cb,
1494 .name = "verify_pattern",
1495 .type = FIO_OPT_STR,
1496 .cb = str_verify_pattern_cb,
1497 .help = "Fill pattern for IO buffers",
1501 .name = "verify_fatal",
1502 .type = FIO_OPT_BOOL,
1503 .off1 = td_var_offset(verify_fatal),
1505 .help = "Exit on a single verify failure, don't continue",
1509 .name = "verify_dump",
1510 .type = FIO_OPT_BOOL,
1511 .off1 = td_var_offset(verify_dump),
1513 .help = "Dump contents of good and bad blocks on failure",
1517 .name = "verify_async",
1518 .type = FIO_OPT_INT,
1519 .off1 = td_var_offset(verify_async),
1521 .help = "Number of async verifier threads to use",
1525 .name = "verify_backlog",
1526 .type = FIO_OPT_STR_VAL,
1527 .off1 = td_var_offset(verify_backlog),
1528 .help = "Verify after this number of blocks are written",
1532 .name = "verify_backlog_batch",
1533 .type = FIO_OPT_INT,
1534 .off1 = td_var_offset(verify_batch),
1535 .help = "Verify this number of IO blocks",
1538 #ifdef FIO_HAVE_CPU_AFFINITY
1540 .name = "verify_async_cpus",
1541 .type = FIO_OPT_STR,
1542 .cb = str_verify_cpus_allowed_cb,
1543 .help = "Set CPUs allowed for async verify threads",
1544 .parent = "verify_async",
1547 #ifdef FIO_HAVE_TRIM
1549 .name = "trim_percentage",
1550 .type = FIO_OPT_INT,
1551 .cb = str_verify_trim_cb,
1553 .help = "Number of verify blocks to discard/trim",
1558 .name = "trim_verify_zero",
1559 .type = FIO_OPT_INT,
1560 .help = "Verify that trim/discarded blocks are returned as zeroes",
1561 .off1 = td_var_offset(trim_zero),
1562 .parent = "trim_percentage",
1566 .name = "trim_backlog",
1567 .type = FIO_OPT_STR_VAL,
1568 .off1 = td_var_offset(trim_backlog),
1569 .help = "Trim after this number of blocks are written",
1570 .parent = "trim_percentage",
1573 .name = "trim_backlog_batch",
1574 .type = FIO_OPT_INT,
1575 .off1 = td_var_offset(trim_batch),
1576 .help = "Trim this number of IO blocks",
1577 .parent = "trim_percentage",
1581 .name = "write_iolog",
1582 .type = FIO_OPT_STR_STORE,
1583 .off1 = td_var_offset(write_iolog_file),
1584 .help = "Store IO pattern to file",
1587 .name = "read_iolog",
1588 .type = FIO_OPT_STR_STORE,
1589 .off1 = td_var_offset(read_iolog_file),
1590 .help = "Playback IO pattern from file",
1593 .name = "replay_no_stall",
1594 .type = FIO_OPT_INT,
1595 .off1 = td_var_offset(no_stall),
1597 .parent = "read_iolog",
1598 .help = "Playback IO pattern file as fast as possible without stalls",
1601 .name = "replay_redirect",
1602 .type = FIO_OPT_STR_STORE,
1603 .off1 = td_var_offset(replay_redirect),
1604 .parent = "read_iolog",
1605 .help = "Replay all I/O onto this device, regardless of trace device",
1608 .name = "exec_prerun",
1609 .type = FIO_OPT_STR_STORE,
1610 .off1 = td_var_offset(exec_prerun),
1611 .help = "Execute this file prior to running job",
1614 .name = "exec_postrun",
1615 .type = FIO_OPT_STR_STORE,
1616 .off1 = td_var_offset(exec_postrun),
1617 .help = "Execute this file after running job",
1619 #ifdef FIO_HAVE_IOSCHED_SWITCH
1621 .name = "ioscheduler",
1622 .type = FIO_OPT_STR_STORE,
1623 .off1 = td_var_offset(ioscheduler),
1624 .help = "Use this IO scheduler on the backing device",
1629 .type = FIO_OPT_STR_VAL,
1630 .off1 = td_var_offset(zone_size),
1631 .help = "Give size of an IO zone",
1636 .type = FIO_OPT_STR_VAL,
1637 .off1 = td_var_offset(zone_skip),
1638 .help = "Space between IO zones",
1643 .type = FIO_OPT_STR_VAL,
1644 .cb = str_lockmem_cb,
1645 .help = "Lock down this amount of memory",
1649 .name = "rwmixread",
1650 .type = FIO_OPT_INT,
1651 .cb = str_rwmix_read_cb,
1653 .help = "Percentage of mixed workload that is reads",
1657 .name = "rwmixwrite",
1658 .type = FIO_OPT_INT,
1659 .cb = str_rwmix_write_cb,
1661 .help = "Percentage of mixed workload that is writes",
1665 .name = "rwmixcycle",
1666 .type = FIO_OPT_DEPRECATED,
1670 .type = FIO_OPT_INT,
1671 .off1 = td_var_offset(nice),
1672 .help = "Set job CPU nice value",
1677 #ifdef FIO_HAVE_IOPRIO
1680 .type = FIO_OPT_INT,
1682 .help = "Set job IO priority value",
1687 .name = "prioclass",
1688 .type = FIO_OPT_INT,
1689 .cb = str_prioclass_cb,
1690 .help = "Set job IO priority class",
1696 .name = "thinktime",
1697 .type = FIO_OPT_INT,
1698 .off1 = td_var_offset(thinktime),
1699 .help = "Idle time between IO buffers (usec)",
1703 .name = "thinktime_spin",
1704 .type = FIO_OPT_INT,
1705 .off1 = td_var_offset(thinktime_spin),
1706 .help = "Start think time by spinning this amount (usec)",
1708 .parent = "thinktime",
1711 .name = "thinktime_blocks",
1712 .type = FIO_OPT_INT,
1713 .off1 = td_var_offset(thinktime_blocks),
1714 .help = "IO buffer period between 'thinktime'",
1716 .parent = "thinktime",
1720 .type = FIO_OPT_INT,
1721 .off1 = td_var_offset(rate[0]),
1722 .off2 = td_var_offset(rate[1]),
1723 .help = "Set bandwidth rate",
1727 .type = FIO_OPT_INT,
1728 .off1 = td_var_offset(ratemin[0]),
1729 .off2 = td_var_offset(ratemin[1]),
1730 .help = "Job must meet this rate or it will be shutdown",
1734 .name = "rate_iops",
1735 .type = FIO_OPT_INT,
1736 .off1 = td_var_offset(rate_iops[0]),
1737 .off2 = td_var_offset(rate_iops[1]),
1738 .help = "Limit IO used to this number of IO operations/sec",
1741 .name = "rate_iops_min",
1742 .type = FIO_OPT_INT,
1743 .off1 = td_var_offset(rate_iops_min[0]),
1744 .off2 = td_var_offset(rate_iops_min[1]),
1745 .help = "Job must meet this rate or it will be shut down",
1746 .parent = "rate_iops",
1749 .name = "ratecycle",
1750 .type = FIO_OPT_INT,
1751 .off1 = td_var_offset(ratecycle),
1752 .help = "Window average for rate limits (msec)",
1757 .name = "invalidate",
1758 .type = FIO_OPT_BOOL,
1759 .off1 = td_var_offset(invalidate_cache),
1760 .help = "Invalidate buffer/page cache prior to running job",
1765 .type = FIO_OPT_BOOL,
1766 .off1 = td_var_offset(sync_io),
1767 .help = "Use O_SYNC for buffered writes",
1769 .parent = "buffered",
1772 .name = "bwavgtime",
1773 .type = FIO_OPT_INT,
1774 .off1 = td_var_offset(bw_avg_time),
1775 .help = "Time window over which to calculate bandwidth"
1780 .name = "create_serialize",
1781 .type = FIO_OPT_BOOL,
1782 .off1 = td_var_offset(create_serialize),
1783 .help = "Serialize creating of job files",
1787 .name = "create_fsync",
1788 .type = FIO_OPT_BOOL,
1789 .off1 = td_var_offset(create_fsync),
1790 .help = "fsync file after creation",
1794 .name = "create_on_open",
1795 .type = FIO_OPT_BOOL,
1796 .off1 = td_var_offset(create_on_open),
1797 .help = "Create files when they are opened for IO",
1802 .type = FIO_OPT_BOOL,
1803 .off1 = td_var_offset(pre_read),
1804 .help = "Pre-read files before starting official testing",
1809 .type = FIO_OPT_INT,
1810 .off1 = td_var_offset(cpuload),
1811 .help = "Use this percentage of CPU",
1814 .name = "cpuchunks",
1815 .type = FIO_OPT_INT,
1816 .off1 = td_var_offset(cpucycle),
1817 .help = "Length of the CPU burn cycles (usecs)",
1819 .parent = "cpuload",
1821 #ifdef FIO_HAVE_CPU_AFFINITY
1824 .type = FIO_OPT_INT,
1825 .cb = str_cpumask_cb,
1826 .help = "CPU affinity mask",
1829 .name = "cpus_allowed",
1830 .type = FIO_OPT_STR,
1831 .cb = str_cpus_allowed_cb,
1832 .help = "Set CPUs allowed",
1836 .name = "end_fsync",
1837 .type = FIO_OPT_BOOL,
1838 .off1 = td_var_offset(end_fsync),
1839 .help = "Include fsync at the end of job",
1843 .name = "fsync_on_close",
1844 .type = FIO_OPT_BOOL,
1845 .off1 = td_var_offset(fsync_on_close),
1846 .help = "fsync files on close",
1851 .type = FIO_OPT_BOOL,
1852 .off1 = td_var_offset(unlink),
1853 .help = "Unlink created files after job has completed",
1858 .type = FIO_OPT_STR_SET,
1859 .cb = str_exitall_cb,
1860 .help = "Terminate all jobs when one exits",
1863 .name = "stonewall",
1864 .type = FIO_OPT_STR_SET,
1865 .off1 = td_var_offset(stonewall),
1866 .help = "Insert a hard barrier between this job and previous",
1869 .name = "new_group",
1870 .type = FIO_OPT_STR_SET,
1871 .off1 = td_var_offset(new_group),
1872 .help = "Mark the start of a new group (for reporting)",
1876 .type = FIO_OPT_STR_SET,
1877 .off1 = td_var_offset(use_thread),
1878 .help = "Use threads instead of forks",
1881 .name = "write_bw_log",
1882 .type = FIO_OPT_STR,
1883 .off1 = td_var_offset(write_bw_log),
1884 .cb = str_write_bw_log_cb,
1885 .help = "Write log of bandwidth during run",
1888 .name = "write_lat_log",
1889 .type = FIO_OPT_STR,
1890 .off1 = td_var_offset(write_lat_log),
1891 .cb = str_write_lat_log_cb,
1892 .help = "Write log of latency during run",
1895 .name = "hugepage-size",
1896 .type = FIO_OPT_INT,
1897 .off1 = td_var_offset(hugepage_size),
1898 .help = "When using hugepages, specify size of each page",
1899 .def = __stringify(FIO_HUGE_PAGE),
1902 .name = "group_reporting",
1903 .type = FIO_OPT_STR_SET,
1904 .off1 = td_var_offset(group_reporting),
1905 .help = "Do reporting on a per-group basis",
1908 .name = "zero_buffers",
1909 .type = FIO_OPT_STR_SET,
1910 .off1 = td_var_offset(zero_buffers),
1911 .help = "Init IO buffers to all zeroes",
1914 .name = "refill_buffers",
1915 .type = FIO_OPT_STR_SET,
1916 .off1 = td_var_offset(refill_buffers),
1917 .help = "Refill IO buffers on every IO submit",
1919 #ifdef FIO_HAVE_DISK_UTIL
1921 .name = "disk_util",
1922 .type = FIO_OPT_BOOL,
1923 .off1 = td_var_offset(do_disk_util),
1924 .help = "Log disk utilization statistics",
1929 .name = "gtod_reduce",
1930 .type = FIO_OPT_BOOL,
1931 .help = "Greatly reduce number of gettimeofday() calls",
1932 .cb = str_gtod_reduce_cb,
1936 .name = "disable_lat",
1937 .type = FIO_OPT_BOOL,
1938 .off1 = td_var_offset(disable_lat),
1939 .help = "Disable latency numbers",
1940 .parent = "gtod_reduce",
1944 .name = "disable_clat",
1945 .type = FIO_OPT_BOOL,
1946 .off1 = td_var_offset(disable_clat),
1947 .help = "Disable completion latency numbers",
1948 .parent = "gtod_reduce",
1952 .name = "disable_slat",
1953 .type = FIO_OPT_BOOL,
1954 .off1 = td_var_offset(disable_slat),
1955 .help = "Disable submission latency numbers",
1956 .parent = "gtod_reduce",
1960 .name = "disable_bw_measurement",
1961 .type = FIO_OPT_BOOL,
1962 .off1 = td_var_offset(disable_bw),
1963 .help = "Disable bandwidth logging",
1964 .parent = "gtod_reduce",
1969 .type = FIO_OPT_INT,
1970 .cb = str_gtod_cpu_cb,
1971 .help = "Set up dedicated gettimeofday() thread on this CPU",
1972 .verify = gtod_cpu_verify,
1975 .name = "continue_on_error",
1976 .type = FIO_OPT_BOOL,
1977 .off1 = td_var_offset(continue_on_error),
1978 .help = "Continue on non-fatal errors during IO",
1983 .type = FIO_OPT_STR_STORE,
1984 .off1 = td_var_offset(profile),
1985 .help = "Select a specific builtin performance test",
1989 .type = FIO_OPT_STR_STORE,
1990 .off1 = td_var_offset(cgroup),
1991 .help = "Add job to cgroup of this name",
1994 .name = "cgroup_weight",
1995 .type = FIO_OPT_INT,
1996 .off1 = td_var_offset(cgroup_weight),
1997 .help = "Use given weight for cgroup",
2002 .name = "cgroup_nodelete",
2003 .type = FIO_OPT_BOOL,
2004 .off1 = td_var_offset(cgroup_nodelete),
2005 .help = "Do not delete cgroups after job completion",
2010 .type = FIO_OPT_INT,
2011 .off1 = td_var_offset(uid),
2012 .help = "Run job with this user ID",
2016 .type = FIO_OPT_INT,
2017 .off1 = td_var_offset(gid),
2018 .help = "Run job with this group ID",
2025 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2028 lopt->name = (char *) name;
2029 lopt->val = FIO_GETOPT_JOB;
2030 if (o->type == FIO_OPT_STR_SET)
2031 lopt->has_arg = no_argument;
2033 lopt->has_arg = required_argument;
2036 void fio_options_dup_and_init(struct option *long_options)
2038 struct fio_option *o;
2041 options_init(options);
2044 while (long_options[i].name)
2049 add_to_lopt(&long_options[i], o, o->name);
2052 add_to_lopt(&long_options[i], o, o->alias);
2057 assert(i < FIO_NR_OPTIONS);
2061 struct fio_keyword {
2067 static struct fio_keyword fio_keywords[] = {
2069 .word = "$pagesize",
2070 .desc = "Page size in the system",
2073 .word = "$mb_memory",
2074 .desc = "Megabytes of memory online",
2078 .desc = "Number of CPUs online in the system",
2085 void fio_keywords_init(void)
2087 unsigned long long mb_memory;
2091 sprintf(buf, "%lu", page_size);
2092 fio_keywords[0].replace = strdup(buf);
2094 mb_memory = os_phys_mem() / (1024 * 1024);
2095 sprintf(buf, "%llu", mb_memory);
2096 fio_keywords[1].replace = strdup(buf);
2099 sprintf(buf, "%lu", l);
2100 fio_keywords[2].replace = strdup(buf);
2105 static char *bc_calc(char *str)
2107 char *buf, *tmp, opt[80];
2112 * No math, just return string
2114 if (!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2119 * Split option from value, we only need to calculate the value
2121 tmp = strchr(str, '=');
2126 memset(opt, 0, sizeof(opt));
2127 strncpy(opt, str, tmp - str);
2131 sprintf(buf, "which %s > /dev/null", BC_APP);
2133 log_err("fio: bc is needed for performing math\n");
2138 sprintf(buf, "echo %s | %s", tmp, BC_APP);
2139 f = popen(buf, "r");
2145 ret = fread(buf, 1, 128, f);
2151 buf[ret - 1] = '\0';
2160 * Look for reserved variable names and replace them with real values
2162 static char *fio_keyword_replace(char *opt)
2167 for (i = 0; fio_keywords[i].word != NULL; i++) {
2168 struct fio_keyword *kw = &fio_keywords[i];
2170 while ((s = strstr(opt, kw->word)) != NULL) {
2171 char *new = malloc(strlen(opt) + 1);
2177 * Copy part of the string before the keyword and
2178 * sprintf() the replacement after it.
2180 memcpy(new, opt, olen);
2181 len = sprintf(new + olen, "%s", kw->replace);
2184 * If there's more in the original string, copy that
2187 opt += strlen(kw->word) + olen;
2189 memcpy(new + olen + len, opt, opt - o_org - 1);
2192 * replace opt and free the old opt
2198 * Check for potential math and invoke bc, if possible
2207 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2211 sort_options(opts, options, num_opts);
2213 for (ret = 0, i = 0; i < num_opts; i++) {
2214 opts[i] = fio_keyword_replace(opts[i]);
2215 ret |= parse_option(opts[i], options, td);
2221 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2223 return parse_cmd_option(opt, val, options, td);
2226 void fio_fill_default_options(struct thread_data *td)
2228 fill_default_options(td, options);
2231 int fio_show_option_help(const char *opt)
2233 return show_cmd_help(options, opt);
2236 static void __options_mem(struct thread_data *td, int alloc)
2238 struct thread_options *o = &td->o;
2239 struct fio_option *opt;
2243 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
2244 if (opt->type != FIO_OPT_STR_STORE)
2247 ptr = (void *) o + opt->off1;
2250 *ptr = strdup(*ptr);
2260 * dupe FIO_OPT_STR_STORE options
2262 void options_mem_dupe(struct thread_data *td)
2264 __options_mem(td, 1);
2267 void options_mem_free(struct thread_data fio_unused *td)
2270 __options_mem(td, 0);
2274 unsigned int fio_get_kb_base(void *data)
2276 struct thread_data *td = data;
2277 unsigned int kb_base = 0;
2280 kb_base = td->o.kb_base;
2287 int add_option(struct fio_option *o)
2289 struct fio_option *__o;
2298 memcpy(&options[opt_index], o, sizeof(*o));
2302 void invalidate_profile_options(const char *prof_name)
2304 struct fio_option *o;
2308 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2309 o->type = FIO_OPT_INVALID;
2310 o->prof_name = NULL;
2316 void add_opt_posval(const char *optname, const char *ival, const char *help)
2318 struct fio_option *o;
2321 o = find_option(options, optname);
2325 for (i = 0; i < PARSE_MAX_VP; i++) {
2326 if (o->posval[i].ival)
2329 o->posval[i].ival = ival;
2330 o->posval[i].help = help;
2335 void del_opt_posval(const char *optname, const char *ival)
2337 struct fio_option *o;
2340 o = find_option(options, optname);
2344 for (i = 0; i < PARSE_MAX_VP; i++) {
2345 if (!o->posval[i].ival)
2347 if (strcmp(o->posval[i].ival, ival))
2350 o->posval[i].ival = NULL;
2351 o->posval[i].help = NULL;