configure: Add <linux/blkzoned.h> test
[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 static inline const char *io_ddir_name(enum fio_ddir ddir)
20 {
21         static const char *name[] = { "read", "write", "trim", "sync",
22                                         "datasync", "sync_file_range",
23                                         "wait", };
24
25         if (ddir < DDIR_LAST)
26                 return name[ddir];
27
28         return "invalid";
29 }
30
31 enum td_ddir {
32         TD_DDIR_READ            = 1 << 0,
33         TD_DDIR_WRITE           = 1 << 1,
34         TD_DDIR_RAND            = 1 << 2,
35         TD_DDIR_TRIM            = 1 << 3,
36         TD_DDIR_RW              = TD_DDIR_READ | TD_DDIR_WRITE,
37         TD_DDIR_RANDREAD        = TD_DDIR_READ | TD_DDIR_RAND,
38         TD_DDIR_RANDWRITE       = TD_DDIR_WRITE | TD_DDIR_RAND,
39         TD_DDIR_RANDRW          = TD_DDIR_RW | TD_DDIR_RAND,
40         TD_DDIR_RANDTRIM        = TD_DDIR_TRIM | TD_DDIR_RAND,
41         TD_DDIR_TRIMWRITE       = TD_DDIR_TRIM | TD_DDIR_WRITE,
42 };
43
44 #define td_read(td)             ((td)->o.td_ddir & TD_DDIR_READ)
45 #define td_write(td)            ((td)->o.td_ddir & TD_DDIR_WRITE)
46 #define td_trim(td)             ((td)->o.td_ddir & TD_DDIR_TRIM)
47 #define td_rw(td)               (((td)->o.td_ddir & TD_DDIR_RW) == TD_DDIR_RW)
48 #define td_random(td)           ((td)->o.td_ddir & TD_DDIR_RAND)
49 #define file_randommap(td, f)   (!(td)->o.norandommap && fio_file_axmap((f)))
50 #define td_trimwrite(td)        (((td)->o.td_ddir & TD_DDIR_TRIMWRITE) \
51                                         == TD_DDIR_TRIMWRITE)
52
53 static inline int ddir_sync(enum fio_ddir ddir)
54 {
55         return ddir == DDIR_SYNC || ddir == DDIR_DATASYNC ||
56                ddir == DDIR_SYNC_FILE_RANGE;
57 }
58
59 static inline int ddir_rw(enum fio_ddir ddir)
60 {
61         return ddir == DDIR_READ || ddir == DDIR_WRITE || ddir == DDIR_TRIM;
62 }
63
64 static inline const char *ddir_str(enum td_ddir ddir)
65 {
66         static const char *__str[] = { NULL, "read", "write", "rw", "rand",
67                                 "randread", "randwrite", "randrw",
68                                 "trim", NULL, "trimwrite", NULL, "randtrim" };
69
70         return __str[ddir];
71 }
72
73 #define ddir_rw_sum(arr)        \
74         ((arr)[DDIR_READ] + (arr)[DDIR_WRITE] + (arr)[DDIR_TRIM])
75
76 #endif