Merge branch 'fio-issue-450' of https://github.com/gvkovai/fio
[fio.git] / optgroup.c
CommitLineData
d220c761
JA
1#include <stdio.h>
2#include <inttypes.h>
3#include "optgroup.h"
4
5/*
6 * Option grouping
7 */
8static const struct opt_group fio_opt_groups[] = {
9 {
10 .name = "General",
11 .mask = FIO_OPT_C_GENERAL,
12 },
13 {
14 .name = "I/O",
15 .mask = FIO_OPT_C_IO,
16 },
17 {
18 .name = "File",
19 .mask = FIO_OPT_C_FILE,
20 },
21 {
22 .name = "Statistics",
23 .mask = FIO_OPT_C_STAT,
24 },
25 {
26 .name = "Logging",
27 .mask = FIO_OPT_C_LOG,
28 },
29 {
30 .name = "Profiles",
31 .mask = FIO_OPT_C_PROFILE,
32 },
9cf163b0
TK
33 {
34 .name = "I/O engines",
35 .mask = FIO_OPT_C_ENGINE,
36 },
d220c761
JA
37 {
38 .name = NULL,
39 },
40};
41
42static const struct opt_group fio_opt_cat_groups[] = {
d220c761
JA
43 {
44 .name = "Rate",
45 .mask = FIO_OPT_G_RATE,
46 },
47 {
48 .name = "Zone",
49 .mask = FIO_OPT_G_ZONE,
50 },
51 {
52 .name = "Read/write mix",
53 .mask = FIO_OPT_G_RWMIX,
54 },
55 {
56 .name = "Verify",
57 .mask = FIO_OPT_G_VERIFY,
58 },
59 {
60 .name = "Trim",
61 .mask = FIO_OPT_G_TRIM,
62 },
63 {
64 .name = "I/O Logging",
65 .mask = FIO_OPT_G_IOLOG,
66 },
67 {
68 .name = "I/O Depth",
69 .mask = FIO_OPT_G_IO_DEPTH,
70 },
71 {
72 .name = "I/O Flow",
73 .mask = FIO_OPT_G_IO_FLOW,
74 },
75 {
76 .name = "Description",
77 .mask = FIO_OPT_G_DESC,
78 },
79 {
80 .name = "Filename",
81 .mask = FIO_OPT_G_FILENAME,
82 },
83 {
84 .name = "General I/O",
85 .mask = FIO_OPT_G_IO_BASIC,
86 },
87 {
88 .name = "Cgroups",
89 .mask = FIO_OPT_G_CGROUP,
90 },
91 {
92 .name = "Runtime",
93 .mask = FIO_OPT_G_RUNTIME,
94 },
95 {
96 .name = "Process",
97 .mask = FIO_OPT_G_PROCESS,
98 },
99 {
100 .name = "Job credentials / priority",
101 .mask = FIO_OPT_G_CRED,
102 },
103 {
104 .name = "Clock settings",
105 .mask = FIO_OPT_G_CLOCK,
106 },
107 {
108 .name = "I/O Type",
109 .mask = FIO_OPT_G_IO_TYPE,
110 },
111 {
112 .name = "I/O Thinktime",
113 .mask = FIO_OPT_G_THINKTIME,
114 },
115 {
116 .name = "Randomizations",
117 .mask = FIO_OPT_G_RANDOM,
118 },
119 {
120 .name = "I/O buffers",
121 .mask = FIO_OPT_G_IO_BUF,
122 },
123 {
124 .name = "Tiobench profile",
125 .mask = FIO_OPT_G_TIOBENCH,
126 },
127 {
9cf163b0
TK
128 .name = "Error handling",
129 .mask = FIO_OPT_G_ERR,
130 },
131 {
132 .name = "Ext4 defrag I/O engine", /* e4defrag */
133 .mask = FIO_OPT_G_E4DEFRAG,
134 },
135 {
136 .name = "Network I/O engine", /* net */
137 .mask = FIO_OPT_G_NETIO,
138 },
139 {
140 .name = "RDMA I/O engine", /* rdma */
141 .mask = FIO_OPT_G_RDMA,
142 },
143 {
144 .name = "libaio I/O engine", /* libaio */
145 .mask = FIO_OPT_G_LIBAIO,
146 },
147 {
148 .name = "ACT Aerospike like benchmark profile",
149 .mask = FIO_OPT_G_ACT,
150 },
151 {
152 .name = "Latency profiling",
153 .mask = FIO_OPT_G_LATPROF,
154 },
155 {
156 .name = "RBD I/O engine", /* rbd */
157 .mask = FIO_OPT_G_RBD,
158 },
159 {
160 .name = "GlusterFS I/O engine", /* gfapi,gfapi_async */
161 .mask = FIO_OPT_G_GFAPI,
162 },
163 {
164 .name = "MTD I/O engine", /* mtd */
d220c761
JA
165 .mask = FIO_OPT_G_MTD,
166 },
9cf163b0
TK
167 {
168 .name = "libhdfs I/O engine", /* libhdfs */
169 .mask = FIO_OPT_G_HDFS,
170 },
d220c761
JA
171 {
172 .name = NULL,
9cf163b0 173 },
d220c761
JA
174};
175
176static const struct opt_group *group_from_mask(const struct opt_group *ogs,
177 uint64_t *mask,
178 uint64_t inv_mask)
179{
180 int i;
181
182 if (*mask == inv_mask || !*mask)
183 return NULL;
184
185 for (i = 0; ogs[i].name; i++) {
186 const struct opt_group *og = &ogs[i];
187
188 if (*mask & og->mask) {
189 *mask &= ~(og->mask);
190 return og;
191 }
192 }
193
194 return NULL;
195}
196
197const struct opt_group *opt_group_from_mask(uint64_t *mask)
198{
199 return group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
200}
201
202const struct opt_group *opt_group_cat_from_mask(uint64_t *mask)
203{
204 return group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
205}