blob: 357a7845e559fce6f43a46bb1a411368852d516e [file] [log] [blame]
Jens Axboe51167792012-03-08 21:34:18 +01001#include <string.h>
2
Jens Axboe2dc1cbb2012-03-08 14:52:25 +01003#include "thread_options.h"
4
5static void string_to_cpu(char **dst, const uint8_t *src)
6{
7 const char *__src = (const char *) src;
8
9 if (strlen(__src))
10 *dst = strdup(__src);
11}
12
13static void string_to_net(uint8_t *dst, const char *src)
14{
15 if (src)
16 strcpy((char *) dst, src);
17 else
18 dst[0] = '\0';
19}
20
Jens Axboeeb0c74a2014-02-11 10:33:06 -070021void free_thread_options_to_cpu(struct thread_options *o)
22{
23 free(o->description);
24 free(o->name);
25 free(o->directory);
26 free(o->filename);
27 free(o->filename_format);
28 free(o->opendir);
29 free(o->ioengine);
30 free(o->mmapfile);
31 free(o->read_iolog_file);
32 free(o->write_iolog_file);
33 free(o->bw_log_file);
34 free(o->lat_log_file);
35 free(o->iops_log_file);
36 free(o->replay_redirect);
37 free(o->exec_prerun);
38 free(o->exec_postrun);
39 free(o->ioscheduler);
40 free(o->profile);
41 free(o->cgroup);
42}
43
Jens Axboe2dc1cbb2012-03-08 14:52:25 +010044void convert_thread_options_to_cpu(struct thread_options *o,
45 struct thread_options_pack *top)
46{
47 int i, j;
48
49 string_to_cpu(&o->description, top->description);
50 string_to_cpu(&o->name, top->name);
51 string_to_cpu(&o->directory, top->directory);
52 string_to_cpu(&o->filename, top->filename);
Jens Axboe22f80452013-04-09 20:29:16 +020053 string_to_cpu(&o->filename_format, top->filename_format);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +010054 string_to_cpu(&o->opendir, top->opendir);
55 string_to_cpu(&o->ioengine, top->ioengine);
Jens Axboe83ea4222012-03-28 14:01:46 +020056 string_to_cpu(&o->mmapfile, top->mmapfile);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +010057 string_to_cpu(&o->read_iolog_file, top->read_iolog_file);
58 string_to_cpu(&o->write_iolog_file, top->write_iolog_file);
59 string_to_cpu(&o->bw_log_file, top->bw_log_file);
60 string_to_cpu(&o->lat_log_file, top->lat_log_file);
61 string_to_cpu(&o->iops_log_file, top->iops_log_file);
62 string_to_cpu(&o->replay_redirect, top->replay_redirect);
63 string_to_cpu(&o->exec_prerun, top->exec_prerun);
64 string_to_cpu(&o->exec_postrun, top->exec_postrun);
65 string_to_cpu(&o->ioscheduler, top->ioscheduler);
66 string_to_cpu(&o->profile, top->profile);
67 string_to_cpu(&o->cgroup, top->cgroup);
68
69 o->td_ddir = le32_to_cpu(top->td_ddir);
70 o->rw_seq = le32_to_cpu(top->rw_seq);
71 o->kb_base = le32_to_cpu(top->kb_base);
Jens Axboe22f80452013-04-09 20:29:16 +020072 o->unit_base = le32_to_cpu(top->kb_base);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +010073 o->ddir_seq_nr = le32_to_cpu(top->ddir_seq_nr);
74 o->ddir_seq_add = le64_to_cpu(top->ddir_seq_add);
75 o->iodepth = le32_to_cpu(top->iodepth);
76 o->iodepth_low = le32_to_cpu(top->iodepth_low);
77 o->iodepth_batch = le32_to_cpu(top->iodepth_batch);
78 o->iodepth_batch_complete = le32_to_cpu(top->iodepth_batch_complete);
79 o->size = le64_to_cpu(top->size);
80 o->size_percent = le32_to_cpu(top->size_percent);
81 o->fill_device = le32_to_cpu(top->fill_device);
82 o->file_size_low = le64_to_cpu(top->file_size_low);
83 o->file_size_high = le64_to_cpu(top->file_size_high);
84 o->start_offset = le64_to_cpu(top->start_offset);
85
Jens Axboeb999b3c2012-09-24 09:39:49 +020086 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
Jens Axboe2dc1cbb2012-03-08 14:52:25 +010087 o->bs[i] = le32_to_cpu(top->bs[i]);
88 o->ba[i] = le32_to_cpu(top->ba[i]);
89 o->min_bs[i] = le32_to_cpu(top->min_bs[i]);
90 o->max_bs[i] = le32_to_cpu(top->max_bs[i]);
91 o->bssplit_nr[i] = le32_to_cpu(top->bssplit_nr[i]);
92
93 if (o->bssplit_nr[i]) {
94 o->bssplit[i] = malloc(o->bssplit_nr[i] * sizeof(struct bssplit));
95 for (j = 0; j < o->bssplit_nr[i]; j++) {
96 o->bssplit[i][j].bs = le32_to_cpu(top->bssplit[i][j].bs);
97 o->bssplit[i][j].perc = le32_to_cpu(top->bssplit[i][j].perc);
98 }
99 }
100
101 o->rwmix[i] = le32_to_cpu(top->rwmix[i]);
102 o->rate[i] = le32_to_cpu(top->rate[i]);
103 o->ratemin[i] = le32_to_cpu(top->ratemin[i]);
104 o->rate_iops[i] = le32_to_cpu(top->rate_iops[i]);
105 o->rate_iops_min[i] = le32_to_cpu(top->rate_iops_min[i]);
Jens Axboed9472272013-07-25 10:20:45 -0600106
107 o->perc_rand[i] = le32_to_cpu(top->perc_rand[i]);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100108 }
109
110 o->ratecycle = le32_to_cpu(top->ratecycle);
111 o->nr_files = le32_to_cpu(top->nr_files);
112 o->open_files = le32_to_cpu(top->open_files);
113 o->file_lock_mode = le32_to_cpu(top->file_lock_mode);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100114 o->odirect = le32_to_cpu(top->odirect);
Chris Masond01612f2013-11-15 15:52:58 -0700115 o->oatomic = le32_to_cpu(top->oatomic);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100116 o->invalidate_cache = le32_to_cpu(top->invalidate_cache);
117 o->create_serialize = le32_to_cpu(top->create_serialize);
118 o->create_fsync = le32_to_cpu(top->create_fsync);
119 o->create_on_open = le32_to_cpu(top->create_on_open);
Jens Axboefb390e22012-05-07 09:54:41 +0200120 o->create_only = le32_to_cpu(top->create_only);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100121 o->end_fsync = le32_to_cpu(top->end_fsync);
122 o->pre_read = le32_to_cpu(top->pre_read);
123 o->sync_io = le32_to_cpu(top->sync_io);
124 o->verify = le32_to_cpu(top->verify);
125 o->do_verify = le32_to_cpu(top->do_verify);
126 o->verifysort = le32_to_cpu(top->verifysort);
Jens Axboe836fcc02013-01-24 09:08:45 -0700127 o->verifysort_nr = le32_to_cpu(top->verifysort_nr);
128 o->experimental_verify = le32_to_cpu(top->experimental_verify);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100129 o->verify_interval = le32_to_cpu(top->verify_interval);
130 o->verify_offset = le32_to_cpu(top->verify_offset);
131
132 memcpy(o->verify_pattern, top->verify_pattern, MAX_PATTERN_SIZE);
Jens Axboe3c78a832014-01-15 09:41:31 -0700133 memcpy(o->buffer_pattern, top->buffer_pattern, MAX_PATTERN_SIZE);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100134
135 o->verify_pattern_bytes = le32_to_cpu(top->verify_pattern_bytes);
136 o->verify_fatal = le32_to_cpu(top->verify_fatal);
137 o->verify_dump = le32_to_cpu(top->verify_dump);
138 o->verify_async = le32_to_cpu(top->verify_async);
139 o->verify_batch = le32_to_cpu(top->verify_batch);
140 o->use_thread = le32_to_cpu(top->use_thread);
141 o->unlink = le32_to_cpu(top->unlink);
142 o->do_disk_util = le32_to_cpu(top->do_disk_util);
143 o->override_sync = le32_to_cpu(top->override_sync);
144 o->rand_repeatable = le32_to_cpu(top->rand_repeatable);
Christian Ehrhardt56e2a5f2014-02-20 09:10:17 -0800145 o->allrand_repeatable = le32_to_cpu(top->allrand_repeatable);
Grant Grundler363cffa2014-01-28 15:11:23 -0700146 o->rand_seed = le64_to_cpu(top->rand_seed);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100147 o->use_os_rand = le32_to_cpu(top->use_os_rand);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100148 o->log_avg_msec = le32_to_cpu(top->log_avg_msec);
149 o->norandommap = le32_to_cpu(top->norandommap);
150 o->softrandommap = le32_to_cpu(top->softrandommap);
151 o->bs_unaligned = le32_to_cpu(top->bs_unaligned);
152 o->fsync_on_close = le32_to_cpu(top->fsync_on_close);
Jens Axboe6aca9b32013-07-25 12:45:26 -0600153 o->bs_is_seq_rand = le32_to_cpu(top->bs_is_seq_rand);
Jens Axboe1e5324e2012-11-14 14:25:31 -0700154 o->random_distribution = le32_to_cpu(top->random_distribution);
155 o->zipf_theta.u.f = fio_uint64_to_double(le64_to_cpu(top->zipf_theta.u.i));
156 o->pareto_h.u.f = fio_uint64_to_double(le64_to_cpu(top->pareto_h.u.i));
Jens Axboe49758e12012-12-03 14:37:23 +0100157 o->random_generator = le32_to_cpu(top->random_generator);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100158 o->hugepage_size = le32_to_cpu(top->hugepage_size);
159 o->rw_min_bs = le32_to_cpu(top->rw_min_bs);
160 o->thinktime = le32_to_cpu(top->thinktime);
161 o->thinktime_spin = le32_to_cpu(top->thinktime_spin);
162 o->thinktime_blocks = le32_to_cpu(top->thinktime_blocks);
163 o->fsync_blocks = le32_to_cpu(top->fsync_blocks);
164 o->fdatasync_blocks = le32_to_cpu(top->fdatasync_blocks);
165 o->barrier_blocks = le32_to_cpu(top->barrier_blocks);
166
167 o->verify_backlog = le64_to_cpu(top->verify_backlog);
168 o->start_delay = le64_to_cpu(top->start_delay);
Christian Ehrhardt23ed19b2014-02-20 09:07:02 -0800169 o->start_delay_high = le64_to_cpu(top->start_delay_high);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100170 o->timeout = le64_to_cpu(top->timeout);
171 o->ramp_time = le64_to_cpu(top->ramp_time);
172 o->zone_range = le64_to_cpu(top->zone_range);
173 o->zone_size = le64_to_cpu(top->zone_size);
174 o->zone_skip = le64_to_cpu(top->zone_skip);
Jens Axboeae278f92012-03-28 20:52:55 +0200175 o->lockmem = le64_to_cpu(top->lockmem);
Jens Axboe6a4cf742012-03-16 14:02:54 +0100176 o->offset_increment = le64_to_cpu(top->offset_increment);
Jens Axboeddf24e42013-08-09 12:53:44 -0600177 o->number_ios = le64_to_cpu(top->number_ios);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100178
179 o->overwrite = le32_to_cpu(top->overwrite);
180 o->bw_avg_time = le32_to_cpu(top->bw_avg_time);
181 o->iops_avg_time = le32_to_cpu(top->iops_avg_time);
182 o->loops = le32_to_cpu(top->loops);
183 o->mem_type = le32_to_cpu(top->mem_type);
184 o->mem_align = le32_to_cpu(top->mem_align);
Jens Axboe1e5324e2012-11-14 14:25:31 -0700185 o->max_latency = le32_to_cpu(top->max_latency);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100186 o->stonewall = le32_to_cpu(top->stonewall);
187 o->new_group = le32_to_cpu(top->new_group);
188 o->numjobs = le32_to_cpu(top->numjobs);
189 o->cpumask_set = le32_to_cpu(top->cpumask_set);
190 o->verify_cpumask_set = le32_to_cpu(top->verify_cpumask_set);
Jens Axboec2acfba2014-02-27 15:52:02 -0800191 o->cpus_allowed_policy = le32_to_cpu(top->cpus_allowed_policy);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100192 o->iolog = le32_to_cpu(top->iolog);
193 o->rwmixcycle = le32_to_cpu(top->rwmixcycle);
194 o->nice = le32_to_cpu(top->nice);
Jens Axboe28727df2012-03-29 08:33:15 +0200195 o->ioprio = le32_to_cpu(top->ioprio);
196 o->ioprio_class = le32_to_cpu(top->ioprio_class);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100197 o->file_service_type = le32_to_cpu(top->file_service_type);
198 o->group_reporting = le32_to_cpu(top->group_reporting);
199 o->fadvise_hint = le32_to_cpu(top->fadvise_hint);
200 o->fallocate_mode = le32_to_cpu(top->fallocate_mode);
201 o->zero_buffers = le32_to_cpu(top->zero_buffers);
202 o->refill_buffers = le32_to_cpu(top->refill_buffers);
203 o->scramble_buffers = le32_to_cpu(top->scramble_buffers);
Jens Axboe3c78a832014-01-15 09:41:31 -0700204 o->buffer_pattern_bytes = le32_to_cpu(top->buffer_pattern_bytes);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100205 o->time_based = le32_to_cpu(top->time_based);
206 o->disable_lat = le32_to_cpu(top->disable_lat);
207 o->disable_clat = le32_to_cpu(top->disable_clat);
208 o->disable_slat = le32_to_cpu(top->disable_slat);
209 o->disable_bw = le32_to_cpu(top->disable_bw);
Jens Axboe95820b62013-01-31 13:23:40 +0100210 o->unified_rw_rep = le32_to_cpu(top->unified_rw_rep);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100211 o->gtod_reduce = le32_to_cpu(top->gtod_reduce);
212 o->gtod_cpu = le32_to_cpu(top->gtod_cpu);
213 o->gtod_offload = le32_to_cpu(top->gtod_offload);
214 o->clocksource = le32_to_cpu(top->clocksource);
215 o->no_stall = le32_to_cpu(top->no_stall);
216 o->trim_percentage = le32_to_cpu(top->trim_percentage);
217 o->trim_batch = le32_to_cpu(top->trim_batch);
218 o->trim_zero = le32_to_cpu(top->trim_zero);
219 o->clat_percentiles = le32_to_cpu(top->clat_percentiles);
Jens Axboe9db01ef2013-02-07 15:45:39 +0100220 o->percentile_precision = le32_to_cpu(top->percentile_precision);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100221 o->continue_on_error = le32_to_cpu(top->continue_on_error);
222 o->cgroup_weight = le32_to_cpu(top->cgroup_weight);
223 o->cgroup_nodelete = le32_to_cpu(top->cgroup_nodelete);
224 o->uid = le32_to_cpu(top->uid);
225 o->gid = le32_to_cpu(top->gid);
226 o->flow_id = __le32_to_cpu(top->flow_id);
227 o->flow = __le32_to_cpu(top->flow);
228 o->flow_watermark = __le32_to_cpu(top->flow_watermark);
229 o->flow_sleep = le32_to_cpu(top->flow_sleep);
230 o->sync_file_range = le32_to_cpu(top->sync_file_range);
Jens Axboe3e260a42013-12-09 12:38:53 -0700231 o->latency_target = le64_to_cpu(top->latency_target);
232 o->latency_window = le64_to_cpu(top->latency_window);
233 o->latency_percentile.u.f = fio_uint64_to_double(le64_to_cpu(top->latency_percentile.u.i));
Jens Axboee4769942012-03-13 14:01:11 +0100234 o->compress_percentage = le32_to_cpu(top->compress_percentage);
235 o->compress_chunk = le32_to_cpu(top->compress_chunk);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100236
237 o->trim_backlog = le64_to_cpu(top->trim_backlog);
238
239 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
240 o->percentile_list[i].u.f = fio_uint64_to_double(le64_to_cpu(top->percentile_list[i].u.i));
241#if 0
Jens Axboe3c3ed072012-03-27 09:12:39 +0200242 uint8_t cpumask[FIO_TOP_STR_MAX];
243 uint8_t verify_cpumask[FIO_TOP_STR_MAX];
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100244#endif
245}
246
247void convert_thread_options_to_net(struct thread_options_pack *top,
248 struct thread_options *o)
249{
250 int i, j;
251
252 string_to_net(top->description, o->description);
253 string_to_net(top->name, o->name);
254 string_to_net(top->directory, o->directory);
255 string_to_net(top->filename, o->filename);
Jens Axboe22f80452013-04-09 20:29:16 +0200256 string_to_net(top->filename_format, o->filename_format);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100257 string_to_net(top->opendir, o->opendir);
258 string_to_net(top->ioengine, o->ioengine);
Jens Axboe83ea4222012-03-28 14:01:46 +0200259 string_to_net(top->mmapfile, o->mmapfile);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100260 string_to_net(top->read_iolog_file, o->read_iolog_file);
261 string_to_net(top->write_iolog_file, o->write_iolog_file);
262 string_to_net(top->bw_log_file, o->bw_log_file);
263 string_to_net(top->lat_log_file, o->lat_log_file);
264 string_to_net(top->iops_log_file, o->iops_log_file);
265 string_to_net(top->replay_redirect, o->replay_redirect);
266 string_to_net(top->exec_prerun, o->exec_prerun);
267 string_to_net(top->exec_postrun, o->exec_postrun);
268 string_to_net(top->ioscheduler, o->ioscheduler);
269 string_to_net(top->profile, o->profile);
270 string_to_net(top->cgroup, o->cgroup);
271
272 top->td_ddir = cpu_to_le32(o->td_ddir);
273 top->rw_seq = cpu_to_le32(o->rw_seq);
274 top->kb_base = cpu_to_le32(o->kb_base);
Jens Axboe22f80452013-04-09 20:29:16 +0200275 top->unit_base = cpu_to_le32(o->kb_base);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100276 top->ddir_seq_nr = cpu_to_le32(o->ddir_seq_nr);
277 top->iodepth = cpu_to_le32(o->iodepth);
278 top->iodepth_low = cpu_to_le32(o->iodepth_low);
279 top->iodepth_batch = cpu_to_le32(o->iodepth_batch);
280 top->iodepth_batch_complete = cpu_to_le32(o->iodepth_batch_complete);
281 top->size_percent = cpu_to_le32(o->size_percent);
282 top->fill_device = cpu_to_le32(o->fill_device);
283 top->ratecycle = cpu_to_le32(o->ratecycle);
284 top->nr_files = cpu_to_le32(o->nr_files);
285 top->open_files = cpu_to_le32(o->open_files);
286 top->file_lock_mode = cpu_to_le32(o->file_lock_mode);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100287 top->odirect = cpu_to_le32(o->odirect);
Chris Masond01612f2013-11-15 15:52:58 -0700288 top->oatomic = cpu_to_le32(o->oatomic);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100289 top->invalidate_cache = cpu_to_le32(o->invalidate_cache);
290 top->create_serialize = cpu_to_le32(o->create_serialize);
291 top->create_fsync = cpu_to_le32(o->create_fsync);
292 top->create_on_open = cpu_to_le32(o->create_on_open);
Jens Axboefb390e22012-05-07 09:54:41 +0200293 top->create_only = cpu_to_le32(o->create_only);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100294 top->end_fsync = cpu_to_le32(o->end_fsync);
295 top->pre_read = cpu_to_le32(o->pre_read);
296 top->sync_io = cpu_to_le32(o->sync_io);
297 top->verify = cpu_to_le32(o->verify);
298 top->do_verify = cpu_to_le32(o->do_verify);
299 top->verifysort = cpu_to_le32(o->verifysort);
Jens Axboe836fcc02013-01-24 09:08:45 -0700300 top->verifysort_nr = cpu_to_le32(o->verifysort_nr);
301 top->experimental_verify = cpu_to_le32(o->experimental_verify);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100302 top->verify_interval = cpu_to_le32(o->verify_interval);
303 top->verify_offset = cpu_to_le32(o->verify_offset);
304 top->verify_pattern_bytes = cpu_to_le32(o->verify_pattern_bytes);
305 top->verify_fatal = cpu_to_le32(o->verify_fatal);
306 top->verify_dump = cpu_to_le32(o->verify_dump);
307 top->verify_async = cpu_to_le32(o->verify_async);
308 top->verify_batch = cpu_to_le32(o->verify_batch);
309 top->use_thread = cpu_to_le32(o->use_thread);
310 top->unlink = cpu_to_le32(o->unlink);
311 top->do_disk_util = cpu_to_le32(o->do_disk_util);
312 top->override_sync = cpu_to_le32(o->override_sync);
313 top->rand_repeatable = cpu_to_le32(o->rand_repeatable);
Christian Ehrhardt56e2a5f2014-02-20 09:10:17 -0800314 top->allrand_repeatable = cpu_to_le32(o->allrand_repeatable);
Grant Grundler363cffa2014-01-28 15:11:23 -0700315 top->rand_seed = __cpu_to_le64(o->rand_seed);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100316 top->use_os_rand = cpu_to_le32(o->use_os_rand);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100317 top->log_avg_msec = cpu_to_le32(o->log_avg_msec);
318 top->norandommap = cpu_to_le32(o->norandommap);
319 top->softrandommap = cpu_to_le32(o->softrandommap);
320 top->bs_unaligned = cpu_to_le32(o->bs_unaligned);
321 top->fsync_on_close = cpu_to_le32(o->fsync_on_close);
Jens Axboe6aca9b32013-07-25 12:45:26 -0600322 top->bs_is_seq_rand = cpu_to_le32(o->bs_is_seq_rand);
Jens Axboe1e5324e2012-11-14 14:25:31 -0700323 top->random_distribution = cpu_to_le32(o->random_distribution);
324 top->zipf_theta.u.i = __cpu_to_le64(fio_double_to_uint64(o->zipf_theta.u.f));
325 top->pareto_h.u.i = __cpu_to_le64(fio_double_to_uint64(o->pareto_h.u.f));
Jens Axboe49758e12012-12-03 14:37:23 +0100326 top->random_generator = cpu_to_le32(o->random_generator);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100327 top->hugepage_size = cpu_to_le32(o->hugepage_size);
328 top->rw_min_bs = cpu_to_le32(o->rw_min_bs);
329 top->thinktime = cpu_to_le32(o->thinktime);
330 top->thinktime_spin = cpu_to_le32(o->thinktime_spin);
331 top->thinktime_blocks = cpu_to_le32(o->thinktime_blocks);
332 top->fsync_blocks = cpu_to_le32(o->fsync_blocks);
333 top->fdatasync_blocks = cpu_to_le32(o->fdatasync_blocks);
334 top->barrier_blocks = cpu_to_le32(o->barrier_blocks);
335 top->overwrite = cpu_to_le32(o->overwrite);
336 top->bw_avg_time = cpu_to_le32(o->bw_avg_time);
337 top->iops_avg_time = cpu_to_le32(o->iops_avg_time);
338 top->loops = cpu_to_le32(o->loops);
339 top->mem_type = cpu_to_le32(o->mem_type);
340 top->mem_align = cpu_to_le32(o->mem_align);
Jens Axboe1e5324e2012-11-14 14:25:31 -0700341 top->max_latency = cpu_to_le32(o->max_latency);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100342 top->stonewall = cpu_to_le32(o->stonewall);
343 top->new_group = cpu_to_le32(o->new_group);
344 top->numjobs = cpu_to_le32(o->numjobs);
345 top->cpumask_set = cpu_to_le32(o->cpumask_set);
346 top->verify_cpumask_set = cpu_to_le32(o->verify_cpumask_set);
Jens Axboec2acfba2014-02-27 15:52:02 -0800347 top->cpus_allowed_policy = cpu_to_le32(o->cpus_allowed_policy);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100348 top->iolog = cpu_to_le32(o->iolog);
349 top->rwmixcycle = cpu_to_le32(o->rwmixcycle);
350 top->nice = cpu_to_le32(o->nice);
Jens Axboe28727df2012-03-29 08:33:15 +0200351 top->ioprio = cpu_to_le32(o->ioprio);
352 top->ioprio_class = cpu_to_le32(o->ioprio_class);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100353 top->file_service_type = cpu_to_le32(o->file_service_type);
354 top->group_reporting = cpu_to_le32(o->group_reporting);
355 top->fadvise_hint = cpu_to_le32(o->fadvise_hint);
356 top->fallocate_mode = cpu_to_le32(o->fallocate_mode);
357 top->zero_buffers = cpu_to_le32(o->zero_buffers);
358 top->refill_buffers = cpu_to_le32(o->refill_buffers);
359 top->scramble_buffers = cpu_to_le32(o->scramble_buffers);
Jens Axboe3c78a832014-01-15 09:41:31 -0700360 top->buffer_pattern_bytes = cpu_to_le32(o->buffer_pattern_bytes);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100361 top->time_based = cpu_to_le32(o->time_based);
362 top->disable_lat = cpu_to_le32(o->disable_lat);
363 top->disable_clat = cpu_to_le32(o->disable_clat);
364 top->disable_slat = cpu_to_le32(o->disable_slat);
365 top->disable_bw = cpu_to_le32(o->disable_bw);
Jens Axboe95820b62013-01-31 13:23:40 +0100366 top->unified_rw_rep = cpu_to_le32(o->unified_rw_rep);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100367 top->gtod_reduce = cpu_to_le32(o->gtod_reduce);
368 top->gtod_cpu = cpu_to_le32(o->gtod_cpu);
369 top->gtod_offload = cpu_to_le32(o->gtod_offload);
370 top->clocksource = cpu_to_le32(o->clocksource);
371 top->no_stall = cpu_to_le32(o->no_stall);
372 top->trim_percentage = cpu_to_le32(o->trim_percentage);
373 top->trim_batch = cpu_to_le32(o->trim_batch);
374 top->trim_zero = cpu_to_le32(o->trim_zero);
375 top->clat_percentiles = cpu_to_le32(o->clat_percentiles);
Jens Axboe9db01ef2013-02-07 15:45:39 +0100376 top->percentile_precision = cpu_to_le32(o->percentile_precision);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100377 top->continue_on_error = cpu_to_le32(o->continue_on_error);
378 top->cgroup_weight = cpu_to_le32(o->cgroup_weight);
379 top->cgroup_nodelete = cpu_to_le32(o->cgroup_nodelete);
380 top->uid = cpu_to_le32(o->uid);
381 top->gid = cpu_to_le32(o->gid);
382 top->flow_id = __cpu_to_le32(o->flow_id);
383 top->flow = __cpu_to_le32(o->flow);
384 top->flow_watermark = __cpu_to_le32(o->flow_watermark);
385 top->flow_sleep = cpu_to_le32(o->flow_sleep);
386 top->sync_file_range = cpu_to_le32(o->sync_file_range);
Jens Axboe3e260a42013-12-09 12:38:53 -0700387 top->latency_target = __cpu_to_le64(o->latency_target);
388 top->latency_window = __cpu_to_le64(o->latency_window);
389 top->latency_percentile.u.i = __cpu_to_le64(fio_double_to_uint64(o->latency_percentile.u.f));
Jens Axboee4769942012-03-13 14:01:11 +0100390 top->compress_percentage = cpu_to_le32(o->compress_percentage);
391 top->compress_chunk = cpu_to_le32(o->compress_chunk);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100392
Jens Axboeb999b3c2012-09-24 09:39:49 +0200393 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100394 top->bs[i] = cpu_to_le32(o->bs[i]);
395 top->ba[i] = cpu_to_le32(o->ba[i]);
396 top->min_bs[i] = cpu_to_le32(o->min_bs[i]);
397 top->max_bs[i] = cpu_to_le32(o->max_bs[i]);
398 top->bssplit_nr[i] = cpu_to_le32(o->bssplit_nr[i]);
399
400 if (o->bssplit_nr[i]) {
401 unsigned int bssplit_nr = o->bssplit_nr[i];
402
403 if (bssplit_nr > BSSPLIT_MAX) {
404 log_err("fio: BSSPLIT_MAX is too small\n");
405 bssplit_nr = BSSPLIT_MAX;
406 }
407 for (j = 0; j < bssplit_nr; j++) {
408 top->bssplit[i][j].bs = cpu_to_le32(o->bssplit[i][j].bs);
409 top->bssplit[i][j].perc = cpu_to_le32(o->bssplit[i][j].perc);
410 }
411 }
412
413 top->rwmix[i] = cpu_to_le32(o->rwmix[i]);
414 top->rate[i] = cpu_to_le32(o->rate[i]);
415 top->ratemin[i] = cpu_to_le32(o->ratemin[i]);
416 top->rate_iops[i] = cpu_to_le32(o->rate_iops[i]);
417 top->rate_iops_min[i] = cpu_to_le32(o->rate_iops_min[i]);
Jens Axboed9472272013-07-25 10:20:45 -0600418
419 top->perc_rand[i] = cpu_to_le32(o->perc_rand[i]);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100420 }
421
422 memcpy(top->verify_pattern, o->verify_pattern, MAX_PATTERN_SIZE);
Jens Axboe3c78a832014-01-15 09:41:31 -0700423 memcpy(top->buffer_pattern, o->buffer_pattern, MAX_PATTERN_SIZE);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100424
425 top->size = __cpu_to_le64(o->size);
426 top->verify_backlog = __cpu_to_le64(o->verify_backlog);
427 top->start_delay = __cpu_to_le64(o->start_delay);
Christian Ehrhardt23ed19b2014-02-20 09:07:02 -0800428 top->start_delay_high = __cpu_to_le64(o->start_delay_high);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100429 top->timeout = __cpu_to_le64(o->timeout);
430 top->ramp_time = __cpu_to_le64(o->ramp_time);
431 top->zone_range = __cpu_to_le64(o->zone_range);
432 top->zone_size = __cpu_to_le64(o->zone_size);
433 top->zone_skip = __cpu_to_le64(o->zone_skip);
Jens Axboeae278f92012-03-28 20:52:55 +0200434 top->lockmem = __cpu_to_le64(o->lockmem);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100435 top->ddir_seq_add = __cpu_to_le64(o->ddir_seq_add);
436 top->file_size_low = __cpu_to_le64(o->file_size_low);
437 top->file_size_high = __cpu_to_le64(o->file_size_high);
438 top->start_offset = __cpu_to_le64(o->start_offset);
439 top->trim_backlog = __cpu_to_le64(o->trim_backlog);
Jens Axboe6a4cf742012-03-16 14:02:54 +0100440 top->offset_increment = __cpu_to_le64(o->offset_increment);
Jens Axboeddf24e42013-08-09 12:53:44 -0600441 top->number_ios = __cpu_to_le64(o->number_ios);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100442
443 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
444 top->percentile_list[i].u.i = __cpu_to_le64(fio_double_to_uint64(o->percentile_list[i].u.f));
445#if 0
Jens Axboe3c3ed072012-03-27 09:12:39 +0200446 uint8_t cpumask[FIO_TOP_STR_MAX];
447 uint8_t verify_cpumask[FIO_TOP_STR_MAX];
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100448#endif
449
450}
451
Jens Axboe51167792012-03-08 21:34:18 +0100452/*
453 * Basic conversion test. We'd really need to fill in more of the options
454 * to have a thorough test. Even better, we should auto-generate the
455 * converter functions...
456 */
457int fio_test_cconv(struct thread_options *__o)
458{
459 struct thread_options o;
460 struct thread_options_pack top1, top2;
461
462 memset(&top1, 0, sizeof(top1));
463 memset(&top2, 0, sizeof(top2));
464
465 convert_thread_options_to_net(&top1, __o);
466 memset(&o, 0, sizeof(o));
467 convert_thread_options_to_cpu(&o, &top1);
468 convert_thread_options_to_net(&top2, &o);
469
Jens Axboeeb0c74a2014-02-11 10:33:06 -0700470 free_thread_options_to_cpu(&o);
471
Jens Axboe51167792012-03-08 21:34:18 +0100472 return memcmp(&top1, &top2, sizeof(top1));
473}