allow --client to work with shared filesystem
[fio.git] / options.h
1 #ifndef FIO_OPTION_H
2 #define FIO_OPTION_H
3
4 #define FIO_MAX_OPTS            512
5
6 #include <string.h>
7 #include "parse.h"
8 #include "flist.h"
9 #include "client.h"
10
11 #define td_var_offset(var)      ((size_t) &((struct thread_options *)0)->var)
12
13 int add_option(struct fio_option *);
14 void invalidate_profile_options(const char *);
15 extern char *exec_profile;
16
17 void add_opt_posval(const char *, const char *, const char *);
18 void del_opt_posval(const char *, const char *);
19 struct thread_data;
20 void fio_options_free(struct thread_data *);
21 char *get_name_idx(char *, int);
22 int set_name_idx(char *, char *, int);
23
24 extern char client_sockaddr_str[INET6_ADDRSTRLEN];  /* used with --client option */
25
26 extern struct fio_option fio_options[FIO_MAX_OPTS];
27
28 extern int __fio_option_is_set(struct thread_options *, unsigned int off);
29
30 #define fio_option_is_set(__td, name)                                   \
31 ({                                                                      \
32         const unsigned int off = td_var_offset(name);                   \
33         int __r = __fio_option_is_set((__td), off);                     \
34         if (__r == -1) {                                                \
35                 dprint(FD_PARSE, "option %s/%u not found in map\n",     \
36                                 __fio_stringify(name), off);            \
37                 __r = 0;                                                \
38         }                                                               \
39         __r;                                                            \
40 })
41
42 extern void fio_option_mark_set(struct thread_options *, struct fio_option *);
43
44 static 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
54 static 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
66 struct opt_group {
67         const char *name;
68         unsigned int mask;
69 };
70
71 enum opt_category {
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,
77         __FIO_OPT_C_PROFILE,
78         __FIO_OPT_C_ENGINE,
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),
86         FIO_OPT_C_PROFILE       = (1U << __FIO_OPT_C_PROFILE),
87         FIO_OPT_C_ENGINE        = (1U << __FIO_OPT_C_ENGINE),
88         FIO_OPT_C_INVALID       = (1U << __FIO_OPT_C_NR),
89 };
90
91 enum opt_category_group {
92         __FIO_OPT_G_RATE        = 0,
93         __FIO_OPT_G_ZONE,
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,
100         __FIO_OPT_G_DESC,
101         __FIO_OPT_G_FILENAME,
102         __FIO_OPT_G_IO_BASIC,
103         __FIO_OPT_G_CGROUP,
104         __FIO_OPT_G_RUNTIME,
105         __FIO_OPT_G_PROCESS,
106         __FIO_OPT_G_CRED,
107         __FIO_OPT_G_CLOCK,
108         __FIO_OPT_G_IO_TYPE,
109         __FIO_OPT_G_THINKTIME,
110         __FIO_OPT_G_RANDOM,
111         __FIO_OPT_G_IO_BUF,
112         __FIO_OPT_G_TIOBENCH,
113         __FIO_OPT_G_ERR,
114         __FIO_OPT_G_E4DEFRAG,
115         __FIO_OPT_G_NETIO,
116         __FIO_OPT_G_LIBAIO,
117         __FIO_OPT_G_ACT,
118         __FIO_OPT_G_LATPROF,
119         __FIO_OPT_G_RBD,
120         __FIO_OPT_G_GFAPI,
121         __FIO_OPT_G_MTD,
122         __FIO_OPT_G_NR,
123
124         FIO_OPT_G_RATE          = (1U << __FIO_OPT_G_RATE),
125         FIO_OPT_G_ZONE          = (1U << __FIO_OPT_G_ZONE),
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),
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),
135         FIO_OPT_G_CGROUP        = (1U << __FIO_OPT_G_CGROUP),
136         FIO_OPT_G_RUNTIME       = (1U << __FIO_OPT_G_RUNTIME),
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),
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),
144         FIO_OPT_G_TIOBENCH      = (1U << __FIO_OPT_G_TIOBENCH),
145         FIO_OPT_G_ERR           = (1U << __FIO_OPT_G_ERR),
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),
149         FIO_OPT_G_ACT           = (1U << __FIO_OPT_G_ACT),
150         FIO_OPT_G_LATPROF       = (1U << __FIO_OPT_G_LATPROF),
151         FIO_OPT_G_RBD           = (1U << __FIO_OPT_G_RBD),
152         FIO_OPT_G_GFAPI         = (1U << __FIO_OPT_G_GFAPI),
153         FIO_OPT_G_MTD           = (1U << __FIO_OPT_G_MTD),
154         FIO_OPT_G_INVALID       = (1U << __FIO_OPT_G_NR),
155 };
156
157 extern struct opt_group *opt_group_from_mask(unsigned int *mask);
158 extern struct opt_group *opt_group_cat_from_mask(unsigned int *mask);
159 extern struct fio_option *fio_option_find(const char *name);
160 extern unsigned int fio_get_kb_base(void *);
161
162 #endif