cconv: wire up conversion of unique_filename
[fio.git] / cconv.c
CommitLineData
51167799
JA
1#include <string.h>
2
2dc1cbb5
JA
3#include "thread_options.h"
4
5static void string_to_cpu(char **dst, const uint8_t *src)
6{
7 const char *__src = (const char *) src;
8
9 if (strlen(__src))
10 *dst = strdup(__src);
11}
12
3660ceae 13static void __string_to_net(uint8_t *dst, const char *src, size_t dst_size)
2dc1cbb5 14{
3660ceae
JA
15 if (src) {
16 dst[dst_size - 1] = '\0';
17 strncpy((char *) dst, src, dst_size - 1);
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);
39 free(o->bw_log_file);
40 free(o->lat_log_file);
41 free(o->iops_log_file);
42 free(o->replay_redirect);
43 free(o->exec_prerun);
44 free(o->exec_postrun);
45 free(o->ioscheduler);
46 free(o->profile);
47 free(o->cgroup);
e0a04ac1
JA
48
49 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
50 free(o->bssplit[i]);
51 free(o->zone_split[i]);
52 }
eb0c74ae
JA
53}
54
2dc1cbb5
JA
55void convert_thread_options_to_cpu(struct thread_options *o,
56 struct thread_options_pack *top)
57{
58 int i, j;
59
3b577774
JA
60 for (i = 0; i < NR_OPTS_SZ; i++)
61 o->set_options[i] = le64_to_cpu(top->set_options[i]);
62
2dc1cbb5
JA
63 string_to_cpu(&o->description, top->description);
64 string_to_cpu(&o->name, top->name);
9cc8cb91 65 string_to_cpu(&o->wait_for, top->wait_for);
2dc1cbb5
JA
66 string_to_cpu(&o->directory, top->directory);
67 string_to_cpu(&o->filename, top->filename);
22f80458 68 string_to_cpu(&o->filename_format, top->filename_format);
2dc1cbb5
JA
69 string_to_cpu(&o->opendir, top->opendir);
70 string_to_cpu(&o->ioengine, top->ioengine);
83ea422a 71 string_to_cpu(&o->mmapfile, top->mmapfile);
2dc1cbb5
JA
72 string_to_cpu(&o->read_iolog_file, top->read_iolog_file);
73 string_to_cpu(&o->write_iolog_file, top->write_iolog_file);
74 string_to_cpu(&o->bw_log_file, top->bw_log_file);
75 string_to_cpu(&o->lat_log_file, top->lat_log_file);
76 string_to_cpu(&o->iops_log_file, top->iops_log_file);
77 string_to_cpu(&o->replay_redirect, top->replay_redirect);
78 string_to_cpu(&o->exec_prerun, top->exec_prerun);
79 string_to_cpu(&o->exec_postrun, top->exec_postrun);
80 string_to_cpu(&o->ioscheduler, top->ioscheduler);
81 string_to_cpu(&o->profile, top->profile);
82 string_to_cpu(&o->cgroup, top->cgroup);
83
2378826d 84 o->allow_create = le32_to_cpu(top->allow_create);
8e093781 85 o->allow_mounted_write = le32_to_cpu(top->allow_mounted_write);
2dc1cbb5
JA
86 o->td_ddir = le32_to_cpu(top->td_ddir);
87 o->rw_seq = le32_to_cpu(top->rw_seq);
88 o->kb_base = le32_to_cpu(top->kb_base);
22f80458 89 o->unit_base = le32_to_cpu(top->kb_base);
2dc1cbb5
JA
90 o->ddir_seq_nr = le32_to_cpu(top->ddir_seq_nr);
91 o->ddir_seq_add = le64_to_cpu(top->ddir_seq_add);
92 o->iodepth = le32_to_cpu(top->iodepth);
93 o->iodepth_low = le32_to_cpu(top->iodepth_low);
94 o->iodepth_batch = le32_to_cpu(top->iodepth_batch);
82407585
RP
95 o->iodepth_batch_complete_min = le32_to_cpu(top->iodepth_batch_complete_min);
96 o->iodepth_batch_complete_max = le32_to_cpu(top->iodepth_batch_complete_max);
2dc1cbb5 97 o->size = le64_to_cpu(top->size);
77731b29 98 o->io_limit = le64_to_cpu(top->io_limit);
2dc1cbb5
JA
99 o->size_percent = le32_to_cpu(top->size_percent);
100 o->fill_device = le32_to_cpu(top->fill_device);
bedc9dc2 101 o->file_append = le32_to_cpu(top->file_append);
2dc1cbb5
JA
102 o->file_size_low = le64_to_cpu(top->file_size_low);
103 o->file_size_high = le64_to_cpu(top->file_size_high);
104 o->start_offset = le64_to_cpu(top->start_offset);
105
b999b3c7 106 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
2dc1cbb5
JA
107 o->bs[i] = le32_to_cpu(top->bs[i]);
108 o->ba[i] = le32_to_cpu(top->ba[i]);
109 o->min_bs[i] = le32_to_cpu(top->min_bs[i]);
110 o->max_bs[i] = le32_to_cpu(top->max_bs[i]);
111 o->bssplit_nr[i] = le32_to_cpu(top->bssplit_nr[i]);
112
113 if (o->bssplit_nr[i]) {
114 o->bssplit[i] = malloc(o->bssplit_nr[i] * sizeof(struct bssplit));
115 for (j = 0; j < o->bssplit_nr[i]; j++) {
116 o->bssplit[i][j].bs = le32_to_cpu(top->bssplit[i][j].bs);
117 o->bssplit[i][j].perc = le32_to_cpu(top->bssplit[i][j].perc);
118 }
119 }
120
e0a04ac1
JA
121 o->zone_split_nr[i] = le32_to_cpu(top->zone_split_nr[i]);
122
123 if (o->zone_split_nr[i]) {
124 o->zone_split[i] = malloc(o->zone_split_nr[i] * sizeof(struct zone_split));
125 for (j = 0; j < o->zone_split_nr[i]; j++) {
126 o->zone_split[i][j].access_perc = top->zone_split[i][j].access_perc;
127 o->zone_split[i][j].size_perc = top->zone_split[i][j].size_perc;
128 }
129 }
130
2dc1cbb5
JA
131 o->rwmix[i] = le32_to_cpu(top->rwmix[i]);
132 o->rate[i] = le32_to_cpu(top->rate[i]);
133 o->ratemin[i] = le32_to_cpu(top->ratemin[i]);
134 o->rate_iops[i] = le32_to_cpu(top->rate_iops[i]);
135 o->rate_iops_min[i] = le32_to_cpu(top->rate_iops_min[i]);
d9472271
JA
136
137 o->perc_rand[i] = le32_to_cpu(top->perc_rand[i]);
2dc1cbb5
JA
138 }
139
140 o->ratecycle = le32_to_cpu(top->ratecycle);
a9da8ab2 141 o->io_submit_mode = le32_to_cpu(top->io_submit_mode);
20fdc81c 142 o->unique_filename = le32_to_cpu(top->unique_filename);
2dc1cbb5
JA
143 o->nr_files = le32_to_cpu(top->nr_files);
144 o->open_files = le32_to_cpu(top->open_files);
145 o->file_lock_mode = le32_to_cpu(top->file_lock_mode);
2dc1cbb5 146 o->odirect = le32_to_cpu(top->odirect);
d01612f3 147 o->oatomic = le32_to_cpu(top->oatomic);
2dc1cbb5
JA
148 o->invalidate_cache = le32_to_cpu(top->invalidate_cache);
149 o->create_serialize = le32_to_cpu(top->create_serialize);
150 o->create_fsync = le32_to_cpu(top->create_fsync);
151 o->create_on_open = le32_to_cpu(top->create_on_open);
fb390e24 152 o->create_only = le32_to_cpu(top->create_only);
2dc1cbb5
JA
153 o->end_fsync = le32_to_cpu(top->end_fsync);
154 o->pre_read = le32_to_cpu(top->pre_read);
155 o->sync_io = le32_to_cpu(top->sync_io);
156 o->verify = le32_to_cpu(top->verify);
157 o->do_verify = le32_to_cpu(top->do_verify);
158 o->verifysort = le32_to_cpu(top->verifysort);
836fcc0f
JA
159 o->verifysort_nr = le32_to_cpu(top->verifysort_nr);
160 o->experimental_verify = le32_to_cpu(top->experimental_verify);
ca09be4b 161 o->verify_state = le32_to_cpu(top->verify_state);
2dc1cbb5
JA
162 o->verify_interval = le32_to_cpu(top->verify_interval);
163 o->verify_offset = le32_to_cpu(top->verify_offset);
164
165 memcpy(o->verify_pattern, top->verify_pattern, MAX_PATTERN_SIZE);
3c78a83f 166 memcpy(o->buffer_pattern, top->buffer_pattern, MAX_PATTERN_SIZE);
2dc1cbb5
JA
167
168 o->verify_pattern_bytes = le32_to_cpu(top->verify_pattern_bytes);
169 o->verify_fatal = le32_to_cpu(top->verify_fatal);
170 o->verify_dump = le32_to_cpu(top->verify_dump);
171 o->verify_async = le32_to_cpu(top->verify_async);
172 o->verify_batch = le32_to_cpu(top->verify_batch);
173 o->use_thread = le32_to_cpu(top->use_thread);
174 o->unlink = le32_to_cpu(top->unlink);
175 o->do_disk_util = le32_to_cpu(top->do_disk_util);
176 o->override_sync = le32_to_cpu(top->override_sync);
177 o->rand_repeatable = le32_to_cpu(top->rand_repeatable);
56e2a5fc 178 o->allrand_repeatable = le32_to_cpu(top->allrand_repeatable);
363cffa7 179 o->rand_seed = le64_to_cpu(top->rand_seed);
2dc1cbb5 180 o->log_avg_msec = le32_to_cpu(top->log_avg_msec);
e6989e10 181 o->log_max = le32_to_cpu(top->log_max);
d6c0b409 182 o->log_offset = le32_to_cpu(top->log_offset);
aee2ab67 183 o->log_gz = le32_to_cpu(top->log_gz);
b26317c9 184 o->log_gz_store = le32_to_cpu(top->log_gz_store);
2dc1cbb5
JA
185 o->norandommap = le32_to_cpu(top->norandommap);
186 o->softrandommap = le32_to_cpu(top->softrandommap);
187 o->bs_unaligned = le32_to_cpu(top->bs_unaligned);
188 o->fsync_on_close = le32_to_cpu(top->fsync_on_close);
6aca9b3d 189 o->bs_is_seq_rand = le32_to_cpu(top->bs_is_seq_rand);
1e5324e7 190 o->random_distribution = le32_to_cpu(top->random_distribution);
f9cafb12 191 o->exitall_error = le32_to_cpu(top->exitall_error);
1e5324e7
JA
192 o->zipf_theta.u.f = fio_uint64_to_double(le64_to_cpu(top->zipf_theta.u.i));
193 o->pareto_h.u.f = fio_uint64_to_double(le64_to_cpu(top->pareto_h.u.i));
f88cd222 194 o->gauss_dev.u.f = fio_uint64_to_double(le64_to_cpu(top->gauss_dev.u.i));
49758e11 195 o->random_generator = le32_to_cpu(top->random_generator);
2dc1cbb5
JA
196 o->hugepage_size = le32_to_cpu(top->hugepage_size);
197 o->rw_min_bs = le32_to_cpu(top->rw_min_bs);
198 o->thinktime = le32_to_cpu(top->thinktime);
199 o->thinktime_spin = le32_to_cpu(top->thinktime_spin);
200 o->thinktime_blocks = le32_to_cpu(top->thinktime_blocks);
201 o->fsync_blocks = le32_to_cpu(top->fsync_blocks);
202 o->fdatasync_blocks = le32_to_cpu(top->fdatasync_blocks);
203 o->barrier_blocks = le32_to_cpu(top->barrier_blocks);
204
205 o->verify_backlog = le64_to_cpu(top->verify_backlog);
206 o->start_delay = le64_to_cpu(top->start_delay);
23ed19b0 207 o->start_delay_high = le64_to_cpu(top->start_delay_high);
2dc1cbb5
JA
208 o->timeout = le64_to_cpu(top->timeout);
209 o->ramp_time = le64_to_cpu(top->ramp_time);
210 o->zone_range = le64_to_cpu(top->zone_range);
211 o->zone_size = le64_to_cpu(top->zone_size);
212 o->zone_skip = le64_to_cpu(top->zone_skip);
ae278f9a 213 o->lockmem = le64_to_cpu(top->lockmem);
6a4cf74f 214 o->offset_increment = le64_to_cpu(top->offset_increment);
ddf24e42 215 o->number_ios = le64_to_cpu(top->number_ios);
2dc1cbb5
JA
216
217 o->overwrite = le32_to_cpu(top->overwrite);
218 o->bw_avg_time = le32_to_cpu(top->bw_avg_time);
219 o->iops_avg_time = le32_to_cpu(top->iops_avg_time);
220 o->loops = le32_to_cpu(top->loops);
221 o->mem_type = le32_to_cpu(top->mem_type);
222 o->mem_align = le32_to_cpu(top->mem_align);
1e5324e7 223 o->max_latency = le32_to_cpu(top->max_latency);
2dc1cbb5
JA
224 o->stonewall = le32_to_cpu(top->stonewall);
225 o->new_group = le32_to_cpu(top->new_group);
226 o->numjobs = le32_to_cpu(top->numjobs);
c2acfbac 227 o->cpus_allowed_policy = le32_to_cpu(top->cpus_allowed_policy);
2dc1cbb5
JA
228 o->iolog = le32_to_cpu(top->iolog);
229 o->rwmixcycle = le32_to_cpu(top->rwmixcycle);
230 o->nice = le32_to_cpu(top->nice);
28727df7
JA
231 o->ioprio = le32_to_cpu(top->ioprio);
232 o->ioprio_class = le32_to_cpu(top->ioprio_class);
2dc1cbb5
JA
233 o->file_service_type = le32_to_cpu(top->file_service_type);
234 o->group_reporting = le32_to_cpu(top->group_reporting);
235 o->fadvise_hint = le32_to_cpu(top->fadvise_hint);
236 o->fallocate_mode = le32_to_cpu(top->fallocate_mode);
237 o->zero_buffers = le32_to_cpu(top->zero_buffers);
238 o->refill_buffers = le32_to_cpu(top->refill_buffers);
239 o->scramble_buffers = le32_to_cpu(top->scramble_buffers);
3c78a83f 240 o->buffer_pattern_bytes = le32_to_cpu(top->buffer_pattern_bytes);
2dc1cbb5
JA
241 o->time_based = le32_to_cpu(top->time_based);
242 o->disable_lat = le32_to_cpu(top->disable_lat);
243 o->disable_clat = le32_to_cpu(top->disable_clat);
244 o->disable_slat = le32_to_cpu(top->disable_slat);
245 o->disable_bw = le32_to_cpu(top->disable_bw);
95820b6e 246 o->unified_rw_rep = le32_to_cpu(top->unified_rw_rep);
2dc1cbb5
JA
247 o->gtod_reduce = le32_to_cpu(top->gtod_reduce);
248 o->gtod_cpu = le32_to_cpu(top->gtod_cpu);
2dc1cbb5
JA
249 o->clocksource = le32_to_cpu(top->clocksource);
250 o->no_stall = le32_to_cpu(top->no_stall);
251 o->trim_percentage = le32_to_cpu(top->trim_percentage);
252 o->trim_batch = le32_to_cpu(top->trim_batch);
253 o->trim_zero = le32_to_cpu(top->trim_zero);
254 o->clat_percentiles = le32_to_cpu(top->clat_percentiles);
9db01ef9 255 o->percentile_precision = le32_to_cpu(top->percentile_precision);
2dc1cbb5
JA
256 o->continue_on_error = le32_to_cpu(top->continue_on_error);
257 o->cgroup_weight = le32_to_cpu(top->cgroup_weight);
258 o->cgroup_nodelete = le32_to_cpu(top->cgroup_nodelete);
259 o->uid = le32_to_cpu(top->uid);
260 o->gid = le32_to_cpu(top->gid);
261 o->flow_id = __le32_to_cpu(top->flow_id);
262 o->flow = __le32_to_cpu(top->flow);
263 o->flow_watermark = __le32_to_cpu(top->flow_watermark);
264 o->flow_sleep = le32_to_cpu(top->flow_sleep);
265 o->sync_file_range = le32_to_cpu(top->sync_file_range);
3e260a46
JA
266 o->latency_target = le64_to_cpu(top->latency_target);
267 o->latency_window = le64_to_cpu(top->latency_window);
268 o->latency_percentile.u.f = fio_uint64_to_double(le64_to_cpu(top->latency_percentile.u.i));
e476994e
JA
269 o->compress_percentage = le32_to_cpu(top->compress_percentage);
270 o->compress_chunk = le32_to_cpu(top->compress_chunk);
5c94b008 271 o->dedupe_percentage = le32_to_cpu(top->dedupe_percentage);
d77d8152
JA
272 o->skip_bad = le32_to_cpu(top->skip_bad);
273 o->block_error_hist = le32_to_cpu(top->block_error_hist);
0c63576e
JA
274 o->replay_align = le32_to_cpu(top->replay_align);
275 o->replay_scale = le32_to_cpu(top->replay_scale);
3a5db920 276 o->per_job_logs = le32_to_cpu(top->per_job_logs);
2dc1cbb5
JA
277
278 o->trim_backlog = le64_to_cpu(top->trim_backlog);
6de65959 279 o->rate_process = le32_to_cpu(top->rate_process);
2dc1cbb5
JA
280
281 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
282 o->percentile_list[i].u.f = fio_uint64_to_double(le64_to_cpu(top->percentile_list[i].u.i));
283#if 0
3c3ed070
JA
284 uint8_t cpumask[FIO_TOP_STR_MAX];
285 uint8_t verify_cpumask[FIO_TOP_STR_MAX];
c08f9fe2 286 uint8_t log_gz_cpumask[FIO_TOP_STR_MAX];
2dc1cbb5
JA
287#endif
288}
289
290void convert_thread_options_to_net(struct thread_options_pack *top,
291 struct thread_options *o)
292{
293 int i, j;
294
3b577774
JA
295 for (i = 0; i < NR_OPTS_SZ; i++)
296 top->set_options[i] = cpu_to_le64(o->set_options[i]);
297
2dc1cbb5
JA
298 string_to_net(top->description, o->description);
299 string_to_net(top->name, o->name);
9cc8cb91 300 string_to_net(top->wait_for, o->wait_for);
2dc1cbb5
JA
301 string_to_net(top->directory, o->directory);
302 string_to_net(top->filename, o->filename);
22f80458 303 string_to_net(top->filename_format, o->filename_format);
2dc1cbb5
JA
304 string_to_net(top->opendir, o->opendir);
305 string_to_net(top->ioengine, o->ioengine);
83ea422a 306 string_to_net(top->mmapfile, o->mmapfile);
2dc1cbb5
JA
307 string_to_net(top->read_iolog_file, o->read_iolog_file);
308 string_to_net(top->write_iolog_file, o->write_iolog_file);
309 string_to_net(top->bw_log_file, o->bw_log_file);
310 string_to_net(top->lat_log_file, o->lat_log_file);
311 string_to_net(top->iops_log_file, o->iops_log_file);
312 string_to_net(top->replay_redirect, o->replay_redirect);
313 string_to_net(top->exec_prerun, o->exec_prerun);
314 string_to_net(top->exec_postrun, o->exec_postrun);
315 string_to_net(top->ioscheduler, o->ioscheduler);
316 string_to_net(top->profile, o->profile);
317 string_to_net(top->cgroup, o->cgroup);
318
2378826d 319 top->allow_create = cpu_to_le32(o->allow_create);
8e093781 320 top->allow_mounted_write = cpu_to_le32(o->allow_mounted_write);
2dc1cbb5
JA
321 top->td_ddir = cpu_to_le32(o->td_ddir);
322 top->rw_seq = cpu_to_le32(o->rw_seq);
323 top->kb_base = cpu_to_le32(o->kb_base);
22f80458 324 top->unit_base = cpu_to_le32(o->kb_base);
2dc1cbb5
JA
325 top->ddir_seq_nr = cpu_to_le32(o->ddir_seq_nr);
326 top->iodepth = cpu_to_le32(o->iodepth);
327 top->iodepth_low = cpu_to_le32(o->iodepth_low);
328 top->iodepth_batch = cpu_to_le32(o->iodepth_batch);
82407585
RP
329 top->iodepth_batch_complete_min = cpu_to_le32(o->iodepth_batch_complete_min);
330 top->iodepth_batch_complete_max = cpu_to_le32(o->iodepth_batch_complete_max);
2dc1cbb5
JA
331 top->size_percent = cpu_to_le32(o->size_percent);
332 top->fill_device = cpu_to_le32(o->fill_device);
bedc9dc2 333 top->file_append = cpu_to_le32(o->file_append);
2dc1cbb5 334 top->ratecycle = cpu_to_le32(o->ratecycle);
a9da8ab2 335 top->io_submit_mode = cpu_to_le32(o->io_submit_mode);
2dc1cbb5 336 top->nr_files = cpu_to_le32(o->nr_files);
20fdc81c 337 top->unique_filename = cpu_to_le32(o->unique_filename);
2dc1cbb5
JA
338 top->open_files = cpu_to_le32(o->open_files);
339 top->file_lock_mode = cpu_to_le32(o->file_lock_mode);
2dc1cbb5 340 top->odirect = cpu_to_le32(o->odirect);
d01612f3 341 top->oatomic = cpu_to_le32(o->oatomic);
2dc1cbb5
JA
342 top->invalidate_cache = cpu_to_le32(o->invalidate_cache);
343 top->create_serialize = cpu_to_le32(o->create_serialize);
344 top->create_fsync = cpu_to_le32(o->create_fsync);
345 top->create_on_open = cpu_to_le32(o->create_on_open);
fb390e24 346 top->create_only = cpu_to_le32(o->create_only);
2dc1cbb5
JA
347 top->end_fsync = cpu_to_le32(o->end_fsync);
348 top->pre_read = cpu_to_le32(o->pre_read);
349 top->sync_io = cpu_to_le32(o->sync_io);
350 top->verify = cpu_to_le32(o->verify);
351 top->do_verify = cpu_to_le32(o->do_verify);
352 top->verifysort = cpu_to_le32(o->verifysort);
836fcc0f
JA
353 top->verifysort_nr = cpu_to_le32(o->verifysort_nr);
354 top->experimental_verify = cpu_to_le32(o->experimental_verify);
ca09be4b 355 top->verify_state = cpu_to_le32(o->verify_state);
2dc1cbb5
JA
356 top->verify_interval = cpu_to_le32(o->verify_interval);
357 top->verify_offset = cpu_to_le32(o->verify_offset);
358 top->verify_pattern_bytes = cpu_to_le32(o->verify_pattern_bytes);
359 top->verify_fatal = cpu_to_le32(o->verify_fatal);
360 top->verify_dump = cpu_to_le32(o->verify_dump);
361 top->verify_async = cpu_to_le32(o->verify_async);
362 top->verify_batch = cpu_to_le32(o->verify_batch);
363 top->use_thread = cpu_to_le32(o->use_thread);
364 top->unlink = cpu_to_le32(o->unlink);
365 top->do_disk_util = cpu_to_le32(o->do_disk_util);
366 top->override_sync = cpu_to_le32(o->override_sync);
367 top->rand_repeatable = cpu_to_le32(o->rand_repeatable);
56e2a5fc 368 top->allrand_repeatable = cpu_to_le32(o->allrand_repeatable);
363cffa7 369 top->rand_seed = __cpu_to_le64(o->rand_seed);
2dc1cbb5 370 top->log_avg_msec = cpu_to_le32(o->log_avg_msec);
e6989e10 371 top->log_max = cpu_to_le32(o->log_max);
d6c0b409 372 top->log_offset = cpu_to_le32(o->log_offset);
aee2ab67 373 top->log_gz = cpu_to_le32(o->log_gz);
b26317c9 374 top->log_gz_store = cpu_to_le32(o->log_gz_store);
2dc1cbb5
JA
375 top->norandommap = cpu_to_le32(o->norandommap);
376 top->softrandommap = cpu_to_le32(o->softrandommap);
377 top->bs_unaligned = cpu_to_le32(o->bs_unaligned);
378 top->fsync_on_close = cpu_to_le32(o->fsync_on_close);
6aca9b3d 379 top->bs_is_seq_rand = cpu_to_le32(o->bs_is_seq_rand);
1e5324e7 380 top->random_distribution = cpu_to_le32(o->random_distribution);
f9cafb12 381 top->exitall_error = cpu_to_le32(o->exitall_error);
1e5324e7
JA
382 top->zipf_theta.u.i = __cpu_to_le64(fio_double_to_uint64(o->zipf_theta.u.f));
383 top->pareto_h.u.i = __cpu_to_le64(fio_double_to_uint64(o->pareto_h.u.f));
f88cd222 384 top->gauss_dev.u.i = __cpu_to_le64(fio_double_to_uint64(o->gauss_dev.u.f));
49758e11 385 top->random_generator = cpu_to_le32(o->random_generator);
2dc1cbb5
JA
386 top->hugepage_size = cpu_to_le32(o->hugepage_size);
387 top->rw_min_bs = cpu_to_le32(o->rw_min_bs);
388 top->thinktime = cpu_to_le32(o->thinktime);
389 top->thinktime_spin = cpu_to_le32(o->thinktime_spin);
390 top->thinktime_blocks = cpu_to_le32(o->thinktime_blocks);
391 top->fsync_blocks = cpu_to_le32(o->fsync_blocks);
392 top->fdatasync_blocks = cpu_to_le32(o->fdatasync_blocks);
393 top->barrier_blocks = cpu_to_le32(o->barrier_blocks);
394 top->overwrite = cpu_to_le32(o->overwrite);
395 top->bw_avg_time = cpu_to_le32(o->bw_avg_time);
396 top->iops_avg_time = cpu_to_le32(o->iops_avg_time);
397 top->loops = cpu_to_le32(o->loops);
398 top->mem_type = cpu_to_le32(o->mem_type);
399 top->mem_align = cpu_to_le32(o->mem_align);
1e5324e7 400 top->max_latency = cpu_to_le32(o->max_latency);
2dc1cbb5
JA
401 top->stonewall = cpu_to_le32(o->stonewall);
402 top->new_group = cpu_to_le32(o->new_group);
403 top->numjobs = cpu_to_le32(o->numjobs);
c2acfbac 404 top->cpus_allowed_policy = cpu_to_le32(o->cpus_allowed_policy);
2dc1cbb5
JA
405 top->iolog = cpu_to_le32(o->iolog);
406 top->rwmixcycle = cpu_to_le32(o->rwmixcycle);
407 top->nice = cpu_to_le32(o->nice);
28727df7
JA
408 top->ioprio = cpu_to_le32(o->ioprio);
409 top->ioprio_class = cpu_to_le32(o->ioprio_class);
2dc1cbb5
JA
410 top->file_service_type = cpu_to_le32(o->file_service_type);
411 top->group_reporting = cpu_to_le32(o->group_reporting);
412 top->fadvise_hint = cpu_to_le32(o->fadvise_hint);
413 top->fallocate_mode = cpu_to_le32(o->fallocate_mode);
414 top->zero_buffers = cpu_to_le32(o->zero_buffers);
415 top->refill_buffers = cpu_to_le32(o->refill_buffers);
416 top->scramble_buffers = cpu_to_le32(o->scramble_buffers);
3c78a83f 417 top->buffer_pattern_bytes = cpu_to_le32(o->buffer_pattern_bytes);
2dc1cbb5
JA
418 top->time_based = cpu_to_le32(o->time_based);
419 top->disable_lat = cpu_to_le32(o->disable_lat);
420 top->disable_clat = cpu_to_le32(o->disable_clat);
421 top->disable_slat = cpu_to_le32(o->disable_slat);
422 top->disable_bw = cpu_to_le32(o->disable_bw);
95820b6e 423 top->unified_rw_rep = cpu_to_le32(o->unified_rw_rep);
2dc1cbb5
JA
424 top->gtod_reduce = cpu_to_le32(o->gtod_reduce);
425 top->gtod_cpu = cpu_to_le32(o->gtod_cpu);
2dc1cbb5
JA
426 top->clocksource = cpu_to_le32(o->clocksource);
427 top->no_stall = cpu_to_le32(o->no_stall);
428 top->trim_percentage = cpu_to_le32(o->trim_percentage);
429 top->trim_batch = cpu_to_le32(o->trim_batch);
430 top->trim_zero = cpu_to_le32(o->trim_zero);
431 top->clat_percentiles = cpu_to_le32(o->clat_percentiles);
9db01ef9 432 top->percentile_precision = cpu_to_le32(o->percentile_precision);
2dc1cbb5
JA
433 top->continue_on_error = cpu_to_le32(o->continue_on_error);
434 top->cgroup_weight = cpu_to_le32(o->cgroup_weight);
435 top->cgroup_nodelete = cpu_to_le32(o->cgroup_nodelete);
436 top->uid = cpu_to_le32(o->uid);
437 top->gid = cpu_to_le32(o->gid);
438 top->flow_id = __cpu_to_le32(o->flow_id);
439 top->flow = __cpu_to_le32(o->flow);
440 top->flow_watermark = __cpu_to_le32(o->flow_watermark);
441 top->flow_sleep = cpu_to_le32(o->flow_sleep);
442 top->sync_file_range = cpu_to_le32(o->sync_file_range);
3e260a46
JA
443 top->latency_target = __cpu_to_le64(o->latency_target);
444 top->latency_window = __cpu_to_le64(o->latency_window);
445 top->latency_percentile.u.i = __cpu_to_le64(fio_double_to_uint64(o->latency_percentile.u.f));
e476994e
JA
446 top->compress_percentage = cpu_to_le32(o->compress_percentage);
447 top->compress_chunk = cpu_to_le32(o->compress_chunk);
5c94b008 448 top->dedupe_percentage = cpu_to_le32(o->dedupe_percentage);
d77d8152
JA
449 top->block_error_hist = cpu_to_le32(o->block_error_hist);
450 top->skip_bad = cpu_to_le32(o->skip_bad);
0c63576e
JA
451 top->replay_align = cpu_to_le32(o->replay_align);
452 top->replay_scale = cpu_to_le32(o->replay_scale);
3a5db920 453 top->per_job_logs = cpu_to_le32(o->per_job_logs);
2dc1cbb5 454
b999b3c7 455 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
2dc1cbb5
JA
456 top->bs[i] = cpu_to_le32(o->bs[i]);
457 top->ba[i] = cpu_to_le32(o->ba[i]);
458 top->min_bs[i] = cpu_to_le32(o->min_bs[i]);
459 top->max_bs[i] = cpu_to_le32(o->max_bs[i]);
460 top->bssplit_nr[i] = cpu_to_le32(o->bssplit_nr[i]);
461
462 if (o->bssplit_nr[i]) {
463 unsigned int bssplit_nr = o->bssplit_nr[i];
464
465 if (bssplit_nr > BSSPLIT_MAX) {
466 log_err("fio: BSSPLIT_MAX is too small\n");
467 bssplit_nr = BSSPLIT_MAX;
468 }
469 for (j = 0; j < bssplit_nr; j++) {
470 top->bssplit[i][j].bs = cpu_to_le32(o->bssplit[i][j].bs);
471 top->bssplit[i][j].perc = cpu_to_le32(o->bssplit[i][j].perc);
472 }
473 }
474
e0a04ac1
JA
475 top->zone_split_nr[i] = cpu_to_le32(o->zone_split_nr[i]);
476
477 if (o->zone_split_nr[i]) {
478 unsigned int zone_split_nr = o->zone_split_nr[i];
479
480 if (zone_split_nr > ZONESPLIT_MAX) {
481 log_err("fio: ZONESPLIT_MAX is too small\n");
482 zone_split_nr = ZONESPLIT_MAX;
483 }
484 for (j = 0; j < zone_split_nr; j++) {
485 top->zone_split[i][j].access_perc = o->zone_split[i][j].access_perc;
486 top->zone_split[i][j].size_perc = o->zone_split[i][j].size_perc;
487 }
488 }
489
2dc1cbb5
JA
490 top->rwmix[i] = cpu_to_le32(o->rwmix[i]);
491 top->rate[i] = cpu_to_le32(o->rate[i]);
492 top->ratemin[i] = cpu_to_le32(o->ratemin[i]);
493 top->rate_iops[i] = cpu_to_le32(o->rate_iops[i]);
494 top->rate_iops_min[i] = cpu_to_le32(o->rate_iops_min[i]);
d9472271
JA
495
496 top->perc_rand[i] = cpu_to_le32(o->perc_rand[i]);
2dc1cbb5
JA
497 }
498
499 memcpy(top->verify_pattern, o->verify_pattern, MAX_PATTERN_SIZE);
3c78a83f 500 memcpy(top->buffer_pattern, o->buffer_pattern, MAX_PATTERN_SIZE);
2dc1cbb5
JA
501
502 top->size = __cpu_to_le64(o->size);
77731b29 503 top->io_limit = __cpu_to_le64(o->io_limit);
2dc1cbb5
JA
504 top->verify_backlog = __cpu_to_le64(o->verify_backlog);
505 top->start_delay = __cpu_to_le64(o->start_delay);
23ed19b0 506 top->start_delay_high = __cpu_to_le64(o->start_delay_high);
2dc1cbb5
JA
507 top->timeout = __cpu_to_le64(o->timeout);
508 top->ramp_time = __cpu_to_le64(o->ramp_time);
509 top->zone_range = __cpu_to_le64(o->zone_range);
510 top->zone_size = __cpu_to_le64(o->zone_size);
511 top->zone_skip = __cpu_to_le64(o->zone_skip);
ae278f9a 512 top->lockmem = __cpu_to_le64(o->lockmem);
2dc1cbb5
JA
513 top->ddir_seq_add = __cpu_to_le64(o->ddir_seq_add);
514 top->file_size_low = __cpu_to_le64(o->file_size_low);
515 top->file_size_high = __cpu_to_le64(o->file_size_high);
516 top->start_offset = __cpu_to_le64(o->start_offset);
517 top->trim_backlog = __cpu_to_le64(o->trim_backlog);
6a4cf74f 518 top->offset_increment = __cpu_to_le64(o->offset_increment);
ddf24e42 519 top->number_ios = __cpu_to_le64(o->number_ios);
6de65959 520 top->rate_process = cpu_to_le32(o->rate_process);
2dc1cbb5
JA
521
522 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
523 top->percentile_list[i].u.i = __cpu_to_le64(fio_double_to_uint64(o->percentile_list[i].u.f));
524#if 0
3c3ed070
JA
525 uint8_t cpumask[FIO_TOP_STR_MAX];
526 uint8_t verify_cpumask[FIO_TOP_STR_MAX];
c08f9fe2 527 uint8_t log_gz_cpumask[FIO_TOP_STR_MAX];
2dc1cbb5
JA
528#endif
529
530}
531
51167799
JA
532/*
533 * Basic conversion test. We'd really need to fill in more of the options
534 * to have a thorough test. Even better, we should auto-generate the
535 * converter functions...
536 */
537int fio_test_cconv(struct thread_options *__o)
538{
539 struct thread_options o;
540 struct thread_options_pack top1, top2;
541
542 memset(&top1, 0, sizeof(top1));
543 memset(&top2, 0, sizeof(top2));
544
545 convert_thread_options_to_net(&top1, __o);
546 memset(&o, 0, sizeof(o));
547 convert_thread_options_to_cpu(&o, &top1);
548 convert_thread_options_to_net(&top2, &o);
549
eb0c74ae
JA
550 free_thread_options_to_cpu(&o);
551
51167799
JA
552 return memcmp(&top1, &top2, sizeof(top1));
553}