init: automate displaying debug categories
[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
317b95d0 17#include "compiler/compiler.h"
8062f527 18#include "thread_options.h"
01743ee1 19#include "flist.h"
e2887563 20#include "fifo.h"
317b95d0
JA
21#include "arch/arch.h"
22#include "os/os.h"
07739b57 23#include "mutex.h"
a3d741fa
JA
24#include "log.h"
25#include "debug.h"
d6aed795
JA
26#include "file.h"
27#include "io_ddir.h"
dcefb588 28#include "ioengine.h"
5995a6a4 29#include "iolog.h"
c5c8bd5c 30#include "helpers.h"
07b3232d 31#include "options.h"
7eb36574 32#include "profile.h"
ef3c94b6 33#include "fio_time.h"
a7346816 34#include "gettime.h"
bf2e821a 35#include "lib/getopt.h"
2615cc4b 36#include "lib/rand.h"
7fb6d453 37#include "lib/rbtree.h"
dd366728 38#include "client.h"
37db14fe 39#include "server.h"
a64e88da 40#include "stat.h"
9e684a49 41#include "flow.h"
2ae0b204 42#include "io_u_queue.h"
a9da8ab2 43#include "workqueue.h"
ebac4655 44
4700b234 45#ifdef CONFIG_SOLARISAIO
417f0068
JA
46#include <sys/asynch.h>
47#endif
48
67bf9823 49#ifdef CONFIG_LIBNUMA
d0b937ed
YR
50#include <linux/mempolicy.h>
51#include <numa.h>
52
53/*
54 * "local" is pseudo-policy
55 */
56#define MPOL_LOCAL MPOL_MAX
57#endif
58
38dad62d
JA
59/*
60 * offset generator types
61 */
62enum {
63 RW_SEQ_SEQ = 0,
64 RW_SEQ_IDENT,
65};
66
d72be545
JA
67enum {
68 TD_F_VER_BACKLOG = 1,
69 TD_F_TRIM_BACKLOG = 2,
70 TD_F_READ_IOLOG = 4,
71 TD_F_REFILL_BUFFERS = 8,
72 TD_F_SCRAMBLE_BUFFERS = 16,
73 TD_F_VER_NONE = 32,
74 TD_F_PROFILE_OPS = 64,
bedc9dc2 75 TD_F_COMPRESS = 128,
046395d7 76 TD_F_NOIO = 256,
aee2ab67 77 TD_F_COMPRESS_LOG = 512,
ca09be4b 78 TD_F_VSTATE_SAVED = 1024,
a9da8ab2
JA
79 TD_F_NEED_LOCK = 2048,
80 TD_F_CHILD = 4096,
d72be545
JA
81};
82
d24945f0
JA
83enum {
84 FIO_RAND_BS_OFF = 0,
85 FIO_RAND_VER_OFF,
86 FIO_RAND_MIX_OFF,
87 FIO_RAND_FILE_OFF,
88 FIO_RAND_BLOCK_OFF,
89 FIO_RAND_FILE_SIZE_OFF,
90 FIO_RAND_TRIM_OFF,
91 FIO_RAND_BUF_OFF,
d9472271
JA
92 FIO_RAND_SEQ_RAND_READ_OFF,
93 FIO_RAND_SEQ_RAND_WRITE_OFF,
94 FIO_RAND_SEQ_RAND_TRIM_OFF,
23ed19b0 95 FIO_RAND_START_DELAY,
5c94b008 96 FIO_DEDUPE_OFF,
d24945f0
JA
97 FIO_RAND_NR_OFFS,
98};
99
a9da8ab2
JA
100enum {
101 IO_MODE_INLINE = 0,
102 IO_MODE_OFFLOAD,
103};
104
2dc1bbeb
JA
105/*
106 * This describes a single thread/process executing a fio job.
107 */
108struct thread_data {
109 struct thread_options o;
d72be545 110 unsigned long flags;
de890a1e 111 void *eo;
e4e33258 112 char verror[FIO_VERROR_SIZE];
2dc1bbeb 113 pthread_t thread;
2f122b13 114 unsigned int thread_number;
69bdd6ba 115 unsigned int subjob_number;
2f122b13 116 unsigned int groupid;
2dc1bbeb 117 struct thread_stat ts;
7b9f733a 118
46bcd498
JA
119 int client_type;
120
7b9f733a
JA
121 struct io_log *slat_log;
122 struct io_log *clat_log;
123 struct io_log *lat_log;
124 struct io_log *bw_log;
c8eeb9df 125 struct io_log *iops_log;
7b9f733a 126
aee2ab67
JA
127 struct tp_data *tp_data;
128
a9da8ab2
JA
129 struct thread_data *parent;
130
6eaf09d6 131 uint64_t stat_io_bytes[DDIR_RWDIR_CNT];
c8eeb9df
JA
132 struct timeval bw_sample_time;
133
6eaf09d6 134 uint64_t stat_io_blocks[DDIR_RWDIR_CNT];
c8eeb9df 135 struct timeval iops_sample_time;
f0505a14 136
ca09be4b
JA
137 /*
138 * Tracks the last iodepth number of completed writes, if data
139 * verification is enabled
140 */
141 uint64_t *last_write_comp;
142 unsigned int last_write_idx;
143
c97f1ad6
JA
144 volatile int update_rusage;
145 struct fio_mutex *rusage_sem;
c8aaba19
JA
146 struct rusage ru_start;
147 struct rusage ru_end;
148
126d65c6 149 struct fio_file **files;
d7df1d13 150 unsigned char *file_locks;
dd87b2c9 151 unsigned int files_size;
2dc1bbeb
JA
152 unsigned int files_index;
153 unsigned int nr_open_files;
1020a139 154 unsigned int nr_done_files;
2dc1bbeb
JA
155 unsigned int nr_normal_files;
156 union {
157 unsigned int next_file;
d6b72507 158 struct frand_state next_file_state;
2dc1bbeb
JA
159 };
160 int error;
a5e371a6 161 int sig;
20e354ef 162 int done;
ca09be4b 163 int stop_io;
2dc1bbeb
JA
164 pid_t pid;
165 char *orig_buffer;
166 size_t orig_buffer_size;
167 volatile int terminate;
168 volatile int runstate;
2dc1bbeb 169 unsigned int last_was_sync;
9e144189 170 enum fio_ddir last_ddir;
2dc1bbeb 171
2dc1bbeb
JA
172 int mmapfd;
173
843a7413
JA
174 void *iolog_buf;
175 FILE *iolog_f;
ebac4655 176
da86774e 177 char *sysfs_root;
da86774e 178
d24945f0 179 unsigned long rand_seeds[FIO_RAND_NR_OFFS];
5bfc35d7 180
d6b72507
JA
181 struct frand_state bsrange_state;
182 struct frand_state verify_state;
183 struct frand_state trim_state;
184 struct frand_state delay_state;
ebac4655 185
3545a109 186 struct frand_state buf_state;
5c94b008
JA
187 struct frand_state buf_state_prev;
188 struct frand_state dedupe_state;
3545a109 189
9e144189 190 unsigned int verify_batch;
0d29de83 191 unsigned int trim_batch;
9e144189 192
ca09be4b
JA
193 struct thread_io_list *vstate;
194
ebac4655
JA
195 int shm_id;
196
e9c047a0
JA
197 /*
198 * IO engine hooks, contains everything needed to submit an io_u
199 * to any of the available IO engines.
200 */
2866c82d 201 struct ioengine_ops *io_ops;
ebac4655 202
e9c047a0 203 /*
422f9e4b 204 * Queue depth of io_u's that fio MIGHT do
e9c047a0 205 */
ebac4655 206 unsigned int cur_depth;
422f9e4b
RM
207
208 /*
209 * io_u's about to be committed
210 */
d8005759 211 unsigned int io_u_queued;
422f9e4b
RM
212
213 /*
214 * io_u's submitted but not completed yet
215 */
216 unsigned int io_u_in_flight;
217
218 /*
219 * List of free and busy io_u's
220 */
2ae0b204
JA
221 struct io_u_ring io_u_requeues;
222 struct io_u_queue io_u_freelist;
223 struct io_u_queue io_u_all;
e8462bd8
JA
224 pthread_mutex_t io_u_lock;
225 pthread_cond_t free_cond;
226
227 /*
228 * async verify offload
229 */
230 struct flist_head verify_list;
231 pthread_t *verify_threads;
232 unsigned int nr_verify_threads;
233 pthread_cond_t verify_cond;
234 int verify_thread_exit;
ebac4655 235
e9c047a0
JA
236 /*
237 * Rate state
238 */
bdb6d20a 239 uint64_t rate_bps[DDIR_RWDIR_CNT];
6eaf09d6
SL
240 long rate_pending_usleep[DDIR_RWDIR_CNT];
241 unsigned long rate_bytes[DDIR_RWDIR_CNT];
242 unsigned long rate_blocks[DDIR_RWDIR_CNT];
243 struct timeval lastrate[DDIR_RWDIR_CNT];
ebac4655 244
a9da8ab2
JA
245 /*
246 * Enforced rate submission/completion workqueue
247 */
248 struct workqueue io_wq;
249
bdb6d20a
JA
250 uint64_t total_io_size;
251 uint64_t fill_device_size;
ebac4655 252
74d6277f
JA
253 /*
254 * Issue side
255 */
ca09be4b 256 uint64_t io_issues[DDIR_RWDIR_CNT];
74d6277f 257 uint64_t io_issue_bytes[DDIR_RWDIR_CNT];
cf8a46a7 258 uint64_t loops;
74d6277f
JA
259
260 /*
261 * Completions
262 */
bdb6d20a
JA
263 uint64_t io_blocks[DDIR_RWDIR_CNT];
264 uint64_t this_io_blocks[DDIR_RWDIR_CNT];
265 uint64_t io_bytes[DDIR_RWDIR_CNT];
bdb6d20a 266 uint64_t this_io_bytes[DDIR_RWDIR_CNT];
55312f9f 267 uint64_t io_skip_bytes;
bdb6d20a 268 uint64_t zone_bytes;
cdd18ad8 269 struct fio_mutex *mutex;
55312f9f 270 uint64_t bytes_done[DDIR_RWDIR_CNT];
ebac4655 271
e9c047a0
JA
272 /*
273 * State for random io, a bitmap of blocks done vs not done
274 */
d6b72507 275 struct frand_state random_state;
ebac4655 276
ebac4655
JA
277 struct timeval start; /* start of this loop */
278 struct timeval epoch; /* time job was started */
a61eddec 279 struct timeval last_issue;
df8fb609 280 long time_offset;
993bf48b 281 struct timeval tv_cache;
cba5460c 282 struct timeval terminate_time;
993bf48b
JA
283 unsigned int tv_cache_nr;
284 unsigned int tv_cache_mask;
721938ae 285 unsigned int ramp_time_over;
ebac4655 286
3e260a46
JA
287 /*
288 * Time since last latency_window was started
289 */
290 struct timeval latency_ts;
291 unsigned int latency_qd;
292 unsigned int latency_qd_high;
293 unsigned int latency_qd_low;
294 unsigned int latency_failed;
295 uint64_t latency_ios;
6bb58215 296 int latency_end_run;
3e260a46 297
e9c047a0
JA
298 /*
299 * read/write mixed workload state
300 */
d6b72507 301 struct frand_state rwmix_state;
e4928662 302 unsigned long rwmix_issues;
e9c047a0 303 enum fio_ddir rwmix_ddir;
5736c10d 304 unsigned int ddir_seq_nr;
a6ccc7be 305
211c9b89
JA
306 /*
307 * rand/seq mixed workload state
308 */
d6b72507 309 struct frand_state seq_rand_state[DDIR_RWDIR_CNT];
211c9b89 310
e9c047a0 311 /*
8de8f047
JA
312 * IO history logs for verification. We use a tree for sorting,
313 * if we are overwriting. Otherwise just use a fifo.
e9c047a0 314 */
4b87898e 315 struct rb_root io_hist_tree;
01743ee1 316 struct flist_head io_hist_list;
9e144189 317 unsigned long io_hist_len;
8de8f047
JA
318
319 /*
320 * For IO replaying
321 */
01743ee1 322 struct flist_head io_log_list;
433afcb4 323
0d29de83
JA
324 /*
325 * For tracking/handling discards
326 */
327 struct flist_head trim_list;
328 unsigned long trim_entries;
329
1ae83d45
JA
330 struct flist_head next_rand_list;
331
1907dbc6
JA
332 /*
333 * for fileservice, how often to switch to a new file
334 */
335 unsigned int file_service_nr;
336 unsigned int file_service_left;
337 struct fio_file *file_service_file;
9c60ce64 338
44f29692
JA
339 unsigned int sync_file_range_nr;
340
9c60ce64
JA
341 /*
342 * For generating file sizes
343 */
d6b72507 344 struct frand_state file_size_state;
f2bba182
RR
345
346 /*
347 * Error counts
348 */
349 unsigned int total_err_count;
350 int first_error;
15dc1934 351
9e684a49
DE
352 struct fio_flow *flow;
353
15dc1934
JA
354 /*
355 * Can be overloaded by profiles
356 */
7eb36574 357 struct prof_io_ops prof_io_ops;
58c55ba0 358 void *prof_data;
9a3f1100
JA
359
360 void *pinned_mem;
ebac4655
JA
361};
362
e592a06b
AC
363/*
364 * when should interactive ETA output be generated
365 */
366enum {
367 FIO_ETA_AUTO,
368 FIO_ETA_ALWAYS,
369 FIO_ETA_NEVER,
370};
371
e1161c32 372#define __td_verror(td, err, msg, func) \
ebac4655 373 do { \
21beb609 374 unsigned int ____e = (err); \
19abcd3d
JA
375 if ((td)->error) \
376 break; \
8271963e 377 (td)->error = ____e; \
f2bba182 378 if (!(td)->first_error) \
98ffb8f3 379 snprintf(td->verror, sizeof(td->verror), "file:%s:%d, func=%s, error=%s", __FILE__, __LINE__, (func), (msg)); \
ebac4655
JA
380 } while (0)
381
b990b5c0 382
a9da8ab2
JA
383#define td_clear_error(td) do { \
384 (td)->error = 0; \
385 if ((td)->parent) \
386 (td)->parent->error = 0; \
387} while (0)
388
389#define td_verror(td, err, func) do { \
390 __td_verror((td), (err), strerror((err)), (func)); \
391 if ((td)->parent) \
392 __td_verror((td)->parent, (err), strerror((err)), (func)); \
393} while (0)
394
395#define td_vmsg(td, err, msg, func) do { \
396 __td_verror((td), (err), (msg), (func)); \
397 if ((td)->parent) \
398 __td_verror((td)->parent, (err), (msg), (func)); \
399} while (0)
b990b5c0 400
81179eec
JA
401#define __fio_stringify_1(x) #x
402#define __fio_stringify(x) __fio_stringify_1(x)
403
ebac4655 404extern int exitall_on_terminate;
11e950bd 405extern unsigned int thread_number;
108fea77 406extern unsigned int stat_number;
ebac4655
JA
407extern int shm_id;
408extern int groupid;
f3afa57e 409extern int output_format;
2b8c71b0 410extern int append_terse_output;
53cdc686 411extern int temp_stall_ts;
7078106d 412extern uintptr_t page_mask, page_size;
4241ea8f 413extern int read_only;
e592a06b 414extern int eta_print;
e382e661 415extern int eta_new_line;
d3eeeabc 416extern unsigned long done_secs;
01f06b63 417extern char *job_section;
be4ecfdf
JA
418extern int fio_gtod_offload;
419extern int fio_gtod_cpu;
c223da83 420extern enum fio_cs fio_clock_source;
fa80feae 421extern int fio_clock_source_set;
a9523c6f 422extern int warnings_fatal;
f57a9c59 423extern int terse_version;
5c341e9a 424extern int is_backend;
a37f69b7 425extern int nr_clients;
e46d8091 426extern int log_syslog;
06464907 427extern int status_interval;
5e726d0a 428extern const char fio_version_string[];
5ddc6707
JA
429extern int helper_do_stat;
430extern pthread_cond_t helper_cond;
ca09be4b
JA
431extern char *trigger_file;
432extern char *trigger_cmd;
b63efd30 433extern char *trigger_remote_cmd;
ca09be4b 434extern long long trigger_timeout;
ebac4655
JA
435
436extern struct thread_data *threads;
437
effd6ff0 438static inline void fio_ro_check(const struct thread_data *td, struct io_u *io_u)
7101d9c2
JA
439{
440 assert(!(io_u->ddir == DDIR_WRITE && !td_write(td)));
441}
442
fca70358 443#define REAL_MAX_JOBS 2048
ebac4655 444
87dc1ab1
JA
445static inline int should_fsync(struct thread_data *td)
446{
447 if (td->last_was_sync)
448 return 0;
2dc1bbeb 449 if (td_write(td) || td_rw(td) || td->o.override_sync)
87dc1ab1
JA
450 return 1;
451
452 return 0;
453}
454
8914a9d8 455/*
214e1eca 456 * Init/option functions
8914a9d8 457 */
0420ba6a 458extern int __must_check fio_init_options(void);
72cb971b 459extern int __must_check parse_options(int, char **);
46bcd498
JA
460extern int parse_jobs_ini(char *, int, int, int);
461extern int parse_cmd_line(int, char **, int);
2e1df07d 462extern int fio_backend(void);
50d16976 463extern void reset_fio_state(void);
2e1df07d 464extern void clear_io_state(struct thread_data *);
292cc475 465extern int fio_options_parse(struct thread_data *, char **, int, int);
74929ac2 466extern void fio_keywords_init(void);
af1dc266 467extern void fio_keywords_exit(void);
214e1eca 468extern int fio_cmd_option_parse(struct thread_data *, const char *, char *);
de890a1e 469extern int fio_cmd_ioengine_option_parse(struct thread_data *, const char *, char *);
214e1eca
JA
470extern void fio_fill_default_options(struct thread_data *);
471extern int fio_show_option_help(const char *);
de890a1e 472extern void fio_options_set_ioengine_opts(struct option *long_options, struct thread_data *td);
214e1eca 473extern void fio_options_dup_and_init(struct option *);
de890a1e
SL
474extern void fio_options_mem_dupe(struct thread_data *);
475extern void options_mem_dupe(void *data, struct fio_option *options);
5bfc35d7 476extern void td_fill_rand_seeds(struct thread_data *);
46bcd498 477extern void add_job_opts(const char **, int);
ca09be4b 478extern char *num2str(uint64_t, int, int, int, int);
de890a1e 479extern int ioengine_load(struct thread_data *);
f9633d72 480extern int parse_dryrun(void);
046395d7 481extern int fio_running_or_pending_io_threads(void);
3a35845f 482extern int fio_set_fd_nonblocking(int, const char *);
1ec3d69b 483
a569b45f
JA
484extern uintptr_t page_mask;
485extern uintptr_t page_size;
486extern int initialize_fio(char *envp[]);
af1dc266 487extern void deinitialize_fio(void);
a569b45f 488
de890a1e
SL
489#define FIO_GETOPT_JOB 0x89000000
490#define FIO_GETOPT_IOENGINE 0x98000000
07b3232d 491#define FIO_NR_OPTIONS (FIO_MAX_OPTS + 128)
8914a9d8 492
263e529f
JA
493/*
494 * ETA/status stuff
495 */
496extern void print_thread_status(void);
497extern void print_status_init(int);
0a428b23 498extern char *fio_uint_to_kmg(unsigned int val);
263e529f
JA
499
500/*
501 * Thread life cycle. Once a thread has a runstate beyond TD_INITIALIZED, it
502 * will never back again. It may cycle between running/verififying/fsyncing.
503 * Once the thread reaches TD_EXITED, it is just waiting for the core to
504 * reap it.
505 */
506enum {
507 TD_NOT_CREATED = 0,
508 TD_CREATED,
509 TD_INITIALIZED,
b29ee5b3 510 TD_RAMP,
36d80bc7 511 TD_SETTING_UP,
263e529f 512 TD_RUNNING,
b0f65863 513 TD_PRE_READING,
263e529f
JA
514 TD_VERIFYING,
515 TD_FSYNCING,
3d434057 516 TD_FINISHING,
263e529f
JA
517 TD_EXITED,
518 TD_REAPED,
519};
520
b29ee5b3 521extern void td_set_runstate(struct thread_data *, int);
8edd973d
JA
522extern int td_bump_runstate(struct thread_data *, int);
523extern void td_restore_runstate(struct thread_data *, int);
524
cba5460c
JA
525/*
526 * Allow 60 seconds for a job to quit on its own, otherwise reap with
527 * a vengeance.
528 */
529#define FIO_REAP_TIMEOUT 60
530
cc0df00a
JA
531#define TERMINATE_ALL (-1)
532extern void fio_terminate_threads(int);
ebea2133 533extern void fio_mark_td_terminate(struct thread_data *);
b29ee5b3 534
2f9ade3c
JA
535/*
536 * Memory helpers
537 */
9a3f1100
JA
538extern int __must_check fio_pin_memory(struct thread_data *);
539extern void fio_unpin_memory(struct thread_data *);
b2fdda43 540extern int __must_check allocate_io_mem(struct thread_data *);
2f9ade3c 541extern void free_io_mem(struct thread_data *);
2bb3f0a7 542extern void free_threads_shm(void);
2f9ade3c 543
b29ee5b3
JA
544/*
545 * Reset stats after ramp time completes
546 */
547extern void reset_all_stats(struct thread_data *);
548
fb7b71a3
JA
549/*
550 * blktrace support
551 */
5e62c22a 552#ifdef FIO_HAVE_BLKTRACE
d95b34a6
JA
553extern int is_blktrace(const char *, int *);
554extern int load_blktrace(struct thread_data *, const char *, int);
5e62c22a 555#endif
fb7b71a3 556
3e260a46
JA
557/*
558 * Latency target helpers
559 */
560extern void lat_target_check(struct thread_data *);
561extern void lat_target_init(struct thread_data *);
6bb58215 562extern void lat_target_reset(struct thread_data *);
3e260a46 563
34572e28
JA
564#define for_each_td(td, i) \
565 for ((i) = 0, (td) = &threads[0]; (i) < (int) thread_number; (i)++, (td)++)
53cdc686 566#define for_each_file(td, f, i) \
691c8fb0
JA
567 if ((td)->files_index) \
568 for ((i) = 0, (f) = (td)->files[0]; \
569 (i) < (td)->o.nr_files && ((f) = (td)->files[i]) != NULL; \
570 (i)++)
53cdc686 571
0032bf9f
JA
572#define fio_assert(td, cond) do { \
573 if (!(cond)) { \
340fd243 574 int *__foo = NULL; \
0032bf9f 575 fprintf(stderr, "file:%s:%d, assert %s failed\n", __FILE__, __LINE__, #cond); \
ac18ea38 576 td_set_runstate((td), TD_EXITED); \
437c9b71 577 (td)->error = EFAULT; \
340fd243 578 *__foo = 0; \
0032bf9f
JA
579 } \
580} while (0)
581
12d9d841
JA
582static inline int fio_fill_issue_time(struct thread_data *td)
583{
584 if (td->o.read_iolog_file ||
585 !td->o.disable_clat || !td->o.disable_slat || !td->o.disable_bw)
586 return 1;
587
588 return 0;
589}
590
581e7141
JA
591static inline int __should_check_rate(struct thread_data *td,
592 enum fio_ddir ddir)
593{
594 struct thread_options *o = &td->o;
595
596 /*
597 * If some rate setting was given, we need to check it
598 */
599 if (o->rate[ddir] || o->ratemin[ddir] || o->rate_iops[ddir] ||
600 o->rate_iops_min[ddir])
601 return 1;
602
603 return 0;
604}
605
55312f9f 606static inline int should_check_rate(struct thread_data *td)
581e7141
JA
607{
608 int ret = 0;
609
55312f9f 610 if (td->bytes_done[DDIR_READ])
6eaf09d6 611 ret |= __should_check_rate(td, DDIR_READ);
55312f9f 612 if (td->bytes_done[DDIR_WRITE])
6eaf09d6 613 ret |= __should_check_rate(td, DDIR_WRITE);
55312f9f 614 if (td->bytes_done[DDIR_TRIM])
6eaf09d6 615 ret |= __should_check_rate(td, DDIR_TRIM);
581e7141
JA
616
617 return ret;
618}
619
74f4b020
JA
620static inline unsigned int td_max_bs(struct thread_data *td)
621{
622 unsigned int max_bs;
623
624 max_bs = max(td->o.max_bs[DDIR_READ], td->o.max_bs[DDIR_WRITE]);
625 return max(td->o.max_bs[DDIR_TRIM], max_bs);
626}
627
8d916c94
JA
628static inline unsigned int td_min_bs(struct thread_data *td)
629{
630 unsigned int min_bs;
631
632 min_bs = min(td->o.min_bs[DDIR_READ], td->o.min_bs[DDIR_WRITE]);
633 return min(td->o.min_bs[DDIR_TRIM], min_bs);
634}
635
a9da8ab2
JA
636static inline int td_async_processing(struct thread_data *td)
637{
638 return (td->flags & TD_F_NEED_LOCK) != 0;
639}
640
e8462bd8
JA
641/*
642 * We currently only need to do locking if we have verifier threads
643 * accessing our internal structures too
644 */
645static inline void td_io_u_lock(struct thread_data *td)
646{
a9da8ab2 647 if (td_async_processing(td))
e8462bd8
JA
648 pthread_mutex_lock(&td->io_u_lock);
649}
650
651static inline void td_io_u_unlock(struct thread_data *td)
652{
a9da8ab2 653 if (td_async_processing(td))
e8462bd8
JA
654 pthread_mutex_unlock(&td->io_u_lock);
655}
656
657static inline void td_io_u_free_notify(struct thread_data *td)
658{
a9da8ab2 659 if (td_async_processing(td))
e8462bd8
JA
660 pthread_cond_signal(&td->free_cond);
661}
662
cca84643
JA
663extern const char *fio_get_arch_string(int);
664extern const char *fio_get_os_string(int);
665
e2c81040 666#ifdef FIO_INTERNAL
05775438 667#define ARRAY_SIZE(x) (sizeof((x)) / (sizeof((x)[0])))
e2c81040 668#endif
05775438 669
f3afa57e
JA
670enum {
671 FIO_OUTPUT_TERSE = 0,
672 FIO_OUTPUT_JSON,
673 FIO_OUTPUT_NORMAL,
674};
675
e25839d4
JA
676enum {
677 FIO_RAND_DIST_RANDOM = 0,
678 FIO_RAND_DIST_ZIPF,
925fee33 679 FIO_RAND_DIST_PARETO,
56d9fa4b 680 FIO_RAND_DIST_GAUSS,
e25839d4
JA
681};
682
c95f9404
JA
683#define FIO_DEF_ZIPF 1.1
684#define FIO_DEF_PARETO 0.2
685
8055e41d
JA
686enum {
687 FIO_RAND_GEN_TAUSWORTHE = 0,
688 FIO_RAND_GEN_LFSR,
c3546b53 689 FIO_RAND_GEN_TAUSWORTHE64,
8055e41d
JA
690};
691
c2acfbac
JA
692enum {
693 FIO_CPUS_SHARED = 0,
694 FIO_CPUS_SPLIT,
695};
696
ca09be4b
JA
697extern void exec_trigger(const char *);
698extern void check_trigger_file(void);
699
ebac4655 700#endif