t/io_uring: fix bandwidth calculation
[fio.git] / cconv.c
CommitLineData
51167799
JA
1#include <string.h>
2
3d2d14bc 3#include "log.h"
2dc1cbb5
JA
4#include "thread_options.h"
5
6static void string_to_cpu(char **dst, const uint8_t *src)
7{
8 const char *__src = (const char *) src;
9
10 if (strlen(__src))
11 *dst = strdup(__src);
12}
13
3660ceae 14static void __string_to_net(uint8_t *dst, const char *src, size_t dst_size)
2dc1cbb5 15{
36833fb0
BVA
16 if (src)
17 snprintf((char *) dst, dst_size, "%s", src);
18 else
2dc1cbb5
JA
19 dst[0] = '\0';
20}
21
3660ceae
JA
22#define string_to_net(dst, src) __string_to_net((dst), (src), sizeof(dst))
23
10aa136b 24static void free_thread_options_to_cpu(struct thread_options *o)
eb0c74ae 25{
e0a04ac1
JA
26 int i;
27
eb0c74ae
JA
28 free(o->description);
29 free(o->name);
9cc8cb91 30 free(o->wait_for);
eb0c74ae
JA
31 free(o->directory);
32 free(o->filename);
33 free(o->filename_format);
34 free(o->opendir);
35 free(o->ioengine);
36 free(o->mmapfile);
37 free(o->read_iolog_file);
38 free(o->write_iolog_file);
b9921d1a 39 free(o->merge_blktrace_file);
eb0c74ae
JA
40 free(o->bw_log_file);
41 free(o->lat_log_file);
42 free(o->iops_log_file);
68cebb4b 43 free(o->hist_log_file);
eb0c74ae
JA
44 free(o->replay_redirect);
45 free(o->exec_prerun);
46 free(o->exec_postrun);
47 free(o->ioscheduler);
48 free(o->profile);
49 free(o->cgroup);
e0a04ac1
JA
50
51 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
52 free(o->bssplit[i]);
53 free(o->zone_split[i]);
54 }
eb0c74ae
JA
55}
56
2dc1cbb5
JA
57void convert_thread_options_to_cpu(struct thread_options *o,
58 struct thread_options_pack *top)
59{
60 int i, j;
61
3b577774
JA
62 for (i = 0; i < NR_OPTS_SZ; i++)
63 o->set_options[i] = le64_to_cpu(top->set_options[i]);
64
2dc1cbb5
JA
65 string_to_cpu(&o->description, top->description);
66 string_to_cpu(&o->name, top->name);
9cc8cb91 67 string_to_cpu(&o->wait_for, top->wait_for);
2dc1cbb5
JA
68 string_to_cpu(&o->directory, top->directory);
69 string_to_cpu(&o->filename, top->filename);
22f80458 70 string_to_cpu(&o->filename_format, top->filename_format);
2dc1cbb5
JA
71 string_to_cpu(&o->opendir, top->opendir);
72 string_to_cpu(&o->ioengine, top->ioengine);
83ea422a 73 string_to_cpu(&o->mmapfile, top->mmapfile);
2dc1cbb5
JA
74 string_to_cpu(&o->read_iolog_file, top->read_iolog_file);
75 string_to_cpu(&o->write_iolog_file, top->write_iolog_file);
b9921d1a 76 string_to_cpu(&o->merge_blktrace_file, top->merge_blktrace_file);
2dc1cbb5
JA
77 string_to_cpu(&o->bw_log_file, top->bw_log_file);
78 string_to_cpu(&o->lat_log_file, top->lat_log_file);
79 string_to_cpu(&o->iops_log_file, top->iops_log_file);
68cebb4b 80 string_to_cpu(&o->hist_log_file, top->hist_log_file);
2dc1cbb5
JA
81 string_to_cpu(&o->replay_redirect, top->replay_redirect);
82 string_to_cpu(&o->exec_prerun, top->exec_prerun);
83 string_to_cpu(&o->exec_postrun, top->exec_postrun);
84 string_to_cpu(&o->ioscheduler, top->ioscheduler);
85 string_to_cpu(&o->profile, top->profile);
86 string_to_cpu(&o->cgroup, top->cgroup);
87
2378826d 88 o->allow_create = le32_to_cpu(top->allow_create);
8e093781 89 o->allow_mounted_write = le32_to_cpu(top->allow_mounted_write);
2dc1cbb5
JA
90 o->td_ddir = le32_to_cpu(top->td_ddir);
91 o->rw_seq = le32_to_cpu(top->rw_seq);
92 o->kb_base = le32_to_cpu(top->kb_base);
a199930c 93 o->unit_base = le32_to_cpu(top->unit_base);
2dc1cbb5
JA
94 o->ddir_seq_nr = le32_to_cpu(top->ddir_seq_nr);
95 o->ddir_seq_add = le64_to_cpu(top->ddir_seq_add);
96 o->iodepth = le32_to_cpu(top->iodepth);
97 o->iodepth_low = le32_to_cpu(top->iodepth_low);
98 o->iodepth_batch = le32_to_cpu(top->iodepth_batch);
82407585
RP
99 o->iodepth_batch_complete_min = le32_to_cpu(top->iodepth_batch_complete_min);
100 o->iodepth_batch_complete_max = le32_to_cpu(top->iodepth_batch_complete_max);
997b5680 101 o->serialize_overlap = le32_to_cpu(top->serialize_overlap);
2dc1cbb5 102 o->size = le64_to_cpu(top->size);
5be9bf09 103 o->io_size = le64_to_cpu(top->io_size);
2dc1cbb5 104 o->size_percent = le32_to_cpu(top->size_percent);
8b38f401 105 o->io_size_percent = le32_to_cpu(top->io_size_percent);
2dc1cbb5 106 o->fill_device = le32_to_cpu(top->fill_device);
bedc9dc2 107 o->file_append = le32_to_cpu(top->file_append);
2dc1cbb5
JA
108 o->file_size_low = le64_to_cpu(top->file_size_low);
109 o->file_size_high = le64_to_cpu(top->file_size_high);
110 o->start_offset = le64_to_cpu(top->start_offset);
83c8b093 111 o->start_offset_align = le64_to_cpu(top->start_offset_align);
89978a6b 112 o->start_offset_percent = le32_to_cpu(top->start_offset_percent);
2dc1cbb5 113
b999b3c7 114 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
5fff9543
JF
115 o->bs[i] = le64_to_cpu(top->bs[i]);
116 o->ba[i] = le64_to_cpu(top->ba[i]);
117 o->min_bs[i] = le64_to_cpu(top->min_bs[i]);
118 o->max_bs[i] = le64_to_cpu(top->max_bs[i]);
2dc1cbb5
JA
119 o->bssplit_nr[i] = le32_to_cpu(top->bssplit_nr[i]);
120
121 if (o->bssplit_nr[i]) {
122 o->bssplit[i] = malloc(o->bssplit_nr[i] * sizeof(struct bssplit));
123 for (j = 0; j < o->bssplit_nr[i]; j++) {
5fff9543 124 o->bssplit[i][j].bs = le64_to_cpu(top->bssplit[i][j].bs);
2dc1cbb5
JA
125 o->bssplit[i][j].perc = le32_to_cpu(top->bssplit[i][j].perc);
126 }
127 }
128
e0a04ac1
JA
129 o->zone_split_nr[i] = le32_to_cpu(top->zone_split_nr[i]);
130
131 if (o->zone_split_nr[i]) {
132 o->zone_split[i] = malloc(o->zone_split_nr[i] * sizeof(struct zone_split));
133 for (j = 0; j < o->zone_split_nr[i]; j++) {
134 o->zone_split[i][j].access_perc = top->zone_split[i][j].access_perc;
135 o->zone_split[i][j].size_perc = top->zone_split[i][j].size_perc;
136 }
137 }
138
2dc1cbb5 139 o->rwmix[i] = le32_to_cpu(top->rwmix[i]);
90eff1c9
SW
140 o->rate[i] = le64_to_cpu(top->rate[i]);
141 o->ratemin[i] = le64_to_cpu(top->ratemin[i]);
2dc1cbb5
JA
142 o->rate_iops[i] = le32_to_cpu(top->rate_iops[i]);
143 o->rate_iops_min[i] = le32_to_cpu(top->rate_iops_min[i]);
d9472271
JA
144
145 o->perc_rand[i] = le32_to_cpu(top->perc_rand[i]);
f7cf63bf
VR
146
147 o->max_latency[i] = le64_to_cpu(top->max_latency[i]);
2dc1cbb5
JA
148 }
149
150 o->ratecycle = le32_to_cpu(top->ratecycle);
a9da8ab2 151 o->io_submit_mode = le32_to_cpu(top->io_submit_mode);
20fdc81c 152 o->unique_filename = le32_to_cpu(top->unique_filename);
2dc1cbb5
JA
153 o->nr_files = le32_to_cpu(top->nr_files);
154 o->open_files = le32_to_cpu(top->open_files);
155 o->file_lock_mode = le32_to_cpu(top->file_lock_mode);
2dc1cbb5 156 o->odirect = le32_to_cpu(top->odirect);
d01612f3 157 o->oatomic = le32_to_cpu(top->oatomic);
2dc1cbb5
JA
158 o->invalidate_cache = le32_to_cpu(top->invalidate_cache);
159 o->create_serialize = le32_to_cpu(top->create_serialize);
160 o->create_fsync = le32_to_cpu(top->create_fsync);
161 o->create_on_open = le32_to_cpu(top->create_on_open);
fb390e24 162 o->create_only = le32_to_cpu(top->create_only);
2dc1cbb5
JA
163 o->end_fsync = le32_to_cpu(top->end_fsync);
164 o->pre_read = le32_to_cpu(top->pre_read);
165 o->sync_io = le32_to_cpu(top->sync_io);
ae8e559e 166 o->write_hint = le32_to_cpu(top->write_hint);
2dc1cbb5
JA
167 o->verify = le32_to_cpu(top->verify);
168 o->do_verify = le32_to_cpu(top->do_verify);
836fcc0f 169 o->experimental_verify = le32_to_cpu(top->experimental_verify);
ca09be4b 170 o->verify_state = le32_to_cpu(top->verify_state);
2dc1cbb5
JA
171 o->verify_interval = le32_to_cpu(top->verify_interval);
172 o->verify_offset = le32_to_cpu(top->verify_offset);
173
174 memcpy(o->verify_pattern, top->verify_pattern, MAX_PATTERN_SIZE);
3c78a83f 175 memcpy(o->buffer_pattern, top->buffer_pattern, MAX_PATTERN_SIZE);
2dc1cbb5
JA
176
177 o->verify_pattern_bytes = le32_to_cpu(top->verify_pattern_bytes);
178 o->verify_fatal = le32_to_cpu(top->verify_fatal);
179 o->verify_dump = le32_to_cpu(top->verify_dump);
180 o->verify_async = le32_to_cpu(top->verify_async);
181 o->verify_batch = le32_to_cpu(top->verify_batch);
182 o->use_thread = le32_to_cpu(top->use_thread);
183 o->unlink = le32_to_cpu(top->unlink);
39c1c323 184 o->unlink_each_loop = le32_to_cpu(top->unlink_each_loop);
2dc1cbb5
JA
185 o->do_disk_util = le32_to_cpu(top->do_disk_util);
186 o->override_sync = le32_to_cpu(top->override_sync);
187 o->rand_repeatable = le32_to_cpu(top->rand_repeatable);
56e2a5fc 188 o->allrand_repeatable = le32_to_cpu(top->allrand_repeatable);
363cffa7 189 o->rand_seed = le64_to_cpu(top->rand_seed);
2dc1cbb5 190 o->log_avg_msec = le32_to_cpu(top->log_avg_msec);
1e613c9c
KC
191 o->log_hist_msec = le32_to_cpu(top->log_hist_msec);
192 o->log_hist_coarseness = le32_to_cpu(top->log_hist_coarseness);
e6989e10 193 o->log_max = le32_to_cpu(top->log_max);
d6c0b409 194 o->log_offset = le32_to_cpu(top->log_offset);
03ec570f 195 o->log_prio = le32_to_cpu(top->log_prio);
aee2ab67 196 o->log_gz = le32_to_cpu(top->log_gz);
b26317c9 197 o->log_gz_store = le32_to_cpu(top->log_gz_store);
3aea75b1 198 o->log_unix_epoch = le32_to_cpu(top->log_unix_epoch);
2dc1cbb5
JA
199 o->norandommap = le32_to_cpu(top->norandommap);
200 o->softrandommap = le32_to_cpu(top->softrandommap);
201 o->bs_unaligned = le32_to_cpu(top->bs_unaligned);
202 o->fsync_on_close = le32_to_cpu(top->fsync_on_close);
6aca9b3d 203 o->bs_is_seq_rand = le32_to_cpu(top->bs_is_seq_rand);
1e5324e7 204 o->random_distribution = le32_to_cpu(top->random_distribution);
f9cafb12 205 o->exitall_error = le32_to_cpu(top->exitall_error);
1e5324e7
JA
206 o->zipf_theta.u.f = fio_uint64_to_double(le64_to_cpu(top->zipf_theta.u.i));
207 o->pareto_h.u.f = fio_uint64_to_double(le64_to_cpu(top->pareto_h.u.i));
f88cd222 208 o->gauss_dev.u.f = fio_uint64_to_double(le64_to_cpu(top->gauss_dev.u.i));
a87c90fd 209 o->random_center.u.f = fio_uint64_to_double(le64_to_cpu(top->random_center.u.i));
49758e11 210 o->random_generator = le32_to_cpu(top->random_generator);
2dc1cbb5 211 o->hugepage_size = le32_to_cpu(top->hugepage_size);
5fff9543 212 o->rw_min_bs = le64_to_cpu(top->rw_min_bs);
2dc1cbb5
JA
213 o->thinktime = le32_to_cpu(top->thinktime);
214 o->thinktime_spin = le32_to_cpu(top->thinktime_spin);
215 o->thinktime_blocks = le32_to_cpu(top->thinktime_blocks);
33f42c20 216 o->thinktime_blocks_type = le32_to_cpu(top->thinktime_blocks_type);
f7942acd 217 o->thinktime_iotime = le32_to_cpu(top->thinktime_iotime);
2dc1cbb5
JA
218 o->fsync_blocks = le32_to_cpu(top->fsync_blocks);
219 o->fdatasync_blocks = le32_to_cpu(top->fdatasync_blocks);
220 o->barrier_blocks = le32_to_cpu(top->barrier_blocks);
221
222 o->verify_backlog = le64_to_cpu(top->verify_backlog);
223 o->start_delay = le64_to_cpu(top->start_delay);
23ed19b0 224 o->start_delay_high = le64_to_cpu(top->start_delay_high);
2dc1cbb5
JA
225 o->timeout = le64_to_cpu(top->timeout);
226 o->ramp_time = le64_to_cpu(top->ramp_time);
72863286
JA
227 o->ss_dur = le64_to_cpu(top->ss_dur);
228 o->ss_ramp_time = le64_to_cpu(top->ss_ramp_time);
2c5d94bc 229 o->ss_state = le32_to_cpu(top->ss_state);
72863286 230 o->ss_limit.u.f = fio_uint64_to_double(le64_to_cpu(top->ss_limit.u.i));
2dc1cbb5
JA
231 o->zone_range = le64_to_cpu(top->zone_range);
232 o->zone_size = le64_to_cpu(top->zone_size);
b8dd9750 233 o->zone_capacity = le64_to_cpu(top->zone_capacity);
2dc1cbb5 234 o->zone_skip = le64_to_cpu(top->zone_skip);
7b865a2f 235 o->zone_mode = le32_to_cpu(top->zone_mode);
6df25f78 236 o->max_open_zones = __le32_to_cpu(top->max_open_zones);
575686bb 237 o->ignore_zone_limits = le32_to_cpu(top->ignore_zone_limits);
ae278f9a 238 o->lockmem = le64_to_cpu(top->lockmem);
0b288ba1 239 o->offset_increment_percent = le32_to_cpu(top->offset_increment_percent);
6a4cf74f 240 o->offset_increment = le64_to_cpu(top->offset_increment);
ddf24e42 241 o->number_ios = le64_to_cpu(top->number_ios);
2dc1cbb5
JA
242
243 o->overwrite = le32_to_cpu(top->overwrite);
244 o->bw_avg_time = le32_to_cpu(top->bw_avg_time);
245 o->iops_avg_time = le32_to_cpu(top->iops_avg_time);
246 o->loops = le32_to_cpu(top->loops);
247 o->mem_type = le32_to_cpu(top->mem_type);
248 o->mem_align = le32_to_cpu(top->mem_align);
fd56c235
AW
249 o->exit_what = le32_to_cpu(top->exit_what);
250 o->stonewall = le32_to_cpu(top->stonewall);
2dc1cbb5
JA
251 o->new_group = le32_to_cpu(top->new_group);
252 o->numjobs = le32_to_cpu(top->numjobs);
c2acfbac 253 o->cpus_allowed_policy = le32_to_cpu(top->cpus_allowed_policy);
6599ce5a 254 o->gpu_dev_id = le32_to_cpu(top->gpu_dev_id);
2dc1cbb5
JA
255 o->iolog = le32_to_cpu(top->iolog);
256 o->rwmixcycle = le32_to_cpu(top->rwmixcycle);
257 o->nice = le32_to_cpu(top->nice);
28727df7
JA
258 o->ioprio = le32_to_cpu(top->ioprio);
259 o->ioprio_class = le32_to_cpu(top->ioprio_class);
2dc1cbb5
JA
260 o->file_service_type = le32_to_cpu(top->file_service_type);
261 o->group_reporting = le32_to_cpu(top->group_reporting);
8243be59 262 o->stats = le32_to_cpu(top->stats);
2dc1cbb5
JA
263 o->fadvise_hint = le32_to_cpu(top->fadvise_hint);
264 o->fallocate_mode = le32_to_cpu(top->fallocate_mode);
265 o->zero_buffers = le32_to_cpu(top->zero_buffers);
266 o->refill_buffers = le32_to_cpu(top->refill_buffers);
267 o->scramble_buffers = le32_to_cpu(top->scramble_buffers);
3c78a83f 268 o->buffer_pattern_bytes = le32_to_cpu(top->buffer_pattern_bytes);
2dc1cbb5
JA
269 o->time_based = le32_to_cpu(top->time_based);
270 o->disable_lat = le32_to_cpu(top->disable_lat);
271 o->disable_clat = le32_to_cpu(top->disable_clat);
272 o->disable_slat = le32_to_cpu(top->disable_slat);
273 o->disable_bw = le32_to_cpu(top->disable_bw);
95820b6e 274 o->unified_rw_rep = le32_to_cpu(top->unified_rw_rep);
2dc1cbb5
JA
275 o->gtod_reduce = le32_to_cpu(top->gtod_reduce);
276 o->gtod_cpu = le32_to_cpu(top->gtod_cpu);
2dc1cbb5
JA
277 o->clocksource = le32_to_cpu(top->clocksource);
278 o->no_stall = le32_to_cpu(top->no_stall);
279 o->trim_percentage = le32_to_cpu(top->trim_percentage);
280 o->trim_batch = le32_to_cpu(top->trim_batch);
281 o->trim_zero = le32_to_cpu(top->trim_zero);
282 o->clat_percentiles = le32_to_cpu(top->clat_percentiles);
b599759b 283 o->lat_percentiles = le32_to_cpu(top->lat_percentiles);
56440e63 284 o->slat_percentiles = le32_to_cpu(top->slat_percentiles);
9db01ef9 285 o->percentile_precision = le32_to_cpu(top->percentile_precision);
e883cb35 286 o->sig_figs = le32_to_cpu(top->sig_figs);
2dc1cbb5
JA
287 o->continue_on_error = le32_to_cpu(top->continue_on_error);
288 o->cgroup_weight = le32_to_cpu(top->cgroup_weight);
289 o->cgroup_nodelete = le32_to_cpu(top->cgroup_nodelete);
290 o->uid = le32_to_cpu(top->uid);
291 o->gid = le32_to_cpu(top->gid);
292 o->flow_id = __le32_to_cpu(top->flow_id);
20c7a244 293 o->flow = le32_to_cpu(top->flow);
2dc1cbb5
JA
294 o->flow_sleep = le32_to_cpu(top->flow_sleep);
295 o->sync_file_range = le32_to_cpu(top->sync_file_range);
3e260a46
JA
296 o->latency_target = le64_to_cpu(top->latency_target);
297 o->latency_window = le64_to_cpu(top->latency_window);
298 o->latency_percentile.u.f = fio_uint64_to_double(le64_to_cpu(top->latency_percentile.u.i));
e1bcd541 299 o->latency_run = le32_to_cpu(top->latency_run);
e476994e
JA
300 o->compress_percentage = le32_to_cpu(top->compress_percentage);
301 o->compress_chunk = le32_to_cpu(top->compress_chunk);
5c94b008 302 o->dedupe_percentage = le32_to_cpu(top->dedupe_percentage);
0d71aa98
BD
303 o->dedupe_mode = le32_to_cpu(top->dedupe_mode);
304 o->dedupe_working_set_percentage = le32_to_cpu(top->dedupe_working_set_percentage);
d77d8152 305 o->block_error_hist = le32_to_cpu(top->block_error_hist);
0c63576e
JA
306 o->replay_align = le32_to_cpu(top->replay_align);
307 o->replay_scale = le32_to_cpu(top->replay_scale);
dd39e2d4 308 o->replay_time_scale = le32_to_cpu(top->replay_time_scale);
d7235efb 309 o->replay_skip = le32_to_cpu(top->replay_skip);
3a5db920 310 o->per_job_logs = le32_to_cpu(top->per_job_logs);
dded427c
OS
311 o->write_bw_log = le32_to_cpu(top->write_bw_log);
312 o->write_lat_log = le32_to_cpu(top->write_lat_log);
313 o->write_iops_log = le32_to_cpu(top->write_iops_log);
314 o->write_hist_log = le32_to_cpu(top->write_hist_log);
2dc1cbb5
JA
315
316 o->trim_backlog = le64_to_cpu(top->trim_backlog);
6de65959 317 o->rate_process = le32_to_cpu(top->rate_process);
1a9bf814 318 o->rate_ign_think = le32_to_cpu(top->rate_ign_think);
2dc1cbb5
JA
319
320 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
321 o->percentile_list[i].u.f = fio_uint64_to_double(le64_to_cpu(top->percentile_list[i].u.i));
87a48ada
DZ
322
323 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
324 o->merge_blktrace_scalars[i].u.f = fio_uint64_to_double(le64_to_cpu(top->merge_blktrace_scalars[i].u.i));
55bfd8c8
DZ
325
326 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
327 o->merge_blktrace_iters[i].u.f = fio_uint64_to_double(le64_to_cpu(top->merge_blktrace_iters[i].u.i));
2dc1cbb5 328#if 0
3c3ed070
JA
329 uint8_t cpumask[FIO_TOP_STR_MAX];
330 uint8_t verify_cpumask[FIO_TOP_STR_MAX];
c08f9fe2 331 uint8_t log_gz_cpumask[FIO_TOP_STR_MAX];
2dc1cbb5
JA
332#endif
333}
334
335void convert_thread_options_to_net(struct thread_options_pack *top,
336 struct thread_options *o)
337{
338 int i, j;
339
3b577774
JA
340 for (i = 0; i < NR_OPTS_SZ; i++)
341 top->set_options[i] = cpu_to_le64(o->set_options[i]);
342
2dc1cbb5
JA
343 string_to_net(top->description, o->description);
344 string_to_net(top->name, o->name);
9cc8cb91 345 string_to_net(top->wait_for, o->wait_for);
2dc1cbb5
JA
346 string_to_net(top->directory, o->directory);
347 string_to_net(top->filename, o->filename);
22f80458 348 string_to_net(top->filename_format, o->filename_format);
2dc1cbb5
JA
349 string_to_net(top->opendir, o->opendir);
350 string_to_net(top->ioengine, o->ioengine);
83ea422a 351 string_to_net(top->mmapfile, o->mmapfile);
2dc1cbb5
JA
352 string_to_net(top->read_iolog_file, o->read_iolog_file);
353 string_to_net(top->write_iolog_file, o->write_iolog_file);
b9921d1a 354 string_to_net(top->merge_blktrace_file, o->merge_blktrace_file);
2dc1cbb5
JA
355 string_to_net(top->bw_log_file, o->bw_log_file);
356 string_to_net(top->lat_log_file, o->lat_log_file);
357 string_to_net(top->iops_log_file, o->iops_log_file);
68cebb4b 358 string_to_net(top->hist_log_file, o->hist_log_file);
2dc1cbb5
JA
359 string_to_net(top->replay_redirect, o->replay_redirect);
360 string_to_net(top->exec_prerun, o->exec_prerun);
361 string_to_net(top->exec_postrun, o->exec_postrun);
362 string_to_net(top->ioscheduler, o->ioscheduler);
363 string_to_net(top->profile, o->profile);
364 string_to_net(top->cgroup, o->cgroup);
365
2378826d 366 top->allow_create = cpu_to_le32(o->allow_create);
8e093781 367 top->allow_mounted_write = cpu_to_le32(o->allow_mounted_write);
2dc1cbb5
JA
368 top->td_ddir = cpu_to_le32(o->td_ddir);
369 top->rw_seq = cpu_to_le32(o->rw_seq);
370 top->kb_base = cpu_to_le32(o->kb_base);
a199930c 371 top->unit_base = cpu_to_le32(o->unit_base);
2dc1cbb5
JA
372 top->ddir_seq_nr = cpu_to_le32(o->ddir_seq_nr);
373 top->iodepth = cpu_to_le32(o->iodepth);
374 top->iodepth_low = cpu_to_le32(o->iodepth_low);
375 top->iodepth_batch = cpu_to_le32(o->iodepth_batch);
82407585
RP
376 top->iodepth_batch_complete_min = cpu_to_le32(o->iodepth_batch_complete_min);
377 top->iodepth_batch_complete_max = cpu_to_le32(o->iodepth_batch_complete_max);
997b5680 378 top->serialize_overlap = cpu_to_le32(o->serialize_overlap);
2dc1cbb5 379 top->size_percent = cpu_to_le32(o->size_percent);
8b38f401 380 top->io_size_percent = cpu_to_le32(o->io_size_percent);
2dc1cbb5 381 top->fill_device = cpu_to_le32(o->fill_device);
bedc9dc2 382 top->file_append = cpu_to_le32(o->file_append);
2dc1cbb5 383 top->ratecycle = cpu_to_le32(o->ratecycle);
a9da8ab2 384 top->io_submit_mode = cpu_to_le32(o->io_submit_mode);
2dc1cbb5 385 top->nr_files = cpu_to_le32(o->nr_files);
20fdc81c 386 top->unique_filename = cpu_to_le32(o->unique_filename);
2dc1cbb5
JA
387 top->open_files = cpu_to_le32(o->open_files);
388 top->file_lock_mode = cpu_to_le32(o->file_lock_mode);
2dc1cbb5 389 top->odirect = cpu_to_le32(o->odirect);
d01612f3 390 top->oatomic = cpu_to_le32(o->oatomic);
2dc1cbb5
JA
391 top->invalidate_cache = cpu_to_le32(o->invalidate_cache);
392 top->create_serialize = cpu_to_le32(o->create_serialize);
393 top->create_fsync = cpu_to_le32(o->create_fsync);
394 top->create_on_open = cpu_to_le32(o->create_on_open);
fb390e24 395 top->create_only = cpu_to_le32(o->create_only);
2dc1cbb5
JA
396 top->end_fsync = cpu_to_le32(o->end_fsync);
397 top->pre_read = cpu_to_le32(o->pre_read);
398 top->sync_io = cpu_to_le32(o->sync_io);
ae8e559e 399 top->write_hint = cpu_to_le32(o->write_hint);
2dc1cbb5
JA
400 top->verify = cpu_to_le32(o->verify);
401 top->do_verify = cpu_to_le32(o->do_verify);
836fcc0f 402 top->experimental_verify = cpu_to_le32(o->experimental_verify);
ca09be4b 403 top->verify_state = cpu_to_le32(o->verify_state);
2dc1cbb5
JA
404 top->verify_interval = cpu_to_le32(o->verify_interval);
405 top->verify_offset = cpu_to_le32(o->verify_offset);
406 top->verify_pattern_bytes = cpu_to_le32(o->verify_pattern_bytes);
407 top->verify_fatal = cpu_to_le32(o->verify_fatal);
408 top->verify_dump = cpu_to_le32(o->verify_dump);
409 top->verify_async = cpu_to_le32(o->verify_async);
410 top->verify_batch = cpu_to_le32(o->verify_batch);
411 top->use_thread = cpu_to_le32(o->use_thread);
412 top->unlink = cpu_to_le32(o->unlink);
39c1c323 413 top->unlink_each_loop = cpu_to_le32(o->unlink_each_loop);
2dc1cbb5
JA
414 top->do_disk_util = cpu_to_le32(o->do_disk_util);
415 top->override_sync = cpu_to_le32(o->override_sync);
416 top->rand_repeatable = cpu_to_le32(o->rand_repeatable);
56e2a5fc 417 top->allrand_repeatable = cpu_to_le32(o->allrand_repeatable);
363cffa7 418 top->rand_seed = __cpu_to_le64(o->rand_seed);
2dc1cbb5 419 top->log_avg_msec = cpu_to_le32(o->log_avg_msec);
e6989e10 420 top->log_max = cpu_to_le32(o->log_max);
d6c0b409 421 top->log_offset = cpu_to_le32(o->log_offset);
03ec570f 422 top->log_prio = cpu_to_le32(o->log_prio);
aee2ab67 423 top->log_gz = cpu_to_le32(o->log_gz);
b26317c9 424 top->log_gz_store = cpu_to_le32(o->log_gz_store);
3aea75b1 425 top->log_unix_epoch = cpu_to_le32(o->log_unix_epoch);
2dc1cbb5
JA
426 top->norandommap = cpu_to_le32(o->norandommap);
427 top->softrandommap = cpu_to_le32(o->softrandommap);
428 top->bs_unaligned = cpu_to_le32(o->bs_unaligned);
429 top->fsync_on_close = cpu_to_le32(o->fsync_on_close);
6aca9b3d 430 top->bs_is_seq_rand = cpu_to_le32(o->bs_is_seq_rand);
1e5324e7 431 top->random_distribution = cpu_to_le32(o->random_distribution);
f9cafb12 432 top->exitall_error = cpu_to_le32(o->exitall_error);
1e5324e7
JA
433 top->zipf_theta.u.i = __cpu_to_le64(fio_double_to_uint64(o->zipf_theta.u.f));
434 top->pareto_h.u.i = __cpu_to_le64(fio_double_to_uint64(o->pareto_h.u.f));
f88cd222 435 top->gauss_dev.u.i = __cpu_to_le64(fio_double_to_uint64(o->gauss_dev.u.f));
a87c90fd 436 top->random_center.u.i = __cpu_to_le64(fio_double_to_uint64(o->random_center.u.f));
49758e11 437 top->random_generator = cpu_to_le32(o->random_generator);
2dc1cbb5 438 top->hugepage_size = cpu_to_le32(o->hugepage_size);
5fff9543 439 top->rw_min_bs = __cpu_to_le64(o->rw_min_bs);
2dc1cbb5
JA
440 top->thinktime = cpu_to_le32(o->thinktime);
441 top->thinktime_spin = cpu_to_le32(o->thinktime_spin);
442 top->thinktime_blocks = cpu_to_le32(o->thinktime_blocks);
33f42c20 443 top->thinktime_blocks_type = __cpu_to_le32(o->thinktime_blocks_type);
f7942acd 444 top->thinktime_iotime = __cpu_to_le32(o->thinktime_iotime);
2dc1cbb5
JA
445 top->fsync_blocks = cpu_to_le32(o->fsync_blocks);
446 top->fdatasync_blocks = cpu_to_le32(o->fdatasync_blocks);
447 top->barrier_blocks = cpu_to_le32(o->barrier_blocks);
448 top->overwrite = cpu_to_le32(o->overwrite);
449 top->bw_avg_time = cpu_to_le32(o->bw_avg_time);
450 top->iops_avg_time = cpu_to_le32(o->iops_avg_time);
451 top->loops = cpu_to_le32(o->loops);
452 top->mem_type = cpu_to_le32(o->mem_type);
453 top->mem_align = cpu_to_le32(o->mem_align);
fd56c235
AW
454 top->exit_what = cpu_to_le32(o->exit_what);
455 top->stonewall = cpu_to_le32(o->stonewall);
2dc1cbb5
JA
456 top->new_group = cpu_to_le32(o->new_group);
457 top->numjobs = cpu_to_le32(o->numjobs);
c2acfbac 458 top->cpus_allowed_policy = cpu_to_le32(o->cpus_allowed_policy);
6599ce5a 459 top->gpu_dev_id = cpu_to_le32(o->gpu_dev_id);
2dc1cbb5
JA
460 top->iolog = cpu_to_le32(o->iolog);
461 top->rwmixcycle = cpu_to_le32(o->rwmixcycle);
462 top->nice = cpu_to_le32(o->nice);
28727df7
JA
463 top->ioprio = cpu_to_le32(o->ioprio);
464 top->ioprio_class = cpu_to_le32(o->ioprio_class);
2dc1cbb5
JA
465 top->file_service_type = cpu_to_le32(o->file_service_type);
466 top->group_reporting = cpu_to_le32(o->group_reporting);
8243be59 467 top->stats = cpu_to_le32(o->stats);
2dc1cbb5
JA
468 top->fadvise_hint = cpu_to_le32(o->fadvise_hint);
469 top->fallocate_mode = cpu_to_le32(o->fallocate_mode);
470 top->zero_buffers = cpu_to_le32(o->zero_buffers);
471 top->refill_buffers = cpu_to_le32(o->refill_buffers);
472 top->scramble_buffers = cpu_to_le32(o->scramble_buffers);
3c78a83f 473 top->buffer_pattern_bytes = cpu_to_le32(o->buffer_pattern_bytes);
2dc1cbb5
JA
474 top->time_based = cpu_to_le32(o->time_based);
475 top->disable_lat = cpu_to_le32(o->disable_lat);
476 top->disable_clat = cpu_to_le32(o->disable_clat);
477 top->disable_slat = cpu_to_le32(o->disable_slat);
478 top->disable_bw = cpu_to_le32(o->disable_bw);
95820b6e 479 top->unified_rw_rep = cpu_to_le32(o->unified_rw_rep);
2dc1cbb5
JA
480 top->gtod_reduce = cpu_to_le32(o->gtod_reduce);
481 top->gtod_cpu = cpu_to_le32(o->gtod_cpu);
2dc1cbb5
JA
482 top->clocksource = cpu_to_le32(o->clocksource);
483 top->no_stall = cpu_to_le32(o->no_stall);
484 top->trim_percentage = cpu_to_le32(o->trim_percentage);
485 top->trim_batch = cpu_to_le32(o->trim_batch);
486 top->trim_zero = cpu_to_le32(o->trim_zero);
487 top->clat_percentiles = cpu_to_le32(o->clat_percentiles);
b599759b 488 top->lat_percentiles = cpu_to_le32(o->lat_percentiles);
56440e63 489 top->slat_percentiles = cpu_to_le32(o->slat_percentiles);
9db01ef9 490 top->percentile_precision = cpu_to_le32(o->percentile_precision);
e883cb35 491 top->sig_figs = cpu_to_le32(o->sig_figs);
2dc1cbb5
JA
492 top->continue_on_error = cpu_to_le32(o->continue_on_error);
493 top->cgroup_weight = cpu_to_le32(o->cgroup_weight);
494 top->cgroup_nodelete = cpu_to_le32(o->cgroup_nodelete);
495 top->uid = cpu_to_le32(o->uid);
496 top->gid = cpu_to_le32(o->gid);
497 top->flow_id = __cpu_to_le32(o->flow_id);
20c7a244 498 top->flow = cpu_to_le32(o->flow);
2dc1cbb5
JA
499 top->flow_sleep = cpu_to_le32(o->flow_sleep);
500 top->sync_file_range = cpu_to_le32(o->sync_file_range);
3e260a46
JA
501 top->latency_target = __cpu_to_le64(o->latency_target);
502 top->latency_window = __cpu_to_le64(o->latency_window);
503 top->latency_percentile.u.i = __cpu_to_le64(fio_double_to_uint64(o->latency_percentile.u.f));
e1bcd541 504 top->latency_run = __cpu_to_le32(o->latency_run);
e476994e
JA
505 top->compress_percentage = cpu_to_le32(o->compress_percentage);
506 top->compress_chunk = cpu_to_le32(o->compress_chunk);
5c94b008 507 top->dedupe_percentage = cpu_to_le32(o->dedupe_percentage);
0d71aa98
BD
508 top->dedupe_mode = cpu_to_le32(o->dedupe_mode);
509 top->dedupe_working_set_percentage = cpu_to_le32(o->dedupe_working_set_percentage);
d77d8152 510 top->block_error_hist = cpu_to_le32(o->block_error_hist);
0c63576e
JA
511 top->replay_align = cpu_to_le32(o->replay_align);
512 top->replay_scale = cpu_to_le32(o->replay_scale);
dd39e2d4 513 top->replay_time_scale = cpu_to_le32(o->replay_time_scale);
d7235efb 514 top->replay_skip = cpu_to_le32(o->replay_skip);
3a5db920 515 top->per_job_logs = cpu_to_le32(o->per_job_logs);
dded427c
OS
516 top->write_bw_log = cpu_to_le32(o->write_bw_log);
517 top->write_lat_log = cpu_to_le32(o->write_lat_log);
518 top->write_iops_log = cpu_to_le32(o->write_iops_log);
519 top->write_hist_log = cpu_to_le32(o->write_hist_log);
2dc1cbb5 520
b999b3c7 521 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
5fff9543
JF
522 top->bs[i] = __cpu_to_le64(o->bs[i]);
523 top->ba[i] = __cpu_to_le64(o->ba[i]);
524 top->min_bs[i] = __cpu_to_le64(o->min_bs[i]);
525 top->max_bs[i] = __cpu_to_le64(o->max_bs[i]);
2dc1cbb5
JA
526 top->bssplit_nr[i] = cpu_to_le32(o->bssplit_nr[i]);
527
528 if (o->bssplit_nr[i]) {
529 unsigned int bssplit_nr = o->bssplit_nr[i];
530
531 if (bssplit_nr > BSSPLIT_MAX) {
532 log_err("fio: BSSPLIT_MAX is too small\n");
533 bssplit_nr = BSSPLIT_MAX;
534 }
535 for (j = 0; j < bssplit_nr; j++) {
5fff9543 536 top->bssplit[i][j].bs = cpu_to_le64(o->bssplit[i][j].bs);
2dc1cbb5
JA
537 top->bssplit[i][j].perc = cpu_to_le32(o->bssplit[i][j].perc);
538 }
539 }
540
e0a04ac1
JA
541 top->zone_split_nr[i] = cpu_to_le32(o->zone_split_nr[i]);
542
543 if (o->zone_split_nr[i]) {
544 unsigned int zone_split_nr = o->zone_split_nr[i];
545
546 if (zone_split_nr > ZONESPLIT_MAX) {
547 log_err("fio: ZONESPLIT_MAX is too small\n");
548 zone_split_nr = ZONESPLIT_MAX;
549 }
550 for (j = 0; j < zone_split_nr; j++) {
551 top->zone_split[i][j].access_perc = o->zone_split[i][j].access_perc;
552 top->zone_split[i][j].size_perc = o->zone_split[i][j].size_perc;
553 }
554 }
555
2dc1cbb5 556 top->rwmix[i] = cpu_to_le32(o->rwmix[i]);
90eff1c9
SW
557 top->rate[i] = cpu_to_le64(o->rate[i]);
558 top->ratemin[i] = cpu_to_le64(o->ratemin[i]);
2dc1cbb5
JA
559 top->rate_iops[i] = cpu_to_le32(o->rate_iops[i]);
560 top->rate_iops_min[i] = cpu_to_le32(o->rate_iops_min[i]);
d9472271
JA
561
562 top->perc_rand[i] = cpu_to_le32(o->perc_rand[i]);
f7cf63bf
VR
563
564 top->max_latency[i] = __cpu_to_le64(o->max_latency[i]);
2dc1cbb5
JA
565 }
566
567 memcpy(top->verify_pattern, o->verify_pattern, MAX_PATTERN_SIZE);
3c78a83f 568 memcpy(top->buffer_pattern, o->buffer_pattern, MAX_PATTERN_SIZE);
2dc1cbb5
JA
569
570 top->size = __cpu_to_le64(o->size);
5be9bf09 571 top->io_size = __cpu_to_le64(o->io_size);
2dc1cbb5
JA
572 top->verify_backlog = __cpu_to_le64(o->verify_backlog);
573 top->start_delay = __cpu_to_le64(o->start_delay);
23ed19b0 574 top->start_delay_high = __cpu_to_le64(o->start_delay_high);
2dc1cbb5
JA
575 top->timeout = __cpu_to_le64(o->timeout);
576 top->ramp_time = __cpu_to_le64(o->ramp_time);
72863286
JA
577 top->ss_dur = __cpu_to_le64(top->ss_dur);
578 top->ss_ramp_time = __cpu_to_le64(top->ss_ramp_time);
2c5d94bc 579 top->ss_state = cpu_to_le32(top->ss_state);
72863286 580 top->ss_limit.u.i = __cpu_to_le64(fio_double_to_uint64(o->ss_limit.u.f));
2dc1cbb5
JA
581 top->zone_range = __cpu_to_le64(o->zone_range);
582 top->zone_size = __cpu_to_le64(o->zone_size);
b8dd9750 583 top->zone_capacity = __cpu_to_le64(o->zone_capacity);
2dc1cbb5 584 top->zone_skip = __cpu_to_le64(o->zone_skip);
7b865a2f 585 top->zone_mode = __cpu_to_le32(o->zone_mode);
6df25f78 586 top->max_open_zones = __cpu_to_le32(o->max_open_zones);
575686bb 587 top->ignore_zone_limits = cpu_to_le32(o->ignore_zone_limits);
ae278f9a 588 top->lockmem = __cpu_to_le64(o->lockmem);
2dc1cbb5
JA
589 top->ddir_seq_add = __cpu_to_le64(o->ddir_seq_add);
590 top->file_size_low = __cpu_to_le64(o->file_size_low);
591 top->file_size_high = __cpu_to_le64(o->file_size_high);
592 top->start_offset = __cpu_to_le64(o->start_offset);
83c8b093 593 top->start_offset_align = __cpu_to_le64(o->start_offset_align);
89978a6b 594 top->start_offset_percent = __cpu_to_le32(o->start_offset_percent);
2dc1cbb5 595 top->trim_backlog = __cpu_to_le64(o->trim_backlog);
0b288ba1 596 top->offset_increment_percent = __cpu_to_le32(o->offset_increment_percent);
6a4cf74f 597 top->offset_increment = __cpu_to_le64(o->offset_increment);
ddf24e42 598 top->number_ios = __cpu_to_le64(o->number_ios);
6de65959 599 top->rate_process = cpu_to_le32(o->rate_process);
1a9bf814 600 top->rate_ign_think = cpu_to_le32(o->rate_ign_think);
2dc1cbb5
JA
601
602 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
603 top->percentile_list[i].u.i = __cpu_to_le64(fio_double_to_uint64(o->percentile_list[i].u.f));
87a48ada
DZ
604
605 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
606 top->merge_blktrace_scalars[i].u.i = __cpu_to_le64(fio_double_to_uint64(o->merge_blktrace_scalars[i].u.f));
55bfd8c8
DZ
607
608 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
609 top->merge_blktrace_iters[i].u.i = __cpu_to_le64(fio_double_to_uint64(o->merge_blktrace_iters[i].u.f));
2dc1cbb5 610#if 0
3c3ed070
JA
611 uint8_t cpumask[FIO_TOP_STR_MAX];
612 uint8_t verify_cpumask[FIO_TOP_STR_MAX];
c08f9fe2 613 uint8_t log_gz_cpumask[FIO_TOP_STR_MAX];
2dc1cbb5
JA
614#endif
615
616}
617
51167799
JA
618/*
619 * Basic conversion test. We'd really need to fill in more of the options
620 * to have a thorough test. Even better, we should auto-generate the
621 * converter functions...
622 */
623int fio_test_cconv(struct thread_options *__o)
624{
625 struct thread_options o;
626 struct thread_options_pack top1, top2;
627
628 memset(&top1, 0, sizeof(top1));
629 memset(&top2, 0, sizeof(top2));
630
631 convert_thread_options_to_net(&top1, __o);
632 memset(&o, 0, sizeof(o));
633 convert_thread_options_to_cpu(&o, &top1);
634 convert_thread_options_to_net(&top2, &o);
635
eb0c74ae
JA
636 free_thread_options_to_cpu(&o);
637
51167799
JA
638 return memcmp(&top1, &top2, sizeof(top1));
639}