zbd: Fix zone locking for async I/O engines
[fio.git] / io_ddir.h
CommitLineData
d6aed795
JA
1#ifndef FIO_DDIR_H
2#define FIO_DDIR_H
3
4enum fio_ddir {
5 DDIR_READ = 0,
6eaf09d6
SL
6 DDIR_WRITE = 1,
7 DDIR_TRIM = 2,
6eaf09d6 8 DDIR_SYNC = 3,
5f9099ea 9 DDIR_DATASYNC,
44f29692 10 DDIR_SYNC_FILE_RANGE,
457bf399 11 DDIR_WAIT,
173375c2 12 DDIR_LAST,
d6aed795 13 DDIR_INVAL = -1,
d6aed795 14
84a41a37
JA
15 DDIR_RWDIR_CNT = 3,
16 DDIR_RWDIR_SYNC_CNT = 4,
17};
18
173375c2
JA
19static inline const char *io_ddir_name(enum fio_ddir ddir)
20{
820ba1f9
JA
21 static const char *name[] = { "read", "write", "trim", "sync",
22 "datasync", "sync_file_range",
23 "wait", };
173375c2
JA
24
25 if (ddir < DDIR_LAST)
26 return name[ddir];
27
28 return "invalid";
29}
30
d6aed795
JA
31enum td_ddir {
32 TD_DDIR_READ = 1 << 0,
33 TD_DDIR_WRITE = 1 << 1,
34 TD_DDIR_RAND = 1 << 2,
6eaf09d6 35 TD_DDIR_TRIM = 1 << 3,
d6aed795
JA
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,
6eaf09d6 40 TD_DDIR_RANDTRIM = TD_DDIR_TRIM | TD_DDIR_RAND,
82a90686 41 TD_DDIR_TRIMWRITE = TD_DDIR_TRIM | TD_DDIR_WRITE,
d6aed795
JA
42};
43
29c8e868
JA
44#define td_read(td) ((td)->o.td_ddir & TD_DDIR_READ)
45#define td_write(td) ((td)->o.td_ddir & TD_DDIR_WRITE)
6eaf09d6 46#define td_trim(td) ((td)->o.td_ddir & TD_DDIR_TRIM)
29c8e868
JA
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)
967d1b63 49#define file_randommap(td, f) (!(td)->o.norandommap && fio_file_axmap((f)))
82a90686
JA
50#define td_trimwrite(td) (((td)->o.td_ddir & TD_DDIR_TRIMWRITE) \
51 == TD_DDIR_TRIMWRITE)
29c8e868 52
5f9099ea
JA
53static inline int ddir_sync(enum fio_ddir ddir)
54{
44f29692
JA
55 return ddir == DDIR_SYNC || ddir == DDIR_DATASYNC ||
56 ddir == DDIR_SYNC_FILE_RANGE;
5f9099ea
JA
57}
58
ff58fced
JA
59static inline int ddir_rw(enum fio_ddir ddir)
60{
6eaf09d6 61 return ddir == DDIR_READ || ddir == DDIR_WRITE || ddir == DDIR_TRIM;
ff58fced
JA
62}
63
77b640d8 64static inline const char *ddir_str(enum td_ddir ddir)
807f9971 65{
6d6a7e02 66 static const char *__str[] = { NULL, "read", "write", "rw", "rand",
42da5c8b 67 "randread", "randwrite", "randrw",
6d6a7e02 68 "trim", NULL, "trimwrite", NULL, "randtrim" };
807f9971 69
42da5c8b 70 return __str[ddir];
807f9971
JA
71}
72
342f4be4
JA
73#define ddir_rw_sum(arr) \
74 ((arr)[DDIR_READ] + (arr)[DDIR_WRITE] + (arr)[DDIR_TRIM])
75
d6aed795 76#endif