blob: fd8d0ad85142568b2d142948ea4b5f638f03b03f [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);
191 o->iolog = le32_to_cpu(top->iolog);
192 o->rwmixcycle = le32_to_cpu(top->rwmixcycle);
193 o->nice = le32_to_cpu(top->nice);
Jens Axboe28727df2012-03-29 08:33:15 +0200194 o->ioprio = le32_to_cpu(top->ioprio);
195 o->ioprio_class = le32_to_cpu(top->ioprio_class);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100196 o->file_service_type = le32_to_cpu(top->file_service_type);
197 o->group_reporting = le32_to_cpu(top->group_reporting);
198 o->fadvise_hint = le32_to_cpu(top->fadvise_hint);
199 o->fallocate_mode = le32_to_cpu(top->fallocate_mode);
200 o->zero_buffers = le32_to_cpu(top->zero_buffers);
201 o->refill_buffers = le32_to_cpu(top->refill_buffers);
202 o->scramble_buffers = le32_to_cpu(top->scramble_buffers);
Jens Axboe3c78a832014-01-15 09:41:31 -0700203 o->buffer_pattern_bytes = le32_to_cpu(top->buffer_pattern_bytes);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100204 o->time_based = le32_to_cpu(top->time_based);
205 o->disable_lat = le32_to_cpu(top->disable_lat);
206 o->disable_clat = le32_to_cpu(top->disable_clat);
207 o->disable_slat = le32_to_cpu(top->disable_slat);
208 o->disable_bw = le32_to_cpu(top->disable_bw);
Jens Axboe95820b62013-01-31 13:23:40 +0100209 o->unified_rw_rep = le32_to_cpu(top->unified_rw_rep);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100210 o->gtod_reduce = le32_to_cpu(top->gtod_reduce);
211 o->gtod_cpu = le32_to_cpu(top->gtod_cpu);
212 o->gtod_offload = le32_to_cpu(top->gtod_offload);
213 o->clocksource = le32_to_cpu(top->clocksource);
214 o->no_stall = le32_to_cpu(top->no_stall);
215 o->trim_percentage = le32_to_cpu(top->trim_percentage);
216 o->trim_batch = le32_to_cpu(top->trim_batch);
217 o->trim_zero = le32_to_cpu(top->trim_zero);
218 o->clat_percentiles = le32_to_cpu(top->clat_percentiles);
Jens Axboe9db01ef2013-02-07 15:45:39 +0100219 o->percentile_precision = le32_to_cpu(top->percentile_precision);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100220 o->continue_on_error = le32_to_cpu(top->continue_on_error);
221 o->cgroup_weight = le32_to_cpu(top->cgroup_weight);
222 o->cgroup_nodelete = le32_to_cpu(top->cgroup_nodelete);
223 o->uid = le32_to_cpu(top->uid);
224 o->gid = le32_to_cpu(top->gid);
225 o->flow_id = __le32_to_cpu(top->flow_id);
226 o->flow = __le32_to_cpu(top->flow);
227 o->flow_watermark = __le32_to_cpu(top->flow_watermark);
228 o->flow_sleep = le32_to_cpu(top->flow_sleep);
229 o->sync_file_range = le32_to_cpu(top->sync_file_range);
Jens Axboe3e260a42013-12-09 12:38:53 -0700230 o->latency_target = le64_to_cpu(top->latency_target);
231 o->latency_window = le64_to_cpu(top->latency_window);
232 o->latency_percentile.u.f = fio_uint64_to_double(le64_to_cpu(top->latency_percentile.u.i));
Jens Axboee4769942012-03-13 14:01:11 +0100233 o->compress_percentage = le32_to_cpu(top->compress_percentage);
234 o->compress_chunk = le32_to_cpu(top->compress_chunk);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100235
236 o->trim_backlog = le64_to_cpu(top->trim_backlog);
237
238 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
239 o->percentile_list[i].u.f = fio_uint64_to_double(le64_to_cpu(top->percentile_list[i].u.i));
240#if 0
Jens Axboe3c3ed072012-03-27 09:12:39 +0200241 uint8_t cpumask[FIO_TOP_STR_MAX];
242 uint8_t verify_cpumask[FIO_TOP_STR_MAX];
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100243#endif
244}
245
246void convert_thread_options_to_net(struct thread_options_pack *top,
247 struct thread_options *o)
248{
249 int i, j;
250
251 string_to_net(top->description, o->description);
252 string_to_net(top->name, o->name);
253 string_to_net(top->directory, o->directory);
254 string_to_net(top->filename, o->filename);
Jens Axboe22f80452013-04-09 20:29:16 +0200255 string_to_net(top->filename_format, o->filename_format);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100256 string_to_net(top->opendir, o->opendir);
257 string_to_net(top->ioengine, o->ioengine);
Jens Axboe83ea4222012-03-28 14:01:46 +0200258 string_to_net(top->mmapfile, o->mmapfile);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100259 string_to_net(top->read_iolog_file, o->read_iolog_file);
260 string_to_net(top->write_iolog_file, o->write_iolog_file);
261 string_to_net(top->bw_log_file, o->bw_log_file);
262 string_to_net(top->lat_log_file, o->lat_log_file);
263 string_to_net(top->iops_log_file, o->iops_log_file);
264 string_to_net(top->replay_redirect, o->replay_redirect);
265 string_to_net(top->exec_prerun, o->exec_prerun);
266 string_to_net(top->exec_postrun, o->exec_postrun);
267 string_to_net(top->ioscheduler, o->ioscheduler);
268 string_to_net(top->profile, o->profile);
269 string_to_net(top->cgroup, o->cgroup);
270
271 top->td_ddir = cpu_to_le32(o->td_ddir);
272 top->rw_seq = cpu_to_le32(o->rw_seq);
273 top->kb_base = cpu_to_le32(o->kb_base);
Jens Axboe22f80452013-04-09 20:29:16 +0200274 top->unit_base = cpu_to_le32(o->kb_base);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100275 top->ddir_seq_nr = cpu_to_le32(o->ddir_seq_nr);
276 top->iodepth = cpu_to_le32(o->iodepth);
277 top->iodepth_low = cpu_to_le32(o->iodepth_low);
278 top->iodepth_batch = cpu_to_le32(o->iodepth_batch);
279 top->iodepth_batch_complete = cpu_to_le32(o->iodepth_batch_complete);
280 top->size_percent = cpu_to_le32(o->size_percent);
281 top->fill_device = cpu_to_le32(o->fill_device);
282 top->ratecycle = cpu_to_le32(o->ratecycle);
283 top->nr_files = cpu_to_le32(o->nr_files);
284 top->open_files = cpu_to_le32(o->open_files);
285 top->file_lock_mode = cpu_to_le32(o->file_lock_mode);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100286 top->odirect = cpu_to_le32(o->odirect);
Chris Masond01612f2013-11-15 15:52:58 -0700287 top->oatomic = cpu_to_le32(o->oatomic);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100288 top->invalidate_cache = cpu_to_le32(o->invalidate_cache);
289 top->create_serialize = cpu_to_le32(o->create_serialize);
290 top->create_fsync = cpu_to_le32(o->create_fsync);
291 top->create_on_open = cpu_to_le32(o->create_on_open);
Jens Axboefb390e22012-05-07 09:54:41 +0200292 top->create_only = cpu_to_le32(o->create_only);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100293 top->end_fsync = cpu_to_le32(o->end_fsync);
294 top->pre_read = cpu_to_le32(o->pre_read);
295 top->sync_io = cpu_to_le32(o->sync_io);
296 top->verify = cpu_to_le32(o->verify);
297 top->do_verify = cpu_to_le32(o->do_verify);
298 top->verifysort = cpu_to_le32(o->verifysort);
Jens Axboe836fcc02013-01-24 09:08:45 -0700299 top->verifysort_nr = cpu_to_le32(o->verifysort_nr);
300 top->experimental_verify = cpu_to_le32(o->experimental_verify);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100301 top->verify_interval = cpu_to_le32(o->verify_interval);
302 top->verify_offset = cpu_to_le32(o->verify_offset);
303 top->verify_pattern_bytes = cpu_to_le32(o->verify_pattern_bytes);
304 top->verify_fatal = cpu_to_le32(o->verify_fatal);
305 top->verify_dump = cpu_to_le32(o->verify_dump);
306 top->verify_async = cpu_to_le32(o->verify_async);
307 top->verify_batch = cpu_to_le32(o->verify_batch);
308 top->use_thread = cpu_to_le32(o->use_thread);
309 top->unlink = cpu_to_le32(o->unlink);
310 top->do_disk_util = cpu_to_le32(o->do_disk_util);
311 top->override_sync = cpu_to_le32(o->override_sync);
312 top->rand_repeatable = cpu_to_le32(o->rand_repeatable);
Christian Ehrhardt56e2a5f2014-02-20 09:10:17 -0800313 top->allrand_repeatable = cpu_to_le32(o->allrand_repeatable);
Grant Grundler363cffa2014-01-28 15:11:23 -0700314 top->rand_seed = __cpu_to_le64(o->rand_seed);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100315 top->use_os_rand = cpu_to_le32(o->use_os_rand);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100316 top->log_avg_msec = cpu_to_le32(o->log_avg_msec);
317 top->norandommap = cpu_to_le32(o->norandommap);
318 top->softrandommap = cpu_to_le32(o->softrandommap);
319 top->bs_unaligned = cpu_to_le32(o->bs_unaligned);
320 top->fsync_on_close = cpu_to_le32(o->fsync_on_close);
Jens Axboe6aca9b32013-07-25 12:45:26 -0600321 top->bs_is_seq_rand = cpu_to_le32(o->bs_is_seq_rand);
Jens Axboe1e5324e2012-11-14 14:25:31 -0700322 top->random_distribution = cpu_to_le32(o->random_distribution);
323 top->zipf_theta.u.i = __cpu_to_le64(fio_double_to_uint64(o->zipf_theta.u.f));
324 top->pareto_h.u.i = __cpu_to_le64(fio_double_to_uint64(o->pareto_h.u.f));
Jens Axboe49758e12012-12-03 14:37:23 +0100325 top->random_generator = cpu_to_le32(o->random_generator);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100326 top->hugepage_size = cpu_to_le32(o->hugepage_size);
327 top->rw_min_bs = cpu_to_le32(o->rw_min_bs);
328 top->thinktime = cpu_to_le32(o->thinktime);
329 top->thinktime_spin = cpu_to_le32(o->thinktime_spin);
330 top->thinktime_blocks = cpu_to_le32(o->thinktime_blocks);
331 top->fsync_blocks = cpu_to_le32(o->fsync_blocks);
332 top->fdatasync_blocks = cpu_to_le32(o->fdatasync_blocks);
333 top->barrier_blocks = cpu_to_le32(o->barrier_blocks);
334 top->overwrite = cpu_to_le32(o->overwrite);
335 top->bw_avg_time = cpu_to_le32(o->bw_avg_time);
336 top->iops_avg_time = cpu_to_le32(o->iops_avg_time);
337 top->loops = cpu_to_le32(o->loops);
338 top->mem_type = cpu_to_le32(o->mem_type);
339 top->mem_align = cpu_to_le32(o->mem_align);
Jens Axboe1e5324e2012-11-14 14:25:31 -0700340 top->max_latency = cpu_to_le32(o->max_latency);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100341 top->stonewall = cpu_to_le32(o->stonewall);
342 top->new_group = cpu_to_le32(o->new_group);
343 top->numjobs = cpu_to_le32(o->numjobs);
344 top->cpumask_set = cpu_to_le32(o->cpumask_set);
345 top->verify_cpumask_set = cpu_to_le32(o->verify_cpumask_set);
346 top->iolog = cpu_to_le32(o->iolog);
347 top->rwmixcycle = cpu_to_le32(o->rwmixcycle);
348 top->nice = cpu_to_le32(o->nice);
Jens Axboe28727df2012-03-29 08:33:15 +0200349 top->ioprio = cpu_to_le32(o->ioprio);
350 top->ioprio_class = cpu_to_le32(o->ioprio_class);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100351 top->file_service_type = cpu_to_le32(o->file_service_type);
352 top->group_reporting = cpu_to_le32(o->group_reporting);
353 top->fadvise_hint = cpu_to_le32(o->fadvise_hint);
354 top->fallocate_mode = cpu_to_le32(o->fallocate_mode);
355 top->zero_buffers = cpu_to_le32(o->zero_buffers);
356 top->refill_buffers = cpu_to_le32(o->refill_buffers);
357 top->scramble_buffers = cpu_to_le32(o->scramble_buffers);
Jens Axboe3c78a832014-01-15 09:41:31 -0700358 top->buffer_pattern_bytes = cpu_to_le32(o->buffer_pattern_bytes);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100359 top->time_based = cpu_to_le32(o->time_based);
360 top->disable_lat = cpu_to_le32(o->disable_lat);
361 top->disable_clat = cpu_to_le32(o->disable_clat);
362 top->disable_slat = cpu_to_le32(o->disable_slat);
363 top->disable_bw = cpu_to_le32(o->disable_bw);
Jens Axboe95820b62013-01-31 13:23:40 +0100364 top->unified_rw_rep = cpu_to_le32(o->unified_rw_rep);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100365 top->gtod_reduce = cpu_to_le32(o->gtod_reduce);
366 top->gtod_cpu = cpu_to_le32(o->gtod_cpu);
367 top->gtod_offload = cpu_to_le32(o->gtod_offload);
368 top->clocksource = cpu_to_le32(o->clocksource);
369 top->no_stall = cpu_to_le32(o->no_stall);
370 top->trim_percentage = cpu_to_le32(o->trim_percentage);
371 top->trim_batch = cpu_to_le32(o->trim_batch);
372 top->trim_zero = cpu_to_le32(o->trim_zero);
373 top->clat_percentiles = cpu_to_le32(o->clat_percentiles);
Jens Axboe9db01ef2013-02-07 15:45:39 +0100374 top->percentile_precision = cpu_to_le32(o->percentile_precision);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100375 top->continue_on_error = cpu_to_le32(o->continue_on_error);
376 top->cgroup_weight = cpu_to_le32(o->cgroup_weight);
377 top->cgroup_nodelete = cpu_to_le32(o->cgroup_nodelete);
378 top->uid = cpu_to_le32(o->uid);
379 top->gid = cpu_to_le32(o->gid);
380 top->flow_id = __cpu_to_le32(o->flow_id);
381 top->flow = __cpu_to_le32(o->flow);
382 top->flow_watermark = __cpu_to_le32(o->flow_watermark);
383 top->flow_sleep = cpu_to_le32(o->flow_sleep);
384 top->sync_file_range = cpu_to_le32(o->sync_file_range);
Jens Axboe3e260a42013-12-09 12:38:53 -0700385 top->latency_target = __cpu_to_le64(o->latency_target);
386 top->latency_window = __cpu_to_le64(o->latency_window);
387 top->latency_percentile.u.i = __cpu_to_le64(fio_double_to_uint64(o->latency_percentile.u.f));
Jens Axboee4769942012-03-13 14:01:11 +0100388 top->compress_percentage = cpu_to_le32(o->compress_percentage);
389 top->compress_chunk = cpu_to_le32(o->compress_chunk);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100390
Jens Axboeb999b3c2012-09-24 09:39:49 +0200391 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100392 top->bs[i] = cpu_to_le32(o->bs[i]);
393 top->ba[i] = cpu_to_le32(o->ba[i]);
394 top->min_bs[i] = cpu_to_le32(o->min_bs[i]);
395 top->max_bs[i] = cpu_to_le32(o->max_bs[i]);
396 top->bssplit_nr[i] = cpu_to_le32(o->bssplit_nr[i]);
397
398 if (o->bssplit_nr[i]) {
399 unsigned int bssplit_nr = o->bssplit_nr[i];
400
401 if (bssplit_nr > BSSPLIT_MAX) {
402 log_err("fio: BSSPLIT_MAX is too small\n");
403 bssplit_nr = BSSPLIT_MAX;
404 }
405 for (j = 0; j < bssplit_nr; j++) {
406 top->bssplit[i][j].bs = cpu_to_le32(o->bssplit[i][j].bs);
407 top->bssplit[i][j].perc = cpu_to_le32(o->bssplit[i][j].perc);
408 }
409 }
410
411 top->rwmix[i] = cpu_to_le32(o->rwmix[i]);
412 top->rate[i] = cpu_to_le32(o->rate[i]);
413 top->ratemin[i] = cpu_to_le32(o->ratemin[i]);
414 top->rate_iops[i] = cpu_to_le32(o->rate_iops[i]);
415 top->rate_iops_min[i] = cpu_to_le32(o->rate_iops_min[i]);
Jens Axboed9472272013-07-25 10:20:45 -0600416
417 top->perc_rand[i] = cpu_to_le32(o->perc_rand[i]);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100418 }
419
420 memcpy(top->verify_pattern, o->verify_pattern, MAX_PATTERN_SIZE);
Jens Axboe3c78a832014-01-15 09:41:31 -0700421 memcpy(top->buffer_pattern, o->buffer_pattern, MAX_PATTERN_SIZE);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100422
423 top->size = __cpu_to_le64(o->size);
424 top->verify_backlog = __cpu_to_le64(o->verify_backlog);
425 top->start_delay = __cpu_to_le64(o->start_delay);
Christian Ehrhardt23ed19b2014-02-20 09:07:02 -0800426 top->start_delay_high = __cpu_to_le64(o->start_delay_high);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100427 top->timeout = __cpu_to_le64(o->timeout);
428 top->ramp_time = __cpu_to_le64(o->ramp_time);
429 top->zone_range = __cpu_to_le64(o->zone_range);
430 top->zone_size = __cpu_to_le64(o->zone_size);
431 top->zone_skip = __cpu_to_le64(o->zone_skip);
Jens Axboeae278f92012-03-28 20:52:55 +0200432 top->lockmem = __cpu_to_le64(o->lockmem);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100433 top->ddir_seq_add = __cpu_to_le64(o->ddir_seq_add);
434 top->file_size_low = __cpu_to_le64(o->file_size_low);
435 top->file_size_high = __cpu_to_le64(o->file_size_high);
436 top->start_offset = __cpu_to_le64(o->start_offset);
437 top->trim_backlog = __cpu_to_le64(o->trim_backlog);
Jens Axboe6a4cf742012-03-16 14:02:54 +0100438 top->offset_increment = __cpu_to_le64(o->offset_increment);
Jens Axboeddf24e42013-08-09 12:53:44 -0600439 top->number_ios = __cpu_to_le64(o->number_ios);
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100440
441 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
442 top->percentile_list[i].u.i = __cpu_to_le64(fio_double_to_uint64(o->percentile_list[i].u.f));
443#if 0
Jens Axboe3c3ed072012-03-27 09:12:39 +0200444 uint8_t cpumask[FIO_TOP_STR_MAX];
445 uint8_t verify_cpumask[FIO_TOP_STR_MAX];
Jens Axboe2dc1cbb2012-03-08 14:52:25 +0100446#endif
447
448}
449
Jens Axboe51167792012-03-08 21:34:18 +0100450/*
451 * Basic conversion test. We'd really need to fill in more of the options
452 * to have a thorough test. Even better, we should auto-generate the
453 * converter functions...
454 */
455int fio_test_cconv(struct thread_options *__o)
456{
457 struct thread_options o;
458 struct thread_options_pack top1, top2;
459
460 memset(&top1, 0, sizeof(top1));
461 memset(&top2, 0, sizeof(top2));
462
463 convert_thread_options_to_net(&top1, __o);
464 memset(&o, 0, sizeof(o));
465 convert_thread_options_to_cpu(&o, &top1);
466 convert_thread_options_to_net(&top2, &o);
467
Jens Axboeeb0c74a2014-02-11 10:33:06 -0700468 free_thread_options_to_cpu(&o);
469
Jens Axboe51167792012-03-08 21:34:18 +0100470 return memcmp(&top1, &top2, sizeof(top1));
471}