Allow trim on any file type
[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_RWDIR_CNT = 3,
9 DDIR_SYNC = 3,
10 DDIR_DATASYNC,
11 DDIR_SYNC_FILE_RANGE,
12 DDIR_WAIT,
13 DDIR_LAST,
14 DDIR_INVAL = -1,
15};
16
17static inline const char *io_ddir_name(enum fio_ddir ddir)
18{
19 const char *name[] = { "read", "write", "trim", "sync", "datasync",
20 "sync_file_range", "write", };
21
22 if (ddir < DDIR_LAST)
23 return name[ddir];
24
25 return "invalid";
26}
27
28enum td_ddir {
29 TD_DDIR_READ = 1 << 0,
30 TD_DDIR_WRITE = 1 << 1,
31 TD_DDIR_RAND = 1 << 2,
32 TD_DDIR_TRIM = 1 << 3,
33 TD_DDIR_RW = TD_DDIR_READ | TD_DDIR_WRITE,
34 TD_DDIR_RANDREAD = TD_DDIR_READ | TD_DDIR_RAND,
35 TD_DDIR_RANDWRITE = TD_DDIR_WRITE | TD_DDIR_RAND,
36 TD_DDIR_RANDRW = TD_DDIR_RW | TD_DDIR_RAND,
37 TD_DDIR_RANDTRIM = TD_DDIR_TRIM | TD_DDIR_RAND,
38};
39
40#define td_read(td) ((td)->o.td_ddir & TD_DDIR_READ)
41#define td_write(td) ((td)->o.td_ddir & TD_DDIR_WRITE)
42#define td_trim(td) ((td)->o.td_ddir & TD_DDIR_TRIM)
43#define td_rw(td) (((td)->o.td_ddir & TD_DDIR_RW) == TD_DDIR_RW)
44#define td_random(td) ((td)->o.td_ddir & TD_DDIR_RAND)
45#define file_randommap(td, f) (!(td)->o.norandommap && fio_file_axmap((f)))
46
47static inline int ddir_sync(enum fio_ddir ddir)
48{
49 return ddir == DDIR_SYNC || ddir == DDIR_DATASYNC ||
50 ddir == DDIR_SYNC_FILE_RANGE;
51}
52
53static inline int ddir_rw(enum fio_ddir ddir)
54{
55 return ddir == DDIR_READ || ddir == DDIR_WRITE || ddir == DDIR_TRIM;
56}
57
58static inline const char *ddir_str(enum td_ddir ddir)
59{
60 const char *__str[] = { NULL, "read", "write", "rw", NULL,
61 "randread", "randwrite", "randrw",
62 "trim", NULL, NULL, NULL, "randtrim" };
63
64 return __str[ddir];
65}
66
67#define ddir_rw_sum(arr) \
68 ((arr)[DDIR_READ] + (arr)[DDIR_WRITE] + (arr)[DDIR_TRIM])
69
70#endif