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