Jens Axboe | d6aed79 | 2009-06-03 08:41:15 +0200 | [diff] [blame] | 1 | #ifndef FIO_DDIR_H |
| 2 | #define FIO_DDIR_H |
| 3 | |
| 4 | enum fio_ddir { |
| 5 | DDIR_READ = 0, |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 6 | DDIR_WRITE = 1, |
| 7 | DDIR_TRIM = 2, |
| 8 | DDIR_RWDIR_CNT = 3, |
| 9 | DDIR_SYNC = 3, |
Jens Axboe | 5f9099e | 2009-06-16 22:40:26 +0200 | [diff] [blame] | 10 | DDIR_DATASYNC, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 11 | DDIR_SYNC_FILE_RANGE, |
Glen Ogilvie | 457bf39 | 2009-11-03 21:52:36 +0100 | [diff] [blame] | 12 | DDIR_WAIT, |
Jens Axboe | d6aed79 | 2009-06-03 08:41:15 +0200 | [diff] [blame] | 13 | DDIR_INVAL = -1, |
| 14 | }; |
| 15 | |
| 16 | enum td_ddir { |
| 17 | TD_DDIR_READ = 1 << 0, |
| 18 | TD_DDIR_WRITE = 1 << 1, |
| 19 | TD_DDIR_RAND = 1 << 2, |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 20 | TD_DDIR_TRIM = 1 << 3, |
Jens Axboe | d6aed79 | 2009-06-03 08:41:15 +0200 | [diff] [blame] | 21 | TD_DDIR_RW = TD_DDIR_READ | TD_DDIR_WRITE, |
| 22 | TD_DDIR_RANDREAD = TD_DDIR_READ | TD_DDIR_RAND, |
| 23 | TD_DDIR_RANDWRITE = TD_DDIR_WRITE | TD_DDIR_RAND, |
| 24 | TD_DDIR_RANDRW = TD_DDIR_RW | TD_DDIR_RAND, |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 25 | TD_DDIR_RANDTRIM = TD_DDIR_TRIM | TD_DDIR_RAND, |
Jens Axboe | d6aed79 | 2009-06-03 08:41:15 +0200 | [diff] [blame] | 26 | }; |
| 27 | |
Jens Axboe | 29c8e86 | 2009-06-05 22:10:51 +0200 | [diff] [blame] | 28 | #define td_read(td) ((td)->o.td_ddir & TD_DDIR_READ) |
| 29 | #define td_write(td) ((td)->o.td_ddir & TD_DDIR_WRITE) |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 30 | #define td_trim(td) ((td)->o.td_ddir & TD_DDIR_TRIM) |
Jens Axboe | 29c8e86 | 2009-06-05 22:10:51 +0200 | [diff] [blame] | 31 | #define td_rw(td) (((td)->o.td_ddir & TD_DDIR_RW) == TD_DDIR_RW) |
| 32 | #define td_random(td) ((td)->o.td_ddir & TD_DDIR_RAND) |
Jens Axboe | 7ebd796 | 2012-11-28 21:24:46 +0100 | [diff] [blame^] | 33 | #define file_randommap(td, f) (!(td)->o.norandommap && (f)->io_axmap) |
Jens Axboe | 29c8e86 | 2009-06-05 22:10:51 +0200 | [diff] [blame] | 34 | |
Jens Axboe | 5f9099e | 2009-06-16 22:40:26 +0200 | [diff] [blame] | 35 | static inline int ddir_sync(enum fio_ddir ddir) |
| 36 | { |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 37 | return ddir == DDIR_SYNC || ddir == DDIR_DATASYNC || |
| 38 | ddir == DDIR_SYNC_FILE_RANGE; |
Jens Axboe | 5f9099e | 2009-06-16 22:40:26 +0200 | [diff] [blame] | 39 | } |
| 40 | |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 41 | static inline int ddir_rw(enum fio_ddir ddir) |
| 42 | { |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 43 | return ddir == DDIR_READ || ddir == DDIR_WRITE || ddir == DDIR_TRIM; |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 44 | } |
| 45 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 46 | #define ddir_trim(ddir) ((ddir) == DDIR_TRIM) |
| 47 | |
Jens Axboe | 342f4be | 2012-09-14 08:59:20 +0200 | [diff] [blame] | 48 | #define ddir_rw_sum(arr) \ |
| 49 | ((arr)[DDIR_READ] + (arr)[DDIR_WRITE] + (arr)[DDIR_TRIM]) |
| 50 | |
Jens Axboe | d6aed79 | 2009-06-03 08:41:15 +0200 | [diff] [blame] | 51 | #endif |