[PATCH] syslet: fix leak of ring and ahu
[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>
ebac4655
JA
14
15#include "list.h"
16#include "md5.h"
17#include "crc32.h"
18#include "arch.h"
19#include "os.h"
20
a4f4fdd7
JA
21#include "syslet.h"
22
1e97cce9
JA
23enum fio_ddir {
24 DDIR_READ = 0,
25 DDIR_WRITE,
26 DDIR_SYNC,
27};
28
1c9e06ee
JA
29/*
30 * Use for maintaining statistics
31 */
ebac4655 32struct io_stat {
ebac4655
JA
33 unsigned long max_val;
34 unsigned long min_val;
35 unsigned long samples;
68704084
JA
36
37 double mean;
38 double S;
ebac4655
JA
39};
40
1c9e06ee
JA
41/*
42 * A single data sample
43 */
ebac4655
JA
44struct io_sample {
45 unsigned long time;
46 unsigned long val;
1e97cce9 47 enum fio_ddir ddir;
ebac4655
JA
48};
49
1c9e06ee
JA
50/*
51 * Dynamically growing data sample log
52 */
ebac4655
JA
53struct io_log {
54 unsigned long nr_samples;
55 unsigned long max_samples;
56 struct io_sample *log;
57};
58
1c9e06ee
JA
59/*
60 * When logging io actions, this matches a single sent io_u
61 */
ebac4655
JA
62struct io_piece {
63 struct list_head list;
53cdc686 64 struct fio_file *file;
ebac4655 65 unsigned long long offset;
a4f4fdd7 66 unsigned long len;
1e97cce9 67 enum fio_ddir ddir;
ebac4655
JA
68};
69
a4f4fdd7
JA
70#ifdef FIO_HAVE_SYSLET
71struct syslet_req {
72 struct syslet_uatom atom;
a4f4fdd7
JA
73 long ret;
74};
75#endif
76
ebac4655
JA
77/*
78 * The io unit
79 */
80struct io_u {
81 union {
82#ifdef FIO_HAVE_LIBAIO
83 struct iocb iocb;
84#endif
85#ifdef FIO_HAVE_POSIXAIO
86 struct aiocb aiocb;
87#endif
88#ifdef FIO_HAVE_SGIO
89 struct sg_io_hdr hdr;
a4f4fdd7
JA
90#endif
91#ifdef FIO_HAVE_SYSLET
a2e1b08a 92 struct syslet_req req;
ebac4655
JA
93#endif
94 };
95 struct timeval start_time;
96 struct timeval issue_time;
97
1c9e06ee
JA
98 /*
99 * Allocated/set buffer and length
100 */
6b9cea23 101 void *buf;
a4f4fdd7 102 unsigned long buflen;
ebac4655
JA
103 unsigned long long offset;
104
1c9e06ee
JA
105 /*
106 * IO engine state, may be different from above when we get
107 * partial transfers / residual data counts
108 */
cec6b55d 109 void *xfer_buf;
a4f4fdd7 110 unsigned long xfer_buflen;
cec6b55d 111
ebac4655
JA
112 unsigned int resid;
113 unsigned int error;
114
1e97cce9 115 enum fio_ddir ddir;
ebac4655 116
dfd7bc2c
JA
117 /*
118 * io engine private data
119 */
120 union {
121 unsigned int index;
122 unsigned int seen;
123 };
124
53cdc686
JA
125 struct fio_file *file;
126
ebac4655
JA
127 struct list_head list;
128};
129
130#define FIO_HDR_MAGIC 0xf00baaef
131
132enum {
1c9e06ee
JA
133 VERIFY_NONE = 0, /* no verification */
134 VERIFY_MD5, /* md5 sum data blocks */
135 VERIFY_CRC32, /* crc32 sum data blocks */
ebac4655
JA
136};
137
1c9e06ee
JA
138/*
139 * A header structure associated with each checksummed data block
140 */
ebac4655
JA
141struct verify_header {
142 unsigned int fio_magic;
143 unsigned int len;
144 unsigned int verify_type;
145 union {
146 char md5_digest[MD5_HASH_WORDS * 4];
147 unsigned long crc32;
148 };
149};
150
151struct group_run_stats {
9104f874
JA
152 unsigned long long max_run[2], min_run[2];
153 unsigned long long max_bw[2], min_bw[2];
e9b2a3fa 154 unsigned long long io_kb[2];
9104f874 155 unsigned long long agg[2];
ebac4655
JA
156};
157
e9c047a0
JA
158/*
159 * What type of allocation to use for io buffers
160 */
161enum fio_memtype {
162 MEM_MALLOC = 0, /* ordinary malloc */
163 MEM_SHM, /* use shared memory segments */
74b025b0 164 MEM_SHMHUGE, /* use shared memory segments with huge pages */
e9c047a0 165 MEM_MMAP, /* use anonynomous mmap */
d0bdaf49 166 MEM_MMAPHUGE, /* memory mapped huge file */
e9c047a0
JA
167};
168
169/*
170 * The type of object we are working on
171 */
172enum fio_filetype {
1c9e06ee
JA
173 FIO_TYPE_FILE = 1, /* plain file */
174 FIO_TYPE_BD, /* block device */
175 FIO_TYPE_CHAR, /* character device */
e9c047a0
JA
176};
177
2866c82d 178enum fio_ioengine_flags {
1c9e06ee
JA
179 FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */
180 FIO_CPUIO = 1 << 1, /* cpu burner, doesn't do real io */
181 FIO_MMAPIO = 1 << 2, /* uses memory mapped io */
182 FIO_RAWIO = 1 << 3, /* some sort of direct/raw io */
183 FIO_NETIO = 1 << 4, /* networked io */
184 FIO_NULLIO = 1 << 5, /* no real data transfer (cpu/null) */
e9c047a0
JA
185};
186
1c9e06ee
JA
187/*
188 * Each thread_data structure has a number of files associated with it,
189 * this structure holds state information for a single file.
190 */
53cdc686
JA
191struct fio_file {
192 /*
193 * A file may not be a file descriptor, let the io engine decide
194 */
195 union {
196 unsigned long file_data;
a4f4fdd7 197 long fd;
53cdc686
JA
198 };
199 char *file_name;
200 void *mmap;
201 unsigned long long file_size;
202 unsigned long long real_file_size;
203 unsigned long long file_offset;
204 unsigned long long last_pos;
02bcaa8c 205 unsigned long long last_completed_pos;
53cdc686 206
1c9e06ee
JA
207 /*
208 * block map for random io
209 */
53cdc686
JA
210 unsigned long *file_map;
211 unsigned int num_maps;
1c9e06ee 212 unsigned int last_free_lookup;
9b031dc8
JA
213
214 unsigned int unlink;
53cdc686
JA
215};
216
71619dc2
JA
217/*
218 * How many depth levels to log
219 */
220#define FIO_IO_U_MAP_NR 8
221
e9c047a0
JA
222/*
223 * This describes a single thread/process executing a fio job.
224 */
ebac4655 225struct thread_data {
61697c37 226 char *description;
b4692828 227 char *name;
ef899b63 228 char *directory;
13f8e2d2 229 char *filename;
ebac4655
JA
230 char verror[80];
231 pthread_t thread;
232 int thread_number;
233 int groupid;
e9c047a0 234 enum fio_filetype filetype;
53cdc686
JA
235 struct fio_file *files;
236 unsigned int nr_files;
13f8e2d2 237 unsigned int nr_uniq_files;
53cdc686 238 unsigned int next_file;
ebac4655 239 int error;
ebac4655
JA
240 pid_t pid;
241 char *orig_buffer;
242 size_t orig_buffer_size;
243 volatile int terminate;
244 volatile int runstate;
e9c047a0 245 enum fio_ddir ddir;
3d60d1ed 246 unsigned int iomix;
ebac4655 247 unsigned int ioprio;
87dc1ab1 248 unsigned int last_was_sync;
e9c047a0 249
9158d2f7
JA
250 unsigned int sequential;
251 unsigned int odirect;
252 unsigned int invalidate_cache;
253 unsigned int create_serialize;
254 unsigned int create_fsync;
255 unsigned int end_fsync;
256 unsigned int sync_io;
257 unsigned int verify;
258 unsigned int use_thread;
259 unsigned int unlink;
260 unsigned int do_disk_util;
261 unsigned int override_sync;
262 unsigned int rand_repeatable;
263 unsigned int write_lat_log;
264 unsigned int write_bw_log;
bb8895e0 265 unsigned int norandommap;
690adba3 266 unsigned int bs_unaligned;
e9c047a0 267
a00735e6
JA
268 unsigned int bs[2];
269 unsigned int min_bs[2];
270 unsigned int max_bs[2];
56bb17f2 271 unsigned int hugepage_size;
a00735e6 272 unsigned int rw_min_bs;
ebac4655 273 unsigned int thinktime;
9c1f7434 274 unsigned int thinktime_blocks;
ebac4655
JA
275 unsigned int fsync_blocks;
276 unsigned int start_delay;
906c8d75 277 unsigned long timeout;
ebac4655 278 unsigned int overwrite;
ebac4655 279 unsigned int bw_avg_time;
ebac4655 280 unsigned int loops;
20dc95c4
JA
281 unsigned long long zone_size;
282 unsigned long long zone_skip;
e9c047a0 283 enum fio_memtype mem_type;
313cb206
JA
284 char *mmapfile;
285 int mmapfd;
ebac4655
JA
286 unsigned int stonewall;
287 unsigned int numjobs;
ebac4655
JA
288 unsigned int iodepth;
289 os_cpu_mask_t cpumask;
aea47d44 290 unsigned int iolog;
843a7413 291 unsigned int read_iolog;
a6ccc7be
JA
292 unsigned int rwmixcycle;
293 unsigned int rwmixread;
e1f36503 294 unsigned int rwmixwrite;
b6f4d880 295 unsigned int nice;
aea47d44 296
076efc7c
JA
297 char *read_iolog_file;
298 char *write_iolog_file;
843a7413
JA
299 void *iolog_buf;
300 FILE *iolog_f;
ebac4655 301
da86774e 302 char *sysfs_root;
da86774e
JA
303 char *ioscheduler;
304
6dfd46b9
JA
305 os_random_state_t bsrange_state;
306 os_random_state_t verify_state;
ebac4655
JA
307
308 int shm_id;
309
e9c047a0
JA
310 /*
311 * IO engine hooks, contains everything needed to submit an io_u
312 * to any of the available IO engines.
313 */
2866c82d 314 struct ioengine_ops *io_ops;
ebac4655 315
e9c047a0
JA
316 /*
317 * Current IO depth and list of free and busy io_u's.
318 */
ebac4655 319 unsigned int cur_depth;
71619dc2
JA
320 unsigned int io_u_map[FIO_IO_U_MAP_NR];
321 unsigned long total_io_u;
ebac4655
JA
322 struct list_head io_u_freelist;
323 struct list_head io_u_busylist;
324
e9c047a0
JA
325 /*
326 * Rate state
327 */
ebac4655
JA
328 unsigned int rate;
329 unsigned int ratemin;
330 unsigned int ratecycle;
331 unsigned long rate_usec_cycle;
332 long rate_pending_usleep;
333 unsigned long rate_bytes;
334 struct timeval lastrate;
335
336 unsigned long runtime[2]; /* msec */
337 unsigned long long io_size;
53cdc686
JA
338 unsigned long long total_file_size;
339 unsigned long long start_offset;
ebac4655
JA
340 unsigned long long total_io_size;
341
9104f874
JA
342 unsigned long long io_blocks[2];
343 unsigned long long io_bytes[2];
344 unsigned long long zone_bytes;
345 unsigned long long this_io_bytes[2];
bbfd6b00 346 volatile int mutex;
ebac4655 347
e9c047a0
JA
348 /*
349 * State for random io, a bitmap of blocks done vs not done
350 */
6dfd46b9 351 os_random_state_t random_state;
ebac4655 352
b990b5c0
JA
353 /*
354 * CPU "io" cycle burner
355 */
356 unsigned int cpuload;
357 unsigned int cpucycle;
358
ebac4655
JA
359 /*
360 * bandwidth and latency stats
361 */
362 struct io_stat clat_stat[2]; /* completion latency */
363 struct io_stat slat_stat[2]; /* submission latency */
364 struct io_stat bw_stat[2]; /* bandwidth stats */
365
9104f874 366 unsigned long long stat_io_bytes[2];
ebac4655
JA
367 struct timeval stat_sample_time[2];
368
369 struct io_log *slat_log;
370 struct io_log *clat_log;
371 struct io_log *bw_log;
372
373 struct timeval start; /* start of this loop */
374 struct timeval epoch; /* time job was started */
69008999 375 struct timeval end_time;/* time job ended */
ebac4655 376
e9c047a0
JA
377 /*
378 * fio system usage accounting
379 */
ebac4655
JA
380 struct rusage ru_start;
381 struct rusage ru_end;
382 unsigned long usr_time;
383 unsigned long sys_time;
384 unsigned long ctx;
385
e9c047a0
JA
386 /*
387 * read/write mixed workload state
388 */
6dfd46b9 389 os_random_state_t rwmix_state;
a6ccc7be 390 struct timeval rwmix_switch;
e9c047a0 391 enum fio_ddir rwmix_ddir;
a6ccc7be 392
4e0ba8af
JA
393 /*
394 * Pre-run and post-run shell
395 */
396 char *exec_prerun;
397 char *exec_postrun;
398
e9c047a0
JA
399 /*
400 * IO historic logs
401 */
ebac4655 402 struct list_head io_hist_list;
aea47d44 403 struct list_head io_log_list;
ebac4655
JA
404};
405
b990b5c0 406#define __td_verror(td, err, msg) \
ebac4655
JA
407 do { \
408 int e = (err); \
409 (td)->error = e; \
b990b5c0 410 snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, error=%s", __FILE__, __LINE__, (msg)); \
ebac4655
JA
411 } while (0)
412
b990b5c0
JA
413
414#define td_verror(td, err) __td_verror((td), (err), strerror((err)))
415#define td_vmsg(td, err, msg) __td_verror((td), (err), (msg))
416
ebac4655
JA
417extern int exitall_on_terminate;
418extern int thread_number;
419extern int shm_id;
420extern int groupid;
c6ae0a5b 421extern int terse_output;
eb8bbf48
JA
422extern FILE *f_out;
423extern FILE *f_err;
53cdc686 424extern int temp_stall_ts;
1e97cce9 425extern unsigned long long mlock_size;
ebac4655
JA
426
427extern struct thread_data *threads;
428
ebac4655
JA
429#define td_read(td) ((td)->ddir == DDIR_READ)
430#define td_write(td) ((td)->ddir == DDIR_WRITE)
3d60d1ed 431#define td_rw(td) ((td)->iomix != 0)
ebac4655
JA
432
433#define BLOCKS_PER_MAP (8 * sizeof(long))
a00735e6 434#define TO_MAP_BLOCK(td, f, b) ((b) - ((f)->file_offset / (td)->rw_min_bs))
53cdc686
JA
435#define RAND_MAP_IDX(td, f, b) (TO_MAP_BLOCK(td, f, b) / BLOCKS_PER_MAP)
436#define RAND_MAP_BIT(td, f, b) (TO_MAP_BLOCK(td, f, b) & (BLOCKS_PER_MAP - 1))
ebac4655
JA
437
438#define MAX_JOBS (1024)
439
87dc1ab1
JA
440static inline int should_fsync(struct thread_data *td)
441{
442 if (td->last_was_sync)
443 return 0;
444 if (td->odirect)
445 return 0;
446 if (td_write(td) || td_rw(td) || td->override_sync)
447 return 1;
448
449 return 0;
450}
451
1c9e06ee
JA
452/*
453 * Disk utils as read in /sys/block/<dev>/stat
454 */
ebac4655
JA
455struct disk_util_stat {
456 unsigned ios[2];
457 unsigned merges[2];
458 unsigned long long sectors[2];
459 unsigned ticks[2];
460 unsigned io_ticks;
461 unsigned time_in_queue;
462};
463
1c9e06ee
JA
464/*
465 * Per-device disk util management
466 */
ebac4655
JA
467struct disk_util {
468 struct list_head list;
469
470 char *name;
471 char path[256];
472 dev_t dev;
473
474 struct disk_util_stat dus;
475 struct disk_util_stat last_dus;
476
477 unsigned long msec;
478 struct timeval time;
479};
480
1c9e06ee
JA
481/*
482 * Used for passing io_u completion data
483 */
ebac4655
JA
484struct io_completion_data {
485 int nr; /* input */
486
487 int error; /* output */
488 unsigned long bytes_done[2]; /* output */
02bcaa8c 489 struct timeval time; /* output */
ebac4655
JA
490};
491
492#define DISK_UTIL_MSEC (250)
493
6a0106a0
JA
494#ifndef min
495#define min(a, b) ((a) < (b) ? (a) : (b))
496#endif
a00735e6
JA
497#ifndef max
498#define max(a, b) ((a) > (b) ? (a) : (b))
499#endif
6a0106a0 500
6796209a
JA
501/*
502 * Log exports
503 */
504extern int read_iolog_get(struct thread_data *, struct io_u *);
505extern void write_iolog_put(struct thread_data *, struct io_u *);
506extern int init_iolog(struct thread_data *td);
507extern void log_io_piece(struct thread_data *, struct io_u *);
508extern void prune_io_piece_log(struct thread_data *);
509extern void write_iolog_close(struct thread_data *);
510
511/*
512 * Logging
513 */
1e97cce9
JA
514extern void add_clat_sample(struct thread_data *, enum fio_ddir, unsigned long);
515extern void add_slat_sample(struct thread_data *, enum fio_ddir, unsigned long);
516extern void add_bw_sample(struct thread_data *, enum fio_ddir, struct timeval *);
6796209a
JA
517extern void show_run_stats(void);
518extern void init_disk_util(struct thread_data *);
519extern void update_rusage_stat(struct thread_data *);
520extern void update_io_ticks(void);
521extern void disk_util_timer_arm(void);
8914a9d8
JA
522extern void setup_log(struct io_log **);
523extern void finish_log(struct thread_data *, struct io_log *, const char *);
bb3884d8 524extern void __finish_log(struct io_log *, const char *);
8914a9d8 525extern int setup_rate(struct thread_data *);
bb3884d8
JA
526extern struct io_log *agg_io_log[2];
527extern int write_bw_log;
528extern void add_agg_sample(unsigned long, enum fio_ddir);
6796209a
JA
529
530/*
531 * Time functions
532 */
533extern unsigned long utime_since(struct timeval *, struct timeval *);
69008999 534extern unsigned long utime_since_now(struct timeval *);
6796209a
JA
535extern unsigned long mtime_since(struct timeval *, struct timeval *);
536extern unsigned long mtime_since_now(struct timeval *);
537extern unsigned long time_since_now(struct timeval *);
263e529f 538extern unsigned long mtime_since_genesis(void);
b990b5c0 539extern void __usec_sleep(unsigned int);
6796209a 540extern void usec_sleep(struct thread_data *, unsigned long);
a00735e6 541extern void rate_throttle(struct thread_data *, unsigned long, unsigned int, int);
6043c579 542extern void fill_start_time(struct timeval *);
02bcaa8c 543extern void fio_gettime(struct timeval *, void *);
6796209a 544
8914a9d8
JA
545/*
546 * Init functions
547 */
548extern int parse_options(int, char **);
549extern int init_random_state(struct thread_data *);
550
53cdc686
JA
551/*
552 * File setup/shutdown
553 */
554extern void close_files(struct thread_data *);
555extern int setup_files(struct thread_data *);
21972cde 556extern int open_files(struct thread_data *);
e5b401d4 557extern int file_invalidate_cache(struct thread_data *, struct fio_file *);
53cdc686 558
263e529f
JA
559/*
560 * ETA/status stuff
561 */
562extern void print_thread_status(void);
563extern void print_status_init(int);
564
565/*
566 * Thread life cycle. Once a thread has a runstate beyond TD_INITIALIZED, it
567 * will never back again. It may cycle between running/verififying/fsyncing.
568 * Once the thread reaches TD_EXITED, it is just waiting for the core to
569 * reap it.
570 */
571enum {
572 TD_NOT_CREATED = 0,
573 TD_CREATED,
574 TD_INITIALIZED,
575 TD_RUNNING,
576 TD_VERIFYING,
577 TD_FSYNCING,
578 TD_EXITED,
579 TD_REAPED,
580};
581
e29d1b70
JA
582/*
583 * Verify helpers
584 */
585extern void populate_verify_io_u(struct thread_data *, struct io_u *);
586extern int get_next_verify(struct thread_data *td, struct io_u *);
a9619d44 587extern int do_io_u_verify(struct thread_data *, struct io_u **);
e29d1b70 588
2f9ade3c
JA
589/*
590 * Memory helpers
591 */
592extern int fio_pin_memory(void);
593extern void fio_unpin_memory(void);
594extern int allocate_io_mem(struct thread_data *);
595extern void free_io_mem(struct thread_data *);
596
10ba535a
JA
597/*
598 * io unit handling
599 */
600#define queue_full(td) list_empty(&(td)->io_u_freelist)
601extern struct io_u *__get_io_u(struct thread_data *);
602extern struct io_u *get_io_u(struct thread_data *, struct fio_file *);
603extern void put_io_u(struct thread_data *, struct io_u *);
604extern void ios_completed(struct thread_data *, struct io_completion_data *);
605extern void io_completed(struct thread_data *, struct io_u *, struct io_completion_data *);
606
607/*
608 * io engine entry points
609 */
8c16d840 610extern int td_io_init(struct thread_data *);
10ba535a
JA
611extern int td_io_prep(struct thread_data *, struct io_u *);
612extern int td_io_queue(struct thread_data *, struct io_u *);
613extern int td_io_sync(struct thread_data *, struct fio_file *);
614extern int td_io_getevents(struct thread_data *, int, int, struct timespec *);
615
bbfd6b00
JA
616/*
617 * This is a pretty crappy semaphore implementation, but with the use that fio
618 * has (just signalling start/go conditions), it doesn't have to be better.
619 * Naturally this would not work for any type of contended semaphore or
620 * for real locking.
621 */
1056eaad 622static inline void fio_sem_init(volatile int *sem, int val)
bbfd6b00
JA
623{
624 *sem = val;
625}
626
1056eaad 627static inline void fio_sem_down(volatile int *sem)
bbfd6b00
JA
628{
629 while (*sem == 0)
630 usleep(10000);
631
632 (*sem)--;
633}
634
1056eaad 635static inline void fio_sem_up(volatile int *sem)
bbfd6b00
JA
636{
637 (*sem)++;
638}
639
3b70d7e5
JA
640/*
641 * If logging output to a file, stderr should go to both stderr and f_err
642 */
643#define log_err(args...) do { \
644 fprintf(f_err, ##args); \
645 if (f_err != stderr) \
646 fprintf(stderr, ##args); \
647 } while (0)
648
2866c82d 649struct ioengine_ops {
5f350952 650 struct list_head list;
2866c82d
JA
651 char name[16];
652 int version;
653 int flags;
ea2877a4 654 int (*setup)(struct thread_data *);
2866c82d
JA
655 int (*init)(struct thread_data *);
656 int (*prep)(struct thread_data *, struct io_u *);
657 int (*queue)(struct thread_data *, struct io_u *);
658 int (*getevents)(struct thread_data *, int, int, struct timespec *);
659 struct io_u *(*event)(struct thread_data *, int);
660 int (*cancel)(struct thread_data *, struct io_u *);
661 void (*cleanup)(struct thread_data *);
2866c82d
JA
662 void *data;
663 void *dlhandle;
664};
665
87dc1ab1 666#define FIO_IOOPS_VERSION 3
2866c82d 667
b4692828 668extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *);
5f350952
JA
669extern int register_ioengine(struct ioengine_ops *);
670extern void unregister_ioengine(struct ioengine_ops *);
2866c82d
JA
671extern void close_ioengine(struct thread_data *);
672
673/*
674 * Mark unused variables passed to ops functions as unused, to silence gcc
675 */
676#define fio_unused __attribute((__unused__))
5f350952
JA
677#define fio_init __attribute__((constructor))
678#define fio_exit __attribute__((destructor))
2866c82d 679
34572e28
JA
680#define for_each_td(td, i) \
681 for ((i) = 0, (td) = &threads[0]; (i) < (int) thread_number; (i)++, (td)++)
53cdc686 682#define for_each_file(td, f, i) \
34572e28 683 for ((i) = 0, (f) = &(td)->files[0]; (i) < (int) (td)->nr_files; (i)++, (f)++)
53cdc686 684
0032bf9f
JA
685#define fio_assert(td, cond) do { \
686 if (!(cond)) { \
340fd243 687 int *__foo = NULL; \
0032bf9f
JA
688 fprintf(stderr, "file:%s:%d, assert %s failed\n", __FILE__, __LINE__, #cond); \
689 (td)->runstate = TD_EXITED; \
437c9b71 690 (td)->error = EFAULT; \
340fd243 691 *__foo = 0; \
0032bf9f
JA
692 } \
693} while (0)
694
ebac4655 695#endif