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