io_u: use nsec value for buffer scramble
[fio.git] / fio.h
... / ...
CommitLineData
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>
9#include <errno.h>
10#include <stdlib.h>
11#include <stdio.h>
12#include <unistd.h>
13#include <string.h>
14#include <inttypes.h>
15#include <assert.h>
16
17#include "compiler/compiler.h"
18#include "thread_options.h"
19#include "flist.h"
20#include "fifo.h"
21#include "arch/arch.h"
22#include "os/os.h"
23#include "mutex.h"
24#include "log.h"
25#include "debug.h"
26#include "file.h"
27#include "io_ddir.h"
28#include "ioengines.h"
29#include "iolog.h"
30#include "helpers.h"
31#include "options.h"
32#include "profile.h"
33#include "fio_time.h"
34#include "gettime.h"
35#include "oslib/getopt.h"
36#include "lib/rand.h"
37#include "lib/rbtree.h"
38#include "lib/num2str.h"
39#include "client.h"
40#include "server.h"
41#include "stat.h"
42#include "flow.h"
43#include "io_u.h"
44#include "io_u_queue.h"
45#include "workqueue.h"
46#include "steadystate.h"
47
48#ifdef CONFIG_SOLARISAIO
49#include <sys/asynch.h>
50#endif
51
52#ifdef CONFIG_LIBNUMA
53#include <linux/mempolicy.h>
54#include <numa.h>
55
56/*
57 * "local" is pseudo-policy
58 */
59#define MPOL_LOCAL MPOL_MAX
60#endif
61
62#ifdef CONFIG_CUDA
63#include <cuda.h>
64#endif
65
66/*
67 * offset generator types
68 */
69enum {
70 RW_SEQ_SEQ = 0,
71 RW_SEQ_IDENT,
72};
73
74enum {
75 __TD_F_VER_BACKLOG = 0,
76 __TD_F_TRIM_BACKLOG,
77 __TD_F_READ_IOLOG,
78 __TD_F_REFILL_BUFFERS,
79 __TD_F_SCRAMBLE_BUFFERS,
80 __TD_F_VER_NONE,
81 __TD_F_PROFILE_OPS,
82 __TD_F_COMPRESS,
83 __TD_F_COMPRESS_LOG,
84 __TD_F_VSTATE_SAVED,
85 __TD_F_NEED_LOCK,
86 __TD_F_CHILD,
87 __TD_F_NO_PROGRESS,
88 __TD_F_REGROW_LOGS,
89 __TD_F_MMAP_KEEP,
90 __TD_F_DIRS_CREATED,
91 __TD_F_LAST, /* not a real bit, keep last */
92};
93
94enum {
95 TD_F_VER_BACKLOG = 1U << __TD_F_VER_BACKLOG,
96 TD_F_TRIM_BACKLOG = 1U << __TD_F_TRIM_BACKLOG,
97 TD_F_READ_IOLOG = 1U << __TD_F_READ_IOLOG,
98 TD_F_REFILL_BUFFERS = 1U << __TD_F_REFILL_BUFFERS,
99 TD_F_SCRAMBLE_BUFFERS = 1U << __TD_F_SCRAMBLE_BUFFERS,
100 TD_F_VER_NONE = 1U << __TD_F_VER_NONE,
101 TD_F_PROFILE_OPS = 1U << __TD_F_PROFILE_OPS,
102 TD_F_COMPRESS = 1U << __TD_F_COMPRESS,
103 TD_F_COMPRESS_LOG = 1U << __TD_F_COMPRESS_LOG,
104 TD_F_VSTATE_SAVED = 1U << __TD_F_VSTATE_SAVED,
105 TD_F_NEED_LOCK = 1U << __TD_F_NEED_LOCK,
106 TD_F_CHILD = 1U << __TD_F_CHILD,
107 TD_F_NO_PROGRESS = 1U << __TD_F_NO_PROGRESS,
108 TD_F_REGROW_LOGS = 1U << __TD_F_REGROW_LOGS,
109 TD_F_MMAP_KEEP = 1U << __TD_F_MMAP_KEEP,
110 TD_F_DIRS_CREATED = 1U << __TD_F_DIRS_CREATED,
111};
112
113enum {
114 FIO_RAND_BS_OFF = 0,
115 FIO_RAND_BS1_OFF,
116 FIO_RAND_BS2_OFF,
117 FIO_RAND_VER_OFF,
118 FIO_RAND_MIX_OFF,
119 FIO_RAND_FILE_OFF,
120 FIO_RAND_BLOCK_OFF,
121 FIO_RAND_FILE_SIZE_OFF,
122 FIO_RAND_TRIM_OFF,
123 FIO_RAND_BUF_OFF,
124 FIO_RAND_SEQ_RAND_READ_OFF,
125 FIO_RAND_SEQ_RAND_WRITE_OFF,
126 FIO_RAND_SEQ_RAND_TRIM_OFF,
127 FIO_RAND_START_DELAY,
128 FIO_DEDUPE_OFF,
129 FIO_RAND_POISSON_OFF,
130 FIO_RAND_ZONE_OFF,
131 FIO_RAND_POISSON2_OFF,
132 FIO_RAND_POISSON3_OFF,
133 FIO_RAND_NR_OFFS,
134};
135
136enum {
137 IO_MODE_INLINE = 0,
138 IO_MODE_OFFLOAD = 1,
139
140 RATE_PROCESS_LINEAR = 0,
141 RATE_PROCESS_POISSON = 1,
142};
143
144enum {
145 F_ADV_NONE = 0,
146 F_ADV_TYPE,
147 F_ADV_RANDOM,
148 F_ADV_SEQUENTIAL,
149};
150
151/*
152 * Per-thread/process specific data. Only used for the network client
153 * for now.
154 */
155void sk_out_assign(struct sk_out *);
156void sk_out_drop(void);
157
158struct zone_split_index {
159 uint8_t size_perc;
160 uint8_t size_perc_prev;
161 uint64_t size;
162 uint64_t size_prev;
163};
164
165/*
166 * This describes a single thread/process executing a fio job.
167 */
168struct thread_data {
169 struct flist_head opt_list;
170 unsigned long flags;
171 struct thread_options o;
172 void *eo;
173 pthread_t thread;
174 unsigned int thread_number;
175 unsigned int subjob_number;
176 unsigned int groupid;
177 struct thread_stat ts __attribute__ ((aligned(8)));
178
179 int client_type;
180
181 struct io_log *slat_log;
182 struct io_log *clat_log;
183 struct io_log *clat_hist_log;
184 struct io_log *lat_log;
185 struct io_log *bw_log;
186 struct io_log *iops_log;
187
188 struct workqueue log_compress_wq;
189
190 struct thread_data *parent;
191
192 uint64_t stat_io_bytes[DDIR_RWDIR_CNT];
193 struct timespec bw_sample_time;
194
195 uint64_t stat_io_blocks[DDIR_RWDIR_CNT];
196 struct timespec iops_sample_time;
197
198 volatile int update_rusage;
199 struct fio_mutex *rusage_sem;
200 struct rusage ru_start;
201 struct rusage ru_end;
202
203 struct fio_file **files;
204 unsigned char *file_locks;
205 unsigned int files_size;
206 unsigned int files_index;
207 unsigned int nr_open_files;
208 unsigned int nr_done_files;
209 unsigned int nr_normal_files;
210 union {
211 unsigned int next_file;
212 struct frand_state next_file_state;
213 };
214 union {
215 struct zipf_state next_file_zipf;
216 struct gauss_state next_file_gauss;
217 };
218 union {
219 double zipf_theta;
220 double pareto_h;
221 double gauss_dev;
222 };
223 int error;
224 int sig;
225 int done;
226 int stop_io;
227 pid_t pid;
228 char *orig_buffer;
229 size_t orig_buffer_size;
230 volatile int terminate;
231 volatile int runstate;
232 unsigned int last_was_sync;
233 enum fio_ddir last_ddir;
234
235 int mmapfd;
236
237 void *iolog_buf;
238 FILE *iolog_f;
239
240 unsigned long rand_seeds[FIO_RAND_NR_OFFS];
241
242 struct frand_state bsrange_state[DDIR_RWDIR_CNT];
243 struct frand_state verify_state;
244 struct frand_state trim_state;
245 struct frand_state delay_state;
246
247 struct frand_state buf_state;
248 struct frand_state buf_state_prev;
249 struct frand_state dedupe_state;
250 struct frand_state zone_state;
251
252 struct zone_split_index **zone_state_index;
253
254 unsigned int verify_batch;
255 unsigned int trim_batch;
256
257 struct thread_io_list *vstate;
258
259 int shm_id;
260
261 /*
262 * IO engine hooks, contains everything needed to submit an io_u
263 * to any of the available IO engines.
264 */
265 struct ioengine_ops *io_ops;
266 int io_ops_init;
267
268 /*
269 * IO engine private data and dlhandle.
270 */
271 void *io_ops_data;
272 void *io_ops_dlhandle;
273
274 /*
275 * Queue depth of io_u's that fio MIGHT do
276 */
277 unsigned int cur_depth;
278
279 /*
280 * io_u's about to be committed
281 */
282 unsigned int io_u_queued;
283
284 /*
285 * io_u's submitted but not completed yet
286 */
287 unsigned int io_u_in_flight;
288
289 /*
290 * List of free and busy io_u's
291 */
292 struct io_u_ring io_u_requeues;
293 struct io_u_queue io_u_freelist;
294 struct io_u_queue io_u_all;
295 pthread_mutex_t io_u_lock;
296 pthread_cond_t free_cond;
297
298 /*
299 * async verify offload
300 */
301 struct flist_head verify_list;
302 pthread_t *verify_threads;
303 unsigned int nr_verify_threads;
304 pthread_cond_t verify_cond;
305 int verify_thread_exit;
306
307 /*
308 * Rate state
309 */
310 uint64_t rate_bps[DDIR_RWDIR_CNT];
311 uint64_t rate_next_io_time[DDIR_RWDIR_CNT];
312 unsigned long rate_bytes[DDIR_RWDIR_CNT];
313 unsigned long rate_blocks[DDIR_RWDIR_CNT];
314 unsigned long long rate_io_issue_bytes[DDIR_RWDIR_CNT];
315 struct timespec lastrate[DDIR_RWDIR_CNT];
316 int64_t last_usec[DDIR_RWDIR_CNT];
317 struct frand_state poisson_state[DDIR_RWDIR_CNT];
318
319 /*
320 * Enforced rate submission/completion workqueue
321 */
322 struct workqueue io_wq;
323
324 uint64_t total_io_size;
325 uint64_t fill_device_size;
326
327 /*
328 * Issue side
329 */
330 uint64_t io_issues[DDIR_RWDIR_CNT];
331 uint64_t io_issue_bytes[DDIR_RWDIR_CNT];
332 uint64_t loops;
333
334 /*
335 * Completions
336 */
337 uint64_t io_blocks[DDIR_RWDIR_CNT];
338 uint64_t this_io_blocks[DDIR_RWDIR_CNT];
339 uint64_t io_bytes[DDIR_RWDIR_CNT];
340 uint64_t this_io_bytes[DDIR_RWDIR_CNT];
341 uint64_t io_skip_bytes;
342 uint64_t zone_bytes;
343 struct fio_mutex *mutex;
344 uint64_t bytes_done[DDIR_RWDIR_CNT];
345
346 /*
347 * State for random io, a bitmap of blocks done vs not done
348 */
349 struct frand_state random_state;
350
351 struct timespec start; /* start of this loop */
352 struct timespec epoch; /* time job was started */
353 unsigned long long unix_epoch; /* Time job was started, unix epoch based. */
354 struct timespec last_issue;
355 long time_offset;
356 struct timespec ts_cache;
357 struct timespec terminate_time;
358 unsigned int ts_cache_nr;
359 unsigned int ts_cache_mask;
360 bool ramp_time_over;
361
362 /*
363 * Time since last latency_window was started
364 */
365 struct timespec latency_ts;
366 unsigned int latency_qd;
367 unsigned int latency_qd_high;
368 unsigned int latency_qd_low;
369 unsigned int latency_failed;
370 uint64_t latency_ios;
371 int latency_end_run;
372
373 /*
374 * read/write mixed workload state
375 */
376 struct frand_state rwmix_state;
377 unsigned long rwmix_issues;
378 enum fio_ddir rwmix_ddir;
379 unsigned int ddir_seq_nr;
380
381 /*
382 * rand/seq mixed workload state
383 */
384 struct frand_state seq_rand_state[DDIR_RWDIR_CNT];
385
386 /*
387 * IO history logs for verification. We use a tree for sorting,
388 * if we are overwriting. Otherwise just use a fifo.
389 */
390 struct rb_root io_hist_tree;
391 struct flist_head io_hist_list;
392 unsigned long io_hist_len;
393
394 /*
395 * For IO replaying
396 */
397 struct flist_head io_log_list;
398
399 /*
400 * For tracking/handling discards
401 */
402 struct flist_head trim_list;
403 unsigned long trim_entries;
404
405 struct flist_head next_rand_list;
406
407 /*
408 * for fileservice, how often to switch to a new file
409 */
410 unsigned int file_service_nr;
411 unsigned int file_service_left;
412 struct fio_file *file_service_file;
413
414 unsigned int sync_file_range_nr;
415
416 /*
417 * For generating file sizes
418 */
419 struct frand_state file_size_state;
420
421 /*
422 * Error counts
423 */
424 unsigned int total_err_count;
425 int first_error;
426
427 struct fio_flow *flow;
428
429 /*
430 * Can be overloaded by profiles
431 */
432 struct prof_io_ops prof_io_ops;
433 void *prof_data;
434
435 void *pinned_mem;
436
437 struct steadystate_data ss;
438
439 char verror[FIO_VERROR_SIZE];
440
441#ifdef CONFIG_CUDA
442 /*
443 * for GPU memory management
444 */
445 int gpu_dev_cnt;
446 int gpu_dev_id;
447 CUdevice cu_dev;
448 CUcontext cu_ctx;
449 CUdeviceptr dev_mem_ptr;
450#endif
451
452};
453
454/*
455 * when should interactive ETA output be generated
456 */
457enum {
458 FIO_ETA_AUTO,
459 FIO_ETA_ALWAYS,
460 FIO_ETA_NEVER,
461};
462
463#define __td_verror(td, err, msg, func) \
464 do { \
465 unsigned int ____e = (err); \
466 if ((td)->error) \
467 break; \
468 (td)->error = ____e; \
469 if (!(td)->first_error) \
470 snprintf(td->verror, sizeof(td->verror), "file:%s:%d, func=%s, error=%s", __FILE__, __LINE__, (func), (msg)); \
471 } while (0)
472
473
474#define td_clear_error(td) do { \
475 (td)->error = 0; \
476 if ((td)->parent) \
477 (td)->parent->error = 0; \
478} while (0)
479
480#define td_verror(td, err, func) do { \
481 __td_verror((td), (err), strerror((err)), (func)); \
482 if ((td)->parent) \
483 __td_verror((td)->parent, (err), strerror((err)), (func)); \
484} while (0)
485
486#define td_vmsg(td, err, msg, func) do { \
487 __td_verror((td), (err), (msg), (func)); \
488 if ((td)->parent) \
489 __td_verror((td)->parent, (err), (msg), (func)); \
490} while (0)
491
492#define __fio_stringify_1(x) #x
493#define __fio_stringify(x) __fio_stringify_1(x)
494
495extern int exitall_on_terminate;
496extern unsigned int thread_number;
497extern unsigned int stat_number;
498extern int shm_id;
499extern int groupid;
500extern int output_format;
501extern int append_terse_output;
502extern int temp_stall_ts;
503extern uintptr_t page_mask, page_size;
504extern int read_only;
505extern int eta_print;
506extern int eta_new_line;
507extern unsigned long done_secs;
508extern int fio_gtod_offload;
509extern int fio_gtod_cpu;
510extern enum fio_cs fio_clock_source;
511extern int fio_clock_source_set;
512extern int warnings_fatal;
513extern int terse_version;
514extern int is_backend;
515extern int nr_clients;
516extern int log_syslog;
517extern int status_interval;
518extern const char fio_version_string[];
519extern char *trigger_file;
520extern char *trigger_cmd;
521extern char *trigger_remote_cmd;
522extern long long trigger_timeout;
523extern char *aux_path;
524
525extern struct thread_data *threads;
526
527static inline void fio_ro_check(const struct thread_data *td, struct io_u *io_u)
528{
529 assert(!(io_u->ddir == DDIR_WRITE && !td_write(td)));
530}
531
532#define REAL_MAX_JOBS 4096
533
534static inline int should_fsync(struct thread_data *td)
535{
536 if (td->last_was_sync)
537 return 0;
538 if (td_write(td) || td->o.override_sync)
539 return 1;
540
541 return 0;
542}
543
544/*
545 * Init/option functions
546 */
547extern int __must_check fio_init_options(void);
548extern int __must_check parse_options(int, char **);
549extern int parse_jobs_ini(char *, int, int, int);
550extern int parse_cmd_line(int, char **, int);
551extern int fio_backend(struct sk_out *);
552extern void reset_fio_state(void);
553extern void clear_io_state(struct thread_data *, int);
554extern int fio_options_parse(struct thread_data *, char **, int);
555extern void fio_keywords_init(void);
556extern void fio_keywords_exit(void);
557extern int fio_cmd_option_parse(struct thread_data *, const char *, char *);
558extern int fio_cmd_ioengine_option_parse(struct thread_data *, const char *, char *);
559extern void fio_fill_default_options(struct thread_data *);
560extern int fio_show_option_help(const char *);
561extern void fio_options_set_ioengine_opts(struct option *long_options, struct thread_data *td);
562extern void fio_options_dup_and_init(struct option *);
563extern void fio_options_mem_dupe(struct thread_data *);
564extern void td_fill_rand_seeds(struct thread_data *);
565extern void td_fill_verify_state_seed(struct thread_data *);
566extern void add_job_opts(const char **, int);
567extern int ioengine_load(struct thread_data *);
568extern bool parse_dryrun(void);
569extern int fio_running_or_pending_io_threads(void);
570extern int fio_set_fd_nonblocking(int, const char *);
571extern void sig_show_status(int sig);
572extern struct thread_data *get_global_options(void);
573
574extern uintptr_t page_mask;
575extern uintptr_t page_size;
576extern int initialize_fio(char *envp[]);
577extern void deinitialize_fio(void);
578
579#define FIO_GETOPT_JOB 0x89000000
580#define FIO_GETOPT_IOENGINE 0x98000000
581#define FIO_NR_OPTIONS (FIO_MAX_OPTS + 128)
582
583/*
584 * ETA/status stuff
585 */
586extern void print_thread_status(void);
587extern void print_status_init(int);
588extern char *fio_uint_to_kmg(unsigned int val);
589
590/*
591 * Thread life cycle. Once a thread has a runstate beyond TD_INITIALIZED, it
592 * will never back again. It may cycle between running/verififying/fsyncing.
593 * Once the thread reaches TD_EXITED, it is just waiting for the core to
594 * reap it.
595 */
596enum {
597 TD_NOT_CREATED = 0,
598 TD_CREATED,
599 TD_INITIALIZED,
600 TD_RAMP,
601 TD_SETTING_UP,
602 TD_RUNNING,
603 TD_PRE_READING,
604 TD_VERIFYING,
605 TD_FSYNCING,
606 TD_FINISHING,
607 TD_EXITED,
608 TD_REAPED,
609 TD_LAST,
610 TD_NR,
611};
612
613#define TD_ENG_FLAG_SHIFT 16
614#define TD_ENG_FLAG_MASK ((1U << 16) - 1)
615
616static inline void td_set_ioengine_flags(struct thread_data *td)
617{
618 td->flags = (~(TD_ENG_FLAG_MASK << TD_ENG_FLAG_SHIFT) & td->flags) |
619 (td->io_ops->flags << TD_ENG_FLAG_SHIFT);
620}
621
622static inline bool td_ioengine_flagged(struct thread_data *td,
623 enum fio_ioengine_flags flags)
624{
625 return ((td->flags >> TD_ENG_FLAG_SHIFT) & flags) != 0;
626}
627
628extern void td_set_runstate(struct thread_data *, int);
629extern int td_bump_runstate(struct thread_data *, int);
630extern void td_restore_runstate(struct thread_data *, int);
631extern const char *runstate_to_name(int runstate);
632
633/*
634 * Allow 60 seconds for a job to quit on its own, otherwise reap with
635 * a vengeance.
636 */
637#define FIO_REAP_TIMEOUT 300
638
639#define TERMINATE_ALL (-1U)
640extern void fio_terminate_threads(unsigned int);
641extern void fio_mark_td_terminate(struct thread_data *);
642
643/*
644 * Memory helpers
645 */
646extern int __must_check fio_pin_memory(struct thread_data *);
647extern void fio_unpin_memory(struct thread_data *);
648extern int __must_check allocate_io_mem(struct thread_data *);
649extern void free_io_mem(struct thread_data *);
650extern void free_threads_shm(void);
651
652#ifdef FIO_INTERNAL
653#define PTR_ALIGN(ptr, mask) \
654 (char *) (((uintptr_t) (ptr) + (mask)) & ~(mask))
655#endif
656
657/*
658 * Reset stats after ramp time completes
659 */
660extern void reset_all_stats(struct thread_data *);
661
662extern int io_queue_event(struct thread_data *td, struct io_u *io_u, int *ret,
663 enum fio_ddir ddir, uint64_t *bytes_issued, int from_verify,
664 struct timespec *comp_time);
665
666/*
667 * Latency target helpers
668 */
669extern void lat_target_check(struct thread_data *);
670extern void lat_target_init(struct thread_data *);
671extern void lat_target_reset(struct thread_data *);
672
673/*
674 * Iterates all threads/processes within all the defined jobs
675 */
676#define for_each_td(td, i) \
677 for ((i) = 0, (td) = &threads[0]; (i) < (int) thread_number; (i)++, (td)++)
678#define for_each_file(td, f, i) \
679 if ((td)->files_index) \
680 for ((i) = 0, (f) = (td)->files[0]; \
681 (i) < (td)->o.nr_files && ((f) = (td)->files[i]) != NULL; \
682 (i)++)
683
684#define fio_assert(td, cond) do { \
685 if (!(cond)) { \
686 int *__foo = NULL; \
687 fprintf(stderr, "file:%s:%d, assert %s failed\n", __FILE__, __LINE__, #cond); \
688 td_set_runstate((td), TD_EXITED); \
689 (td)->error = EFAULT; \
690 *__foo = 0; \
691 } \
692} while (0)
693
694static inline bool fio_fill_issue_time(struct thread_data *td)
695{
696 if (td->o.read_iolog_file ||
697 !td->o.disable_clat || !td->o.disable_slat || !td->o.disable_bw)
698 return true;
699
700 return false;
701}
702
703static inline bool __should_check_rate(struct thread_data *td,
704 enum fio_ddir ddir)
705{
706 struct thread_options *o = &td->o;
707
708 /*
709 * If some rate setting was given, we need to check it
710 */
711 if (o->rate[ddir] || o->ratemin[ddir] || o->rate_iops[ddir] ||
712 o->rate_iops_min[ddir])
713 return true;
714
715 return false;
716}
717
718static inline bool should_check_rate(struct thread_data *td)
719{
720 if (td->bytes_done[DDIR_READ] && __should_check_rate(td, DDIR_READ))
721 return true;
722 if (td->bytes_done[DDIR_WRITE] && __should_check_rate(td, DDIR_WRITE))
723 return true;
724 if (td->bytes_done[DDIR_TRIM] && __should_check_rate(td, DDIR_TRIM))
725 return true;
726
727 return false;
728}
729
730static inline unsigned int td_max_bs(struct thread_data *td)
731{
732 unsigned int max_bs;
733
734 max_bs = max(td->o.max_bs[DDIR_READ], td->o.max_bs[DDIR_WRITE]);
735 return max(td->o.max_bs[DDIR_TRIM], max_bs);
736}
737
738static inline unsigned int td_min_bs(struct thread_data *td)
739{
740 unsigned int min_bs;
741
742 min_bs = min(td->o.min_bs[DDIR_READ], td->o.min_bs[DDIR_WRITE]);
743 return min(td->o.min_bs[DDIR_TRIM], min_bs);
744}
745
746static inline bool td_async_processing(struct thread_data *td)
747{
748 return (td->flags & TD_F_NEED_LOCK) != 0;
749}
750
751/*
752 * We currently only need to do locking if we have verifier threads
753 * accessing our internal structures too
754 */
755static inline void td_io_u_lock(struct thread_data *td)
756{
757 if (td_async_processing(td))
758 pthread_mutex_lock(&td->io_u_lock);
759}
760
761static inline void td_io_u_unlock(struct thread_data *td)
762{
763 if (td_async_processing(td))
764 pthread_mutex_unlock(&td->io_u_lock);
765}
766
767static inline void td_io_u_free_notify(struct thread_data *td)
768{
769 if (td_async_processing(td))
770 pthread_cond_signal(&td->free_cond);
771}
772
773static inline void td_flags_clear(struct thread_data *td, unsigned int *flags,
774 unsigned int value)
775{
776 if (!td_async_processing(td))
777 *flags &= ~value;
778 else
779 __sync_fetch_and_and(flags, ~value);
780}
781
782static inline void td_flags_set(struct thread_data *td, unsigned int *flags,
783 unsigned int value)
784{
785 if (!td_async_processing(td))
786 *flags |= value;
787 else
788 __sync_fetch_and_or(flags, value);
789}
790
791extern const char *fio_get_arch_string(int);
792extern const char *fio_get_os_string(int);
793
794#ifdef FIO_INTERNAL
795#define ARRAY_SIZE(x) (sizeof((x)) / (sizeof((x)[0])))
796#define FIELD_SIZE(s, f) (sizeof(((typeof(s))0)->f))
797#endif
798
799enum {
800 __FIO_OUTPUT_TERSE = 0,
801 __FIO_OUTPUT_JSON = 1,
802 __FIO_OUTPUT_NORMAL = 2,
803 __FIO_OUTPUT_JSON_PLUS = 3,
804 FIO_OUTPUT_NR = 4,
805
806 FIO_OUTPUT_TERSE = 1U << __FIO_OUTPUT_TERSE,
807 FIO_OUTPUT_JSON = 1U << __FIO_OUTPUT_JSON,
808 FIO_OUTPUT_NORMAL = 1U << __FIO_OUTPUT_NORMAL,
809 FIO_OUTPUT_JSON_PLUS = 1U << __FIO_OUTPUT_JSON_PLUS,
810};
811
812enum {
813 FIO_RAND_DIST_RANDOM = 0,
814 FIO_RAND_DIST_ZIPF,
815 FIO_RAND_DIST_PARETO,
816 FIO_RAND_DIST_GAUSS,
817 FIO_RAND_DIST_ZONED,
818 FIO_RAND_DIST_ZONED_ABS,
819};
820
821#define FIO_DEF_ZIPF 1.1
822#define FIO_DEF_PARETO 0.2
823
824enum {
825 FIO_RAND_GEN_TAUSWORTHE = 0,
826 FIO_RAND_GEN_LFSR,
827 FIO_RAND_GEN_TAUSWORTHE64,
828};
829
830enum {
831 FIO_CPUS_SHARED = 0,
832 FIO_CPUS_SPLIT,
833};
834
835extern void exec_trigger(const char *);
836extern void check_trigger_file(void);
837
838#endif