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