iowatcher: Calculate ios_in_flight per trace
[blktrace.git] / blktrace_api.h
CommitLineData
6fe4709e
JA
1#ifndef BLKTRACEAPI_H
2#define BLKTRACEAPI_H
3
4#include <asm/types.h>
5
6/*
7 * Trace categories
8 */
9enum {
10 BLK_TC_READ = 1 << 0, /* reads */
11 BLK_TC_WRITE = 1 << 1, /* writes */
34432093 12 BLK_TC_FLUSH = 1 << 2, /* flush */
f86990ed 13 BLK_TC_SYNC = 1 << 3, /* sync */
6fe4709e
JA
14 BLK_TC_QUEUE = 1 << 4, /* queueing/merging */
15 BLK_TC_REQUEUE = 1 << 5, /* requeueing */
16 BLK_TC_ISSUE = 1 << 6, /* issue */
17 BLK_TC_COMPLETE = 1 << 7, /* completions */
18 BLK_TC_FS = 1 << 8, /* fs requests */
19 BLK_TC_PC = 1 << 9, /* pc requests */
bfc70ad5 20 BLK_TC_NOTIFY = 1 << 10, /* special message */
f86990ed 21 BLK_TC_AHEAD = 1 << 11, /* readahead */
711e4d25 22 BLK_TC_META = 1 << 12, /* metadata */
37081bf5 23 BLK_TC_DISCARD = 1 << 13, /* discard requests */
c54b9dd9 24 BLK_TC_DRV_DATA = 1 << 14, /* binary driver data */
34432093 25 BLK_TC_FUA = 1 << 15, /* fua requests */
6fe4709e 26
34432093 27 BLK_TC_END = 1 << 15, /* we've run out of bits! */
6fe4709e
JA
28};
29
30#define BLK_TC_SHIFT (16)
31#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT)
32
33/*
34 * Basic trace actions
35 */
36enum {
37 __BLK_TA_QUEUE = 1, /* queued */
38 __BLK_TA_BACKMERGE, /* back merged to existing rq */
39 __BLK_TA_FRONTMERGE, /* front merge to existing rq */
40 __BLK_TA_GETRQ, /* allocated new request */
41 __BLK_TA_SLEEPRQ, /* sleeping on rq allocation */
42 __BLK_TA_REQUEUE, /* request requeued */
43 __BLK_TA_ISSUE, /* sent to driver */
44 __BLK_TA_COMPLETE, /* completed by driver */
88b1a526 45 __BLK_TA_PLUG, /* queue was plugged */
3639a11e
JA
46 __BLK_TA_UNPLUG_IO, /* queue was unplugged by io */
47 __BLK_TA_UNPLUG_TIMER, /* queue was unplugged by timer */
b6076a9b 48 __BLK_TA_INSERT, /* insert request */
93f1c611
JA
49 __BLK_TA_SPLIT, /* bio was split */
50 __BLK_TA_BOUNCE, /* bio was bounced */
a8f30e64 51 __BLK_TA_REMAP, /* bio was remapped */
b3ee499d 52 __BLK_TA_ABORT, /* request aborted */
c54b9dd9 53 __BLK_TA_DRV_DATA, /* binary driver data */
7238673f 54 __BLK_TA_CGROUP = 1 << 8,
6fe4709e
JA
55};
56
7bd4fd0a
OK
57/*
58 * Notify events.
59 */
60enum blktrace_notify {
61 __BLK_TN_PROCESS = 0, /* establish pid/name mapping */
62 __BLK_TN_TIMESTAMP, /* include system clock */
1a15f6a8 63 __BLK_TN_MESSAGE, /* Character string message */
7238673f 64 __BLK_TN_CGROUP = __BLK_TA_CGROUP,
7bd4fd0a
OK
65};
66
6fe4709e
JA
67/*
68 * Trace actions in full. Additionally, read or write is masked
69 */
70#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE))
71#define BLK_TA_BACKMERGE (__BLK_TA_BACKMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
72#define BLK_TA_FRONTMERGE (__BLK_TA_FRONTMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
73#define BLK_TA_GETRQ (__BLK_TA_GETRQ | BLK_TC_ACT(BLK_TC_QUEUE))
74#define BLK_TA_SLEEPRQ (__BLK_TA_SLEEPRQ | BLK_TC_ACT(BLK_TC_QUEUE))
75#define BLK_TA_REQUEUE (__BLK_TA_REQUEUE | BLK_TC_ACT(BLK_TC_REQUEUE))
76#define BLK_TA_ISSUE (__BLK_TA_ISSUE | BLK_TC_ACT(BLK_TC_ISSUE))
77#define BLK_TA_COMPLETE (__BLK_TA_COMPLETE| BLK_TC_ACT(BLK_TC_COMPLETE))
88b1a526 78#define BLK_TA_PLUG (__BLK_TA_PLUG | BLK_TC_ACT(BLK_TC_QUEUE))
3639a11e
JA
79#define BLK_TA_UNPLUG_IO (__BLK_TA_UNPLUG_IO | BLK_TC_ACT(BLK_TC_QUEUE))
80#define BLK_TA_UNPLUG_TIMER (__BLK_TA_UNPLUG_TIMER | BLK_TC_ACT(BLK_TC_QUEUE))
b6076a9b 81#define BLK_TA_INSERT (__BLK_TA_INSERT | BLK_TC_ACT(BLK_TC_QUEUE))
93f1c611
JA
82#define BLK_TA_SPLIT (__BLK_TA_SPLIT)
83#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE)
a8f30e64 84#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE))
b3ee499d 85#define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE))
c54b9dd9 86#define BLK_TA_DRV_DATA (__BLK_TA_DRV_DATA | BLK_TC_ACT(BLK_TC_DRV_DATA))
6fe4709e 87
7bd4fd0a
OK
88#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
89#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
1a15f6a8 90#define BLK_TN_MESSAGE (__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
7bd4fd0a 91
6fe4709e 92#define BLK_IO_TRACE_MAGIC 0x65617400
bfc70ad5 93#define BLK_IO_TRACE_VERSION 0x07
6fe4709e
JA
94
95/*
96 * The trace itself
97 */
98struct blk_io_trace {
99 __u32 magic; /* MAGIC << 8 | version */
100 __u32 sequence; /* event number */
f8fd8985 101 __u64 time; /* in nanoseconds */
6fe4709e
JA
102 __u64 sector; /* disk offset */
103 __u32 bytes; /* transfer length */
104 __u32 action; /* what happened */
105 __u32 pid; /* who did it */
bfc70ad5 106 __u32 device; /* device identifier (dev_t) */
654aaa52 107 __u32 cpu; /* on what cpu did it happen */
6fe4709e
JA
108 __u16 error; /* completion error */
109 __u16 pdu_len; /* length of data after this trace */
110};
111
a8f30e64
JA
112/*
113 * The remap event
114 */
115struct blk_io_trace_remap {
97d13fb0 116 __u32 device_from;
580f7440
AB
117 __u32 device_to;
118 __u64 sector_from;
a8f30e64
JA
119};
120
7238673f
JK
121/*
122 * Payload with originating cgroup info
123 */
124struct blk_io_cgroup_payload {
125 __u32 ino;
126 __u32 gen;
127};
128
6fe4709e
JA
129/*
130 * User setup structure passed with BLKSTARTTRACE
131 */
132struct blk_user_trace_setup {
133 char name[32]; /* output */
134 __u16 act_mask; /* input */
135 __u32 buf_size; /* input */
136 __u32 buf_nr; /* input */
6c8d81e4
JA
137 __u64 start_lba;
138 __u64 end_lba;
139 __u32 pid;
6fe4709e
JA
140};
141
ed71a31e
JA
142#define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
143#define BLKTRACESTART _IO(0x12,116)
144#define BLKTRACESTOP _IO(0x12,117)
145#define BLKTRACETEARDOWN _IO(0x12,118)
6fe4709e
JA
146
147#endif