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