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