Merge branch 'multiclnt-sharedfs-try3' of git://github.com/bengland2/fio
[fio.git] / options.h
CommitLineData
9f988e2e
JA
1#ifndef FIO_OPTION_H
2#define FIO_OPTION_H
3
07b3232d
JA
4#define FIO_MAX_OPTS 512
5
f5b6bb85 6#include <string.h>
9f988e2e
JA
7#include "parse.h"
8#include "flist.h"
72a703da 9#include "client.h"
9f988e2e
JA
10
11#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
12
07b3232d
JA
13int add_option(struct fio_option *);
14void invalidate_profile_options(const char *);
15extern char *exec_profile;
9f988e2e 16
f5b6bb85
JA
17void add_opt_posval(const char *, const char *, const char *);
18void del_opt_posval(const char *, const char *);
7e356b2d
JA
19struct thread_data;
20void fio_options_free(struct thread_data *);
bcbfeefa
CE
21char *get_name_idx(char *, int);
22int set_name_idx(char *, char *, int);
f5b6bb85 23
72a703da
BE
24extern char client_sockaddr_str[INET6_ADDRSTRLEN]; /* used with --client option */
25
9af4a244
JA
26extern struct fio_option fio_options[FIO_MAX_OPTS];
27
a8523a6a
JA
28extern int __fio_option_is_set(struct thread_options *, unsigned int off);
29
2243dfc7
JA
30#define fio_option_is_set(__td, name) \
31({ \
2f2e6c23
JA
32 const unsigned int off = td_var_offset(name); \
33 int __r = __fio_option_is_set((__td), off); \
2243dfc7 34 if (__r == -1) { \
2f2e6c23
JA
35 dprint(FD_PARSE, "option %s/%u not found in map\n", \
36 __fio_stringify(name), off); \
2243dfc7
JA
37 __r = 0; \
38 } \
39 __r; \
40})
a8523a6a
JA
41
42extern void fio_option_mark_set(struct thread_options *, struct fio_option *);
43
f5b6bb85
JA
44static inline int o_match(struct fio_option *o, const char *opt)
45{
46 if (!strcmp(o->name, opt))
47 return 1;
48 else if (o->alias && !strcmp(o->alias, opt))
49 return 1;
50
51 return 0;
52}
53
54static inline struct fio_option *find_option(struct fio_option *options,
55 const char *opt)
56{
57 struct fio_option *o;
58
59 for (o = &options[0]; o->name; o++)
60 if (o_match(o, opt))
61 return o;
62
63 return NULL;
64}
65
9af4a244
JA
66struct opt_group {
67 const char *name;
68 unsigned int mask;
69};
70
71enum opt_category {
e8b0e958
JA
72 __FIO_OPT_C_GENERAL = 0,
73 __FIO_OPT_C_IO,
74 __FIO_OPT_C_FILE,
75 __FIO_OPT_C_STAT,
76 __FIO_OPT_C_LOG,
13fca827 77 __FIO_OPT_C_PROFILE,
e90a0adf 78 __FIO_OPT_C_ENGINE,
e8b0e958
JA
79 __FIO_OPT_C_NR,
80
81 FIO_OPT_C_GENERAL = (1U << __FIO_OPT_C_GENERAL),
82 FIO_OPT_C_IO = (1U << __FIO_OPT_C_IO),
83 FIO_OPT_C_FILE = (1U << __FIO_OPT_C_FILE),
84 FIO_OPT_C_STAT = (1U << __FIO_OPT_C_STAT),
85 FIO_OPT_C_LOG = (1U << __FIO_OPT_C_LOG),
13fca827 86 FIO_OPT_C_PROFILE = (1U << __FIO_OPT_C_PROFILE),
e90a0adf 87 FIO_OPT_C_ENGINE = (1U << __FIO_OPT_C_ENGINE),
e8b0e958
JA
88 FIO_OPT_C_INVALID = (1U << __FIO_OPT_C_NR),
89};
90
91enum opt_category_group {
92 __FIO_OPT_G_RATE = 0,
e231bbe6 93 __FIO_OPT_G_ZONE,
e8b0e958
JA
94 __FIO_OPT_G_RWMIX,
95 __FIO_OPT_G_VERIFY,
96 __FIO_OPT_G_TRIM,
97 __FIO_OPT_G_IOLOG,
98 __FIO_OPT_G_IO_DEPTH,
99 __FIO_OPT_G_IO_FLOW,
0626037e
JA
100 __FIO_OPT_G_DESC,
101 __FIO_OPT_G_FILENAME,
102 __FIO_OPT_G_IO_BASIC,
a1f6afec
JA
103 __FIO_OPT_G_CGROUP,
104 __FIO_OPT_G_RUNTIME,
10860056
JA
105 __FIO_OPT_G_PROCESS,
106 __FIO_OPT_G_CRED,
107 __FIO_OPT_G_CLOCK,
3ceb458f
JA
108 __FIO_OPT_G_IO_TYPE,
109 __FIO_OPT_G_THINKTIME,
110 __FIO_OPT_G_RANDOM,
111 __FIO_OPT_G_IO_BUF,
13fca827 112 __FIO_OPT_G_TIOBENCH,
bc3f552f 113 __FIO_OPT_G_ERR,
e90a0adf
JA
114 __FIO_OPT_G_E4DEFRAG,
115 __FIO_OPT_G_NETIO,
116 __FIO_OPT_G_LIBAIO,
d4afedfd 117 __FIO_OPT_G_ACT,
3e260a46 118 __FIO_OPT_G_LATPROF,
fc5c0345 119 __FIO_OPT_G_RBD,
6e7d7dfb 120 __FIO_OPT_G_GFAPI,
65fa28ca 121 __FIO_OPT_G_MTD,
e231bbe6 122 __FIO_OPT_G_NR,
9af4a244 123
e8b0e958 124 FIO_OPT_G_RATE = (1U << __FIO_OPT_G_RATE),
9af4a244 125 FIO_OPT_G_ZONE = (1U << __FIO_OPT_G_ZONE),
e8b0e958
JA
126 FIO_OPT_G_RWMIX = (1U << __FIO_OPT_G_RWMIX),
127 FIO_OPT_G_VERIFY = (1U << __FIO_OPT_G_VERIFY),
128 FIO_OPT_G_TRIM = (1U << __FIO_OPT_G_TRIM),
129 FIO_OPT_G_IOLOG = (1U << __FIO_OPT_G_IOLOG),
130 FIO_OPT_G_IO_DEPTH = (1U << __FIO_OPT_G_IO_DEPTH),
131 FIO_OPT_G_IO_FLOW = (1U << __FIO_OPT_G_IO_FLOW),
0626037e
JA
132 FIO_OPT_G_DESC = (1U << __FIO_OPT_G_DESC),
133 FIO_OPT_G_FILENAME = (1U << __FIO_OPT_G_FILENAME),
134 FIO_OPT_G_IO_BASIC = (1U << __FIO_OPT_G_IO_BASIC),
a1f6afec
JA
135 FIO_OPT_G_CGROUP = (1U << __FIO_OPT_G_CGROUP),
136 FIO_OPT_G_RUNTIME = (1U << __FIO_OPT_G_RUNTIME),
10860056
JA
137 FIO_OPT_G_PROCESS = (1U << __FIO_OPT_G_PROCESS),
138 FIO_OPT_G_CRED = (1U << __FIO_OPT_G_CRED),
139 FIO_OPT_G_CLOCK = (1U << __FIO_OPT_G_CLOCK),
3ceb458f
JA
140 FIO_OPT_G_IO_TYPE = (1U << __FIO_OPT_G_IO_TYPE),
141 FIO_OPT_G_THINKTIME = (1U << __FIO_OPT_G_THINKTIME),
142 FIO_OPT_G_RANDOM = (1U << __FIO_OPT_G_RANDOM),
143 FIO_OPT_G_IO_BUF = (1U << __FIO_OPT_G_IO_BUF),
13fca827 144 FIO_OPT_G_TIOBENCH = (1U << __FIO_OPT_G_TIOBENCH),
bc3f552f 145 FIO_OPT_G_ERR = (1U << __FIO_OPT_G_ERR),
e90a0adf
JA
146 FIO_OPT_G_E4DEFRAG = (1U << __FIO_OPT_G_E4DEFRAG),
147 FIO_OPT_G_NETIO = (1U << __FIO_OPT_G_NETIO),
148 FIO_OPT_G_LIBAIO = (1U << __FIO_OPT_G_LIBAIO),
d4afedfd 149 FIO_OPT_G_ACT = (1U << __FIO_OPT_G_ACT),
3e260a46 150 FIO_OPT_G_LATPROF = (1U << __FIO_OPT_G_LATPROF),
fc5c0345 151 FIO_OPT_G_RBD = (1U << __FIO_OPT_G_RBD),
6e7d7dfb 152 FIO_OPT_G_GFAPI = (1U << __FIO_OPT_G_GFAPI),
65fa28ca 153 FIO_OPT_G_MTD = (1U << __FIO_OPT_G_MTD),
9af4a244
JA
154 FIO_OPT_G_INVALID = (1U << __FIO_OPT_G_NR),
155};
156
157extern struct opt_group *opt_group_from_mask(unsigned int *mask);
e8b0e958 158extern struct opt_group *opt_group_cat_from_mask(unsigned int *mask);
c504ee55 159extern struct fio_option *fio_option_find(const char *name);
3c3ed070 160extern unsigned int fio_get_kb_base(void *);
9af4a244 161
9f988e2e 162#endif