server: initial support for command line passing
[fio.git] / fio.h
CommitLineData
ebac4655
JA
1#ifndef FIO_H
2#define FIO_H
3
4#include <sched.h>
5#include <limits.h>
6#include <pthread.h>
7#include <sys/time.h>
8#include <sys/resource.h>
3c39a379
JA
9#include <errno.h>
10#include <stdlib.h>
11#include <stdio.h>
6d6f031f 12#include <unistd.h>
34cfcdaf 13#include <string.h>
cd14cc10 14#include <inttypes.h>
7101d9c2 15#include <assert.h>
ebac4655 16
ecc314ba
BC
17struct thread_data;
18
81179eec
JA
19#define FIO_MAJOR 1
20#define FIO_MINOR 58
21#define FIO_PATCH 0
22
317b95d0 23#include "compiler/compiler.h"
01743ee1 24#include "flist.h"
e2887563 25#include "fifo.h"
4b87898e 26#include "rbtree.h"
317b95d0
JA
27#include "arch/arch.h"
28#include "os/os.h"
07739b57 29#include "mutex.h"
a3d741fa
JA
30#include "log.h"
31#include "debug.h"
d6aed795
JA
32#include "file.h"
33#include "io_ddir.h"
dcefb588 34#include "ioengine.h"
5995a6a4 35#include "iolog.h"
c5c8bd5c 36#include "helpers.h"
07b3232d 37#include "options.h"
7eb36574 38#include "profile.h"
c223da83 39#include "time.h"
bf2e821a 40#include "lib/getopt.h"
2615cc4b 41#include "lib/rand.h"
37db14fe 42#include "server.h"
a64e88da 43#include "stat.h"
ebac4655 44
609342ff
DL
45#ifdef FIO_HAVE_GUASI
46#include <guasi.h>
47#endif
48
417f0068
JA
49#ifdef FIO_HAVE_SOLARISAIO
50#include <sys/asynch.h>
51#endif
52
e9c047a0
JA
53/*
54 * What type of allocation to use for io buffers
55 */
56enum fio_memtype {
57 MEM_MALLOC = 0, /* ordinary malloc */
58 MEM_SHM, /* use shared memory segments */
74b025b0 59 MEM_SHMHUGE, /* use shared memory segments with huge pages */
e9c047a0 60 MEM_MMAP, /* use anonynomous mmap */
d0bdaf49 61 MEM_MMAPHUGE, /* memory mapped huge file */
e9c047a0
JA
62};
63
38dad62d
JA
64/*
65 * offset generator types
66 */
67enum {
68 RW_SEQ_SEQ = 0,
69 RW_SEQ_IDENT,
70};
71
564ca972
JA
72struct bssplit {
73 unsigned int bs;
74 unsigned char perc;
75};
76
2dc1bbeb 77struct thread_options {
b1ec1da6 78 int pad;
61697c37 79 char *description;
b4692828 80 char *name;
ef899b63 81 char *directory;
13f8e2d2 82 char *filename;
2dc1bbeb 83 char *opendir;
09629a90 84 char *ioengine;
413dd459 85 enum td_ddir td_ddir;
38dad62d 86 unsigned int rw_seq;
90fef2d1 87 unsigned int kb_base;
5736c10d 88 unsigned int ddir_seq_nr;
a66da7a2 89 long ddir_seq_add;
2dc1bbeb
JA
90 unsigned int iodepth;
91 unsigned int iodepth_low;
92 unsigned int iodepth_batch;
4950421a 93 unsigned int iodepth_batch_complete;
2dc1bbeb
JA
94
95 unsigned long long size;
7bb59102 96 unsigned int size_percent;
aa31f1f1 97 unsigned int fill_device;
2dc1bbeb
JA
98 unsigned long long file_size_low;
99 unsigned long long file_size_high;
100 unsigned long long start_offset;
101
102 unsigned int bs[2];
2b7a01d0 103 unsigned int ba[2];
2dc1bbeb
JA
104 unsigned int min_bs[2];
105 unsigned int max_bs[2];
720e84ad
JA
106 struct bssplit *bssplit[2];
107 unsigned int bssplit_nr[2];
2dc1bbeb
JA
108
109 unsigned int nr_files;
110 unsigned int open_files;
4d4e80f2 111 enum file_lock_mode file_lock_mode;
29c1349f 112 unsigned int lockfile_batch;
e9c047a0 113
9158d2f7
JA
114 unsigned int odirect;
115 unsigned int invalidate_cache;
116 unsigned int create_serialize;
117 unsigned int create_fsync;
814452bd 118 unsigned int create_on_open;
9158d2f7 119 unsigned int end_fsync;
afad68f7 120 unsigned int pre_read;
9158d2f7
JA
121 unsigned int sync_io;
122 unsigned int verify;
e84c73a8 123 unsigned int do_verify;
160b966d 124 unsigned int verifysort;
a59e170d
JA
125 unsigned int verify_interval;
126 unsigned int verify_offset;
0e92f873 127 char verify_pattern[MAX_PATTERN_SIZE];
90059d65 128 unsigned int verify_pattern_bytes;
a12a3b4d 129 unsigned int verify_fatal;
b463e936 130 unsigned int verify_dump;
e8462bd8 131 unsigned int verify_async;
9e144189
JA
132 unsigned long long verify_backlog;
133 unsigned int verify_batch;
9158d2f7
JA
134 unsigned int use_thread;
135 unsigned int unlink;
136 unsigned int do_disk_util;
137 unsigned int override_sync;
138 unsigned int rand_repeatable;
2615cc4b 139 unsigned int use_os_rand;
9158d2f7
JA
140 unsigned int write_lat_log;
141 unsigned int write_bw_log;
bb8895e0 142 unsigned int norandommap;
2b386d25 143 unsigned int softrandommap;
690adba3 144 unsigned int bs_unaligned;
ebb1415f 145 unsigned int fsync_on_close;
e9c047a0 146
56bb17f2 147 unsigned int hugepage_size;
a00735e6 148 unsigned int rw_min_bs;
ebac4655 149 unsigned int thinktime;
48097d5c 150 unsigned int thinktime_spin;
9c1f7434 151 unsigned int thinktime_blocks;
ebac4655 152 unsigned int fsync_blocks;
5f9099ea 153 unsigned int fdatasync_blocks;
1ef2b6be 154 unsigned int barrier_blocks;
dce8b847 155 unsigned long long start_delay;
0db26797 156 unsigned long long timeout;
721938ae 157 unsigned long long ramp_time;
ebac4655 158 unsigned int overwrite;
ebac4655 159 unsigned int bw_avg_time;
ebac4655 160 unsigned int loops;
20dc95c4
JA
161 unsigned long long zone_size;
162 unsigned long long zone_skip;
e9c047a0 163 enum fio_memtype mem_type;
d529ee19 164 unsigned int mem_align;
2dc1bbeb 165
ebac4655 166 unsigned int stonewall;
b3d62a75 167 unsigned int new_group;
ebac4655 168 unsigned int numjobs;
ebac4655 169 os_cpu_mask_t cpumask;
375b2695 170 unsigned int cpumask_set;
e8462bd8
JA
171 os_cpu_mask_t verify_cpumask;
172 unsigned int verify_cpumask_set;
aea47d44 173 unsigned int iolog;
a6ccc7be 174 unsigned int rwmixcycle;
e47f799f 175 unsigned int rwmix[2];
b6f4d880 176 unsigned int nice;
0aabe160 177 unsigned int file_service_type;
b2560f3c 178 unsigned int group_reporting;
d2f3ac35 179 unsigned int fadvise_hint;
a596f047 180 enum fio_fallocate_mode fallocate_mode;
e9459e5a 181 unsigned int zero_buffers;
5973cafb 182 unsigned int refill_buffers;
fd68418e 183 unsigned int scramble_buffers;
cf4464ca 184 unsigned int time_based;
02af0988 185 unsigned int disable_lat;
9520ebb9
JA
186 unsigned int disable_clat;
187 unsigned int disable_slat;
188 unsigned int disable_bw;
993bf48b 189 unsigned int gtod_reduce;
be4ecfdf
JA
190 unsigned int gtod_cpu;
191 unsigned int gtod_offload;
c223da83 192 enum fio_cs clocksource;
64bbb865 193 unsigned int no_stall;
0d29de83
JA
194 unsigned int trim_percentage;
195 unsigned int trim_batch;
196 unsigned int trim_zero;
197 unsigned long long trim_backlog;
83349190
YH
198 unsigned int clat_percentiles;
199 unsigned int overwrite_plist;
200 double percentile_list[FIO_IO_U_LIST_MAX_LEN];
aea47d44 201
076efc7c
JA
202 char *read_iolog_file;
203 char *write_iolog_file;
e3cedca7
JA
204 char *bw_log_file;
205 char *lat_log_file;
d1c46c04 206 char *replay_redirect;
2dc1bbeb
JA
207
208 /*
209 * Pre-run and post-run shell
210 */
211 char *exec_prerun;
212 char *exec_postrun;
213
581e7141
JA
214 unsigned int rate[2];
215 unsigned int ratemin[2];
2dc1bbeb 216 unsigned int ratecycle;
581e7141
JA
217 unsigned int rate_iops[2];
218 unsigned int rate_iops_min[2];
2dc1bbeb
JA
219
220 char *ioscheduler;
221
222 /*
223 * CPU "io" cycle burner
224 */
225 unsigned int cpuload;
226 unsigned int cpucycle;
f2bba182
RR
227
228 /*
229 * I/O Error handling
230 */
231 unsigned int continue_on_error;
9ac8a797
JA
232
233 /*
234 * Benchmark profile type
235 */
79d16311 236 char *profile;
a696fa2a
JA
237
238 /*
239 * blkio cgroup support
240 */
a696fa2a
JA
241 char *cgroup;
242 unsigned int cgroup_weight;
7de87099 243 unsigned int cgroup_nodelete;
e0b0d892
JA
244
245 unsigned int uid;
246 unsigned int gid;
44f29692
JA
247
248 unsigned int sync_file_range;
675012f0
DE
249
250 unsigned int userspace_libaio_reap;
2dc1bbeb
JA
251};
252
253/*
254 * This describes a single thread/process executing a fio job.
255 */
256struct thread_data {
257 struct thread_options o;
e4e33258 258 char verror[FIO_VERROR_SIZE];
2dc1bbeb
JA
259 pthread_t thread;
260 int thread_number;
261 int groupid;
262 struct thread_stat ts;
7b9f733a
JA
263
264 struct io_log *slat_log;
265 struct io_log *clat_log;
266 struct io_log *lat_log;
267 struct io_log *bw_log;
268
f0505a14
JA
269 uint64_t stat_io_bytes[2];
270 struct timeval stat_sample_time[2];
271
c8aaba19
JA
272 struct rusage ru_start;
273 struct rusage ru_end;
274
126d65c6 275 struct fio_file **files;
dd87b2c9 276 unsigned int files_size;
2dc1bbeb
JA
277 unsigned int files_index;
278 unsigned int nr_open_files;
1020a139 279 unsigned int nr_done_files;
2dc1bbeb
JA
280 unsigned int nr_normal_files;
281 union {
282 unsigned int next_file;
283 os_random_state_t next_file_state;
4c07ad86 284 struct frand_state __next_file_state;
2dc1bbeb
JA
285 };
286 int error;
20e354ef 287 int done;
2dc1bbeb
JA
288 pid_t pid;
289 char *orig_buffer;
290 size_t orig_buffer_size;
291 volatile int terminate;
292 volatile int runstate;
293 unsigned int ioprio;
ac684785 294 unsigned int ioprio_set;
2dc1bbeb 295 unsigned int last_was_sync;
9e144189 296 enum fio_ddir last_ddir;
2dc1bbeb
JA
297
298 char *mmapfile;
299 int mmapfd;
300
843a7413
JA
301 void *iolog_buf;
302 FILE *iolog_f;
ebac4655 303
da86774e 304 char *sysfs_root;
da86774e 305
3545a109 306 unsigned long rand_seeds[8];
5bfc35d7 307
4c07ad86
JA
308 union {
309 os_random_state_t bsrange_state;
310 struct frand_state __bsrange_state;
311 };
312 union {
313 os_random_state_t verify_state;
314 struct frand_state __verify_state;
315 };
316 union {
317 os_random_state_t trim_state;
318 struct frand_state __trim_state;
319 };
ebac4655 320
3545a109
JA
321 struct frand_state buf_state;
322
9e144189 323 unsigned int verify_batch;
0d29de83 324 unsigned int trim_batch;
9e144189 325
ebac4655
JA
326 int shm_id;
327
e9c047a0
JA
328 /*
329 * IO engine hooks, contains everything needed to submit an io_u
330 * to any of the available IO engines.
331 */
2866c82d 332 struct ioengine_ops *io_ops;
ebac4655 333
e9c047a0
JA
334 /*
335 * Current IO depth and list of free and busy io_u's.
336 */
ebac4655 337 unsigned int cur_depth;
d8005759 338 unsigned int io_u_queued;
01743ee1
JA
339 struct flist_head io_u_freelist;
340 struct flist_head io_u_busylist;
341 struct flist_head io_u_requeues;
e8462bd8
JA
342 pthread_mutex_t io_u_lock;
343 pthread_cond_t free_cond;
344
345 /*
346 * async verify offload
347 */
348 struct flist_head verify_list;
349 pthread_t *verify_threads;
350 unsigned int nr_verify_threads;
351 pthread_cond_t verify_cond;
352 int verify_thread_exit;
ebac4655 353
e9c047a0
JA
354 /*
355 * Rate state
356 */
ba3e4e0c 357 unsigned long rate_nsec_cycle[2];
581e7141
JA
358 long rate_pending_usleep[2];
359 unsigned long rate_bytes[2];
360 unsigned long rate_blocks[2];
361 struct timeval lastrate[2];
ebac4655 362
ebac4655 363 unsigned long long total_io_size;
2e3bd4c2 364 unsigned long long fill_device_size;
ebac4655 365
755200a3 366 unsigned long io_issues[2];
9104f874
JA
367 unsigned long long io_blocks[2];
368 unsigned long long io_bytes[2];
48f5abd3 369 unsigned long long io_skip_bytes;
9104f874 370 unsigned long long this_io_bytes[2];
079ad09b 371 unsigned long long zone_bytes;
cdd18ad8 372 struct fio_mutex *mutex;
ebac4655 373
e9c047a0
JA
374 /*
375 * State for random io, a bitmap of blocks done vs not done
376 */
4c07ad86
JA
377 union {
378 os_random_state_t random_state;
379 struct frand_state __random_state;
380 };
ebac4655 381
ebac4655
JA
382 struct timeval start; /* start of this loop */
383 struct timeval epoch; /* time job was started */
a61eddec 384 struct timeval last_issue;
993bf48b
JA
385 struct timeval tv_cache;
386 unsigned int tv_cache_nr;
387 unsigned int tv_cache_mask;
721938ae 388 unsigned int ramp_time_over;
ebac4655 389
e9c047a0
JA
390 /*
391 * read/write mixed workload state
392 */
4c07ad86
JA
393 union {
394 os_random_state_t rwmix_state;
395 struct frand_state __rwmix_state;
396 };
e4928662 397 unsigned long rwmix_issues;
e9c047a0 398 enum fio_ddir rwmix_ddir;
5736c10d 399 unsigned int ddir_seq_nr;
a6ccc7be 400
e9c047a0 401 /*
8de8f047
JA
402 * IO history logs for verification. We use a tree for sorting,
403 * if we are overwriting. Otherwise just use a fifo.
e9c047a0 404 */
4b87898e 405 struct rb_root io_hist_tree;
01743ee1 406 struct flist_head io_hist_list;
9e144189 407 unsigned long io_hist_len;
8de8f047
JA
408
409 /*
410 * For IO replaying
411 */
01743ee1 412 struct flist_head io_log_list;
433afcb4 413
0d29de83
JA
414 /*
415 * For tracking/handling discards
416 */
417 struct flist_head trim_list;
418 unsigned long trim_entries;
419
1907dbc6
JA
420 /*
421 * for fileservice, how often to switch to a new file
422 */
423 unsigned int file_service_nr;
424 unsigned int file_service_left;
425 struct fio_file *file_service_file;
9c60ce64 426
44f29692
JA
427 unsigned int sync_file_range_nr;
428
9c60ce64
JA
429 /*
430 * For generating file sizes
431 */
4c07ad86
JA
432 union {
433 os_random_state_t file_size_state;
434 struct frand_state __file_size_state;
435 };
f2bba182
RR
436
437 /*
438 * Error counts
439 */
440 unsigned int total_err_count;
441 int first_error;
15dc1934
JA
442
443 /*
444 * Can be overloaded by profiles
445 */
7eb36574 446 struct prof_io_ops prof_io_ops;
58c55ba0 447 void *prof_data;
ebac4655
JA
448};
449
e592a06b
AC
450/*
451 * when should interactive ETA output be generated
452 */
453enum {
454 FIO_ETA_AUTO,
455 FIO_ETA_ALWAYS,
456 FIO_ETA_NEVER,
457};
458
e1161c32 459#define __td_verror(td, err, msg, func) \
ebac4655 460 do { \
19abcd3d
JA
461 if ((td)->error) \
462 break; \
ebac4655
JA
463 int e = (err); \
464 (td)->error = e; \
f2bba182
RR
465 if (!(td)->first_error) \
466 snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, func=%s, error=%s", __FILE__, __LINE__, (func), (msg)); \
ebac4655
JA
467 } while (0)
468
b990b5c0 469
f2bba182
RR
470#define td_clear_error(td) \
471 (td)->error = 0;
e1161c32
JA
472#define td_verror(td, err, func) \
473 __td_verror((td), (err), strerror((err)), (func))
474#define td_vmsg(td, err, msg, func) \
475 __td_verror((td), (err), (msg), (func))
b990b5c0 476
81179eec
JA
477#define __fio_stringify_1(x) #x
478#define __fio_stringify(x) __fio_stringify_1(x)
479
ebac4655
JA
480extern int exitall_on_terminate;
481extern int thread_number;
9cedf167 482extern int nr_process, nr_thread;
ebac4655
JA
483extern int shm_id;
484extern int groupid;
c6ae0a5b 485extern int terse_output;
53cdc686 486extern int temp_stall_ts;
1e97cce9 487extern unsigned long long mlock_size;
cfc99db7 488extern unsigned long page_mask, page_size;
4241ea8f 489extern int read_only;
e592a06b 490extern int eta_print;
d3eeeabc 491extern unsigned long done_secs;
01f06b63 492extern char *job_section;
be4ecfdf
JA
493extern int fio_gtod_offload;
494extern int fio_gtod_cpu;
c223da83 495extern enum fio_cs fio_clock_source;
a9523c6f 496extern int warnings_fatal;
f57a9c59 497extern int terse_version;
5c341e9a 498extern int is_backend;
a37f69b7 499extern int nr_clients;
e46d8091 500extern int log_syslog;
ebac4655
JA
501
502extern struct thread_data *threads;
503
7101d9c2
JA
504static inline void fio_ro_check(struct thread_data *td, struct io_u *io_u)
505{
506 assert(!(io_u->ddir == DDIR_WRITE && !td_write(td)));
507}
508
0ce8b119 509#define BLOCKS_PER_MAP (8 * sizeof(unsigned long))
aec2de20
JA
510#define TO_MAP_BLOCK(f, b) (b)
511#define RAND_MAP_IDX(f, b) (TO_MAP_BLOCK(f, b) / BLOCKS_PER_MAP)
512#define RAND_MAP_BIT(f, b) (TO_MAP_BLOCK(f, b) & (BLOCKS_PER_MAP - 1))
ebac4655 513
fca70358 514#define REAL_MAX_JOBS 2048
ebac4655 515
1ec99eea 516#define td_non_fatal_error(e) ((e) == EIO || (e) == EILSEQ)
f2bba182
RR
517
518static inline void update_error_count(struct thread_data *td, int err)
519{
520 td->total_err_count++;
521 if (td->total_err_count == 1)
522 td->first_error = err;
523}
524
87dc1ab1
JA
525static inline int should_fsync(struct thread_data *td)
526{
527 if (td->last_was_sync)
528 return 0;
2dc1bbeb 529 if (td->o.odirect)
87dc1ab1 530 return 0;
2dc1bbeb 531 if (td_write(td) || td_rw(td) || td->o.override_sync)
87dc1ab1
JA
532 return 1;
533
534 return 0;
535}
536
8914a9d8 537/*
214e1eca 538 * Init/option functions
8914a9d8 539 */
72cb971b 540extern int __must_check parse_options(int, char **);
50d16976 541extern int parse_jobs_ini(char *, int, int);
81179eec 542extern int parse_cmd_line(int, char **);
50d16976
JA
543extern int exec_run(void);
544extern void reset_fio_state(void);
3b8b7135 545extern int fio_options_parse(struct thread_data *, char **, int);
74929ac2 546extern void fio_keywords_init(void);
214e1eca
JA
547extern int fio_cmd_option_parse(struct thread_data *, const char *, char *);
548extern void fio_fill_default_options(struct thread_data *);
549extern int fio_show_option_help(const char *);
550extern void fio_options_dup_and_init(struct option *);
d23bb327
JA
551extern void options_mem_dupe(struct thread_data *);
552extern void options_mem_free(struct thread_data *);
5bfc35d7 553extern void td_fill_rand_seeds(struct thread_data *);
79d16311 554extern void add_job_opts(const char **);
1ec3d69b
JA
555extern char *num2str(unsigned long, int, int, int);
556
214e1eca 557#define FIO_GETOPT_JOB 0x89988998
07b3232d 558#define FIO_NR_OPTIONS (FIO_MAX_OPTS + 128)
8914a9d8 559
263e529f
JA
560/*
561 * ETA/status stuff
562 */
563extern void print_thread_status(void);
564extern void print_status_init(int);
565
566/*
567 * Thread life cycle. Once a thread has a runstate beyond TD_INITIALIZED, it
568 * will never back again. It may cycle between running/verififying/fsyncing.
569 * Once the thread reaches TD_EXITED, it is just waiting for the core to
570 * reap it.
571 */
572enum {
573 TD_NOT_CREATED = 0,
574 TD_CREATED,
575 TD_INITIALIZED,
b29ee5b3 576 TD_RAMP,
263e529f 577 TD_RUNNING,
b0f65863 578 TD_PRE_READING,
263e529f
JA
579 TD_VERIFYING,
580 TD_FSYNCING,
581 TD_EXITED,
582 TD_REAPED,
583};
584
b29ee5b3 585extern void td_set_runstate(struct thread_data *, int);
cc0df00a
JA
586#define TERMINATE_ALL (-1)
587extern void fio_terminate_threads(int);
b29ee5b3 588
2f9ade3c
JA
589/*
590 * Memory helpers
591 */
b2fdda43 592extern int __must_check fio_pin_memory(void);
2f9ade3c 593extern void fio_unpin_memory(void);
b2fdda43 594extern int __must_check allocate_io_mem(struct thread_data *);
2f9ade3c
JA
595extern void free_io_mem(struct thread_data *);
596
b29ee5b3
JA
597/*
598 * Reset stats after ramp time completes
599 */
600extern void reset_all_stats(struct thread_data *);
601
fb7b71a3
JA
602/*
603 * blktrace support
604 */
5e62c22a 605#ifdef FIO_HAVE_BLKTRACE
fb7b71a3
JA
606extern int is_blktrace(const char *);
607extern int load_blktrace(struct thread_data *, const char *);
5e62c22a 608#endif
fb7b71a3 609
2866c82d
JA
610/*
611 * Mark unused variables passed to ops functions as unused, to silence gcc
612 */
613#define fio_unused __attribute((__unused__))
5f350952
JA
614#define fio_init __attribute__((constructor))
615#define fio_exit __attribute__((destructor))
2866c82d 616
34572e28
JA
617#define for_each_td(td, i) \
618 for ((i) = 0, (td) = &threads[0]; (i) < (int) thread_number; (i)++, (td)++)
53cdc686 619#define for_each_file(td, f, i) \
691c8fb0
JA
620 if ((td)->files_index) \
621 for ((i) = 0, (f) = (td)->files[0]; \
622 (i) < (td)->o.nr_files && ((f) = (td)->files[i]) != NULL; \
623 (i)++)
53cdc686 624
0032bf9f
JA
625#define fio_assert(td, cond) do { \
626 if (!(cond)) { \
340fd243 627 int *__foo = NULL; \
0032bf9f 628 fprintf(stderr, "file:%s:%d, assert %s failed\n", __FILE__, __LINE__, #cond); \
ac18ea38 629 td_set_runstate((td), TD_EXITED); \
437c9b71 630 (td)->error = EFAULT; \
340fd243 631 *__foo = 0; \
0032bf9f
JA
632 } \
633} while (0)
634
12d9d841
JA
635static inline int fio_fill_issue_time(struct thread_data *td)
636{
637 if (td->o.read_iolog_file ||
638 !td->o.disable_clat || !td->o.disable_slat || !td->o.disable_bw)
639 return 1;
640
641 return 0;
642}
643
581e7141
JA
644static inline int __should_check_rate(struct thread_data *td,
645 enum fio_ddir ddir)
646{
647 struct thread_options *o = &td->o;
648
649 /*
650 * If some rate setting was given, we need to check it
651 */
652 if (o->rate[ddir] || o->ratemin[ddir] || o->rate_iops[ddir] ||
653 o->rate_iops_min[ddir])
654 return 1;
655
656 return 0;
657}
658
659static inline int should_check_rate(struct thread_data *td,
660 unsigned long *bytes_done)
661{
662 int ret = 0;
663
664 if (bytes_done[0])
665 ret |= __should_check_rate(td, 0);
666 if (bytes_done[1])
667 ret |= __should_check_rate(td, 1);
668
669 return ret;
670}
671
d529ee19
JA
672static inline int is_power_of_2(unsigned int val)
673{
674 return (val != 0 && ((val & (val - 1)) == 0));
675}
676
e8462bd8
JA
677/*
678 * We currently only need to do locking if we have verifier threads
679 * accessing our internal structures too
680 */
681static inline void td_io_u_lock(struct thread_data *td)
682{
683 if (td->o.verify_async)
684 pthread_mutex_lock(&td->io_u_lock);
685}
686
687static inline void td_io_u_unlock(struct thread_data *td)
688{
689 if (td->o.verify_async)
690 pthread_mutex_unlock(&td->io_u_lock);
691}
692
693static inline void td_io_u_free_notify(struct thread_data *td)
694{
695 if (td->o.verify_async)
696 pthread_cond_signal(&td->free_cond);
697}
698
ebac4655 699#endif