engines/libzbc: set FIO_RO_NEEDS_RW_OPEN engine flag
[fio.git] / io_ddir.h
1 #ifndef FIO_DDIR_H
2 #define FIO_DDIR_H
3
4 enum fio_ddir {
5         DDIR_READ = 0,
6         DDIR_WRITE = 1,
7         DDIR_TRIM = 2,
8         DDIR_SYNC = 3,
9         DDIR_DATASYNC,
10         DDIR_SYNC_FILE_RANGE,
11         DDIR_WAIT,
12         DDIR_LAST,
13         DDIR_INVAL = -1,
14
15         DDIR_RWDIR_CNT = 3,
16         DDIR_RWDIR_SYNC_CNT = 4,
17 };
18
19 #define for_each_rw_ddir(ddir)  for (enum fio_ddir ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++)
20
21 static inline const char *io_ddir_name(enum fio_ddir ddir)
22 {
23         static const char *name[] = { "read", "write", "trim", "sync",
24                                         "datasync", "sync_file_range",
25                                         "wait", };
26
27         if (ddir >= 0 && ddir < DDIR_LAST)
28                 return name[ddir];
29
30         return "invalid";
31 }
32
33 enum td_ddir {
34         TD_DDIR_READ            = 1 << 0,
35         TD_DDIR_WRITE           = 1 << 1,
36         TD_DDIR_RAND            = 1 << 2,
37         TD_DDIR_TRIM            = 1 << 3,
38         TD_DDIR_RW              = TD_DDIR_READ | TD_DDIR_WRITE,
39         TD_DDIR_RANDREAD        = TD_DDIR_READ | TD_DDIR_RAND,
40         TD_DDIR_RANDWRITE       = TD_DDIR_WRITE | TD_DDIR_RAND,
41         TD_DDIR_RANDRW          = TD_DDIR_RW | TD_DDIR_RAND,
42         TD_DDIR_RANDTRIM        = TD_DDIR_TRIM | TD_DDIR_RAND,
43         TD_DDIR_TRIMWRITE       = TD_DDIR_TRIM | TD_DDIR_WRITE,
44         TD_DDIR_RANDTRIMWRITE   = TD_DDIR_RANDTRIM | TD_DDIR_WRITE,
45 };
46
47 #define td_read(td)             ((td)->o.td_ddir & TD_DDIR_READ)
48 #define td_write(td)            ((td)->o.td_ddir & TD_DDIR_WRITE)
49 #define td_trim(td)             ((td)->o.td_ddir & TD_DDIR_TRIM)
50 #define td_rw(td)               (((td)->o.td_ddir & TD_DDIR_RW) == TD_DDIR_RW)
51 #define td_random(td)           ((td)->o.td_ddir & TD_DDIR_RAND)
52 #define file_randommap(td, f)   (!(td)->o.norandommap && fio_file_axmap((f)))
53 #define td_trimwrite(td)        (((td)->o.td_ddir & TD_DDIR_TRIMWRITE) \
54                                         == TD_DDIR_TRIMWRITE)
55 #define td_randtrimwrite(td)    (((td)->o.td_ddir & TD_DDIR_RANDTRIMWRITE) \
56                                         == TD_DDIR_RANDTRIMWRITE)
57
58 static inline int ddir_sync(enum fio_ddir ddir)
59 {
60         return ddir == DDIR_SYNC || ddir == DDIR_DATASYNC ||
61                ddir == DDIR_SYNC_FILE_RANGE;
62 }
63
64 static inline int ddir_rw(enum fio_ddir ddir)
65 {
66         return ddir == DDIR_READ || ddir == DDIR_WRITE || ddir == DDIR_TRIM;
67 }
68
69 static inline const char *ddir_str(enum td_ddir ddir)
70 {
71         static const char *__str[] = { NULL, "read", "write", "rw", "rand",
72                                 "randread", "randwrite", "randrw",
73                                 "trim", NULL, "trimwrite", NULL, "randtrim",
74                                 NULL, "randtrimwrite" };
75
76         return __str[ddir];
77 }
78
79 #define ddir_rw_sum(arr)        \
80         ((arr)[DDIR_READ] + (arr)[DDIR_WRITE] + (arr)[DDIR_TRIM])
81
82 #endif