Merge branch 'patch-1' of https://github.com/Nikratio/fio
[fio.git] / io_ddir.h
... / ...
CommitLineData
1#ifndef FIO_DDIR_H
2#define FIO_DDIR_H
3
4enum 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
21static 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
33enum 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};
45
46#define td_read(td) ((td)->o.td_ddir & TD_DDIR_READ)
47#define td_write(td) ((td)->o.td_ddir & TD_DDIR_WRITE)
48#define td_trim(td) ((td)->o.td_ddir & TD_DDIR_TRIM)
49#define td_rw(td) (((td)->o.td_ddir & TD_DDIR_RW) == TD_DDIR_RW)
50#define td_random(td) ((td)->o.td_ddir & TD_DDIR_RAND)
51#define file_randommap(td, f) (!(td)->o.norandommap && fio_file_axmap((f)))
52#define td_trimwrite(td) (((td)->o.td_ddir & TD_DDIR_TRIMWRITE) \
53 == TD_DDIR_TRIMWRITE)
54
55static inline int ddir_sync(enum fio_ddir ddir)
56{
57 return ddir == DDIR_SYNC || ddir == DDIR_DATASYNC ||
58 ddir == DDIR_SYNC_FILE_RANGE;
59}
60
61static inline int ddir_rw(enum fio_ddir ddir)
62{
63 return ddir == DDIR_READ || ddir == DDIR_WRITE || ddir == DDIR_TRIM;
64}
65
66static inline const char *ddir_str(enum td_ddir ddir)
67{
68 static const char *__str[] = { NULL, "read", "write", "rw", "rand",
69 "randread", "randwrite", "randrw",
70 "trim", NULL, "trimwrite", NULL, "randtrim" };
71
72 return __str[ddir];
73}
74
75#define ddir_rw_sum(arr) \
76 ((arr)[DDIR_READ] + (arr)[DDIR_WRITE] + (arr)[DDIR_TRIM])
77
78#endif