tracing: Convert some block events to DEFINE_EVENT
[linux-2.6.git] / include / trace / events / block.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM block
3
4 #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_BLOCK_H
6
7 #include <linux/blktrace_api.h>
8 #include <linux/blkdev.h>
9 #include <linux/tracepoint.h>
10
11 DECLARE_EVENT_CLASS(block_rq_with_error,
12
13         TP_PROTO(struct request_queue *q, struct request *rq),
14
15         TP_ARGS(q, rq),
16
17         TP_STRUCT__entry(
18                 __field(  dev_t,        dev                     )
19                 __field(  sector_t,     sector                  )
20                 __field(  unsigned int, nr_sector               )
21                 __field(  int,          errors                  )
22                 __array(  char,         rwbs,   6               )
23                 __dynamic_array( char,  cmd,    blk_cmd_buf_len(rq)     )
24         ),
25
26         TP_fast_assign(
27                 __entry->dev       = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
28                 __entry->sector    = blk_pc_request(rq) ? 0 : blk_rq_pos(rq);
29                 __entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
30                 __entry->errors    = rq->errors;
31
32                 blk_fill_rwbs_rq(__entry->rwbs, rq);
33                 blk_dump_cmd(__get_str(cmd), rq);
34         ),
35
36         TP_printk("%d,%d %s (%s) %llu + %u [%d]",
37                   MAJOR(__entry->dev), MINOR(__entry->dev),
38                   __entry->rwbs, __get_str(cmd),
39                   (unsigned long long)__entry->sector,
40                   __entry->nr_sector, __entry->errors)
41 );
42
43 DEFINE_EVENT(block_rq_with_error, block_rq_abort,
44
45         TP_PROTO(struct request_queue *q, struct request *rq),
46
47         TP_ARGS(q, rq)
48 );
49
50 DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
51
52         TP_PROTO(struct request_queue *q, struct request *rq),
53
54         TP_ARGS(q, rq)
55 );
56
57 DEFINE_EVENT(block_rq_with_error, block_rq_complete,
58
59         TP_PROTO(struct request_queue *q, struct request *rq),
60
61         TP_ARGS(q, rq)
62 );
63
64 DECLARE_EVENT_CLASS(block_rq,
65
66         TP_PROTO(struct request_queue *q, struct request *rq),
67
68         TP_ARGS(q, rq),
69
70         TP_STRUCT__entry(
71                 __field(  dev_t,        dev                     )
72                 __field(  sector_t,     sector                  )
73                 __field(  unsigned int, nr_sector               )
74                 __field(  unsigned int, bytes                   )
75                 __array(  char,         rwbs,   6               )
76                 __array(  char,         comm,   TASK_COMM_LEN   )
77                 __dynamic_array( char,  cmd,    blk_cmd_buf_len(rq)     )
78         ),
79
80         TP_fast_assign(
81                 __entry->dev       = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
82                 __entry->sector    = blk_pc_request(rq) ? 0 : blk_rq_pos(rq);
83                 __entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
84                 __entry->bytes     = blk_pc_request(rq) ? blk_rq_bytes(rq) : 0;
85
86                 blk_fill_rwbs_rq(__entry->rwbs, rq);
87                 blk_dump_cmd(__get_str(cmd), rq);
88                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
89         ),
90
91         TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
92                   MAJOR(__entry->dev), MINOR(__entry->dev),
93                   __entry->rwbs, __entry->bytes, __get_str(cmd),
94                   (unsigned long long)__entry->sector,
95                   __entry->nr_sector, __entry->comm)
96 );
97
98 DEFINE_EVENT(block_rq, block_rq_insert,
99
100         TP_PROTO(struct request_queue *q, struct request *rq),
101
102         TP_ARGS(q, rq)
103 );
104
105 DEFINE_EVENT(block_rq, block_rq_issue,
106
107         TP_PROTO(struct request_queue *q, struct request *rq),
108
109         TP_ARGS(q, rq)
110 );
111
112 TRACE_EVENT(block_bio_bounce,
113
114         TP_PROTO(struct request_queue *q, struct bio *bio),
115
116         TP_ARGS(q, bio),
117
118         TP_STRUCT__entry(
119                 __field( dev_t,         dev                     )
120                 __field( sector_t,      sector                  )
121                 __field( unsigned int,  nr_sector               )
122                 __array( char,          rwbs,   6               )
123                 __array( char,          comm,   TASK_COMM_LEN   )
124         ),
125
126         TP_fast_assign(
127                 __entry->dev            = bio->bi_bdev ?
128                                           bio->bi_bdev->bd_dev : 0;
129                 __entry->sector         = bio->bi_sector;
130                 __entry->nr_sector      = bio->bi_size >> 9;
131                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
132                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
133         ),
134
135         TP_printk("%d,%d %s %llu + %u [%s]",
136                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
137                   (unsigned long long)__entry->sector,
138                   __entry->nr_sector, __entry->comm)
139 );
140
141 TRACE_EVENT(block_bio_complete,
142
143         TP_PROTO(struct request_queue *q, struct bio *bio),
144
145         TP_ARGS(q, bio),
146
147         TP_STRUCT__entry(
148                 __field( dev_t,         dev             )
149                 __field( sector_t,      sector          )
150                 __field( unsigned,      nr_sector       )
151                 __field( int,           error           )
152                 __array( char,          rwbs,   6       )
153         ),
154
155         TP_fast_assign(
156                 __entry->dev            = bio->bi_bdev->bd_dev;
157                 __entry->sector         = bio->bi_sector;
158                 __entry->nr_sector      = bio->bi_size >> 9;
159                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
160         ),
161
162         TP_printk("%d,%d %s %llu + %u [%d]",
163                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
164                   (unsigned long long)__entry->sector,
165                   __entry->nr_sector, __entry->error)
166 );
167
168 DECLARE_EVENT_CLASS(block_bio,
169
170         TP_PROTO(struct request_queue *q, struct bio *bio),
171
172         TP_ARGS(q, bio),
173
174         TP_STRUCT__entry(
175                 __field( dev_t,         dev                     )
176                 __field( sector_t,      sector                  )
177                 __field( unsigned int,  nr_sector               )
178                 __array( char,          rwbs,   6               )
179                 __array( char,          comm,   TASK_COMM_LEN   )
180         ),
181
182         TP_fast_assign(
183                 __entry->dev            = bio->bi_bdev->bd_dev;
184                 __entry->sector         = bio->bi_sector;
185                 __entry->nr_sector      = bio->bi_size >> 9;
186                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
187                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
188         ),
189
190         TP_printk("%d,%d %s %llu + %u [%s]",
191                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
192                   (unsigned long long)__entry->sector,
193                   __entry->nr_sector, __entry->comm)
194 );
195
196 DEFINE_EVENT(block_bio, block_bio_backmerge,
197
198         TP_PROTO(struct request_queue *q, struct bio *bio),
199
200         TP_ARGS(q, bio)
201 );
202
203 DEFINE_EVENT(block_bio, block_bio_frontmerge,
204
205         TP_PROTO(struct request_queue *q, struct bio *bio),
206
207         TP_ARGS(q, bio)
208 );
209
210 DEFINE_EVENT(block_bio, block_bio_queue,
211
212         TP_PROTO(struct request_queue *q, struct bio *bio),
213
214         TP_ARGS(q, bio)
215 );
216
217 DECLARE_EVENT_CLASS(block_get_rq,
218
219         TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
220
221         TP_ARGS(q, bio, rw),
222
223         TP_STRUCT__entry(
224                 __field( dev_t,         dev                     )
225                 __field( sector_t,      sector                  )
226                 __field( unsigned int,  nr_sector               )
227                 __array( char,          rwbs,   6               )
228                 __array( char,          comm,   TASK_COMM_LEN   )
229         ),
230
231         TP_fast_assign(
232                 __entry->dev            = bio ? bio->bi_bdev->bd_dev : 0;
233                 __entry->sector         = bio ? bio->bi_sector : 0;
234                 __entry->nr_sector      = bio ? bio->bi_size >> 9 : 0;
235                 blk_fill_rwbs(__entry->rwbs,
236                               bio ? bio->bi_rw : 0, __entry->nr_sector);
237                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
238         ),
239
240         TP_printk("%d,%d %s %llu + %u [%s]",
241                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
242                   (unsigned long long)__entry->sector,
243                   __entry->nr_sector, __entry->comm)
244 );
245
246 DEFINE_EVENT(block_get_rq, block_getrq,
247
248         TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
249
250         TP_ARGS(q, bio, rw)
251 );
252
253 DEFINE_EVENT(block_get_rq, block_sleeprq,
254
255         TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
256
257         TP_ARGS(q, bio, rw)
258 );
259
260 TRACE_EVENT(block_plug,
261
262         TP_PROTO(struct request_queue *q),
263
264         TP_ARGS(q),
265
266         TP_STRUCT__entry(
267                 __array( char,          comm,   TASK_COMM_LEN   )
268         ),
269
270         TP_fast_assign(
271                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
272         ),
273
274         TP_printk("[%s]", __entry->comm)
275 );
276
277 DECLARE_EVENT_CLASS(block_unplug,
278
279         TP_PROTO(struct request_queue *q),
280
281         TP_ARGS(q),
282
283         TP_STRUCT__entry(
284                 __field( int,           nr_rq                   )
285                 __array( char,          comm,   TASK_COMM_LEN   )
286         ),
287
288         TP_fast_assign(
289                 __entry->nr_rq  = q->rq.count[READ] + q->rq.count[WRITE];
290                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
291         ),
292
293         TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
294 );
295
296 DEFINE_EVENT(block_unplug, block_unplug_timer,
297
298         TP_PROTO(struct request_queue *q),
299
300         TP_ARGS(q)
301 );
302
303 DEFINE_EVENT(block_unplug, block_unplug_io,
304
305         TP_PROTO(struct request_queue *q),
306
307         TP_ARGS(q)
308 );
309
310 TRACE_EVENT(block_split,
311
312         TP_PROTO(struct request_queue *q, struct bio *bio,
313                  unsigned int new_sector),
314
315         TP_ARGS(q, bio, new_sector),
316
317         TP_STRUCT__entry(
318                 __field( dev_t,         dev                             )
319                 __field( sector_t,      sector                          )
320                 __field( sector_t,      new_sector                      )
321                 __array( char,          rwbs,           6               )
322                 __array( char,          comm,           TASK_COMM_LEN   )
323         ),
324
325         TP_fast_assign(
326                 __entry->dev            = bio->bi_bdev->bd_dev;
327                 __entry->sector         = bio->bi_sector;
328                 __entry->new_sector     = new_sector;
329                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
330                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
331         ),
332
333         TP_printk("%d,%d %s %llu / %llu [%s]",
334                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
335                   (unsigned long long)__entry->sector,
336                   (unsigned long long)__entry->new_sector,
337                   __entry->comm)
338 );
339
340 TRACE_EVENT(block_remap,
341
342         TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
343                  sector_t from),
344
345         TP_ARGS(q, bio, dev, from),
346
347         TP_STRUCT__entry(
348                 __field( dev_t,         dev             )
349                 __field( sector_t,      sector          )
350                 __field( unsigned int,  nr_sector       )
351                 __field( dev_t,         old_dev         )
352                 __field( sector_t,      old_sector      )
353                 __array( char,          rwbs,   6       )
354         ),
355
356         TP_fast_assign(
357                 __entry->dev            = bio->bi_bdev->bd_dev;
358                 __entry->sector         = bio->bi_sector;
359                 __entry->nr_sector      = bio->bi_size >> 9;
360                 __entry->old_dev        = dev;
361                 __entry->old_sector     = from;
362                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
363         ),
364
365         TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
366                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
367                   (unsigned long long)__entry->sector,
368                   __entry->nr_sector,
369                   MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
370                   (unsigned long long)__entry->old_sector)
371 );
372
373 TRACE_EVENT(block_rq_remap,
374
375         TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
376                  sector_t from),
377
378         TP_ARGS(q, rq, dev, from),
379
380         TP_STRUCT__entry(
381                 __field( dev_t,         dev             )
382                 __field( sector_t,      sector          )
383                 __field( unsigned int,  nr_sector       )
384                 __field( dev_t,         old_dev         )
385                 __field( sector_t,      old_sector      )
386                 __array( char,          rwbs,   6       )
387         ),
388
389         TP_fast_assign(
390                 __entry->dev            = disk_devt(rq->rq_disk);
391                 __entry->sector         = blk_rq_pos(rq);
392                 __entry->nr_sector      = blk_rq_sectors(rq);
393                 __entry->old_dev        = dev;
394                 __entry->old_sector     = from;
395                 blk_fill_rwbs_rq(__entry->rwbs, rq);
396         ),
397
398         TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
399                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
400                   (unsigned long long)__entry->sector,
401                   __entry->nr_sector,
402                   MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
403                   (unsigned long long)__entry->old_sector)
404 );
405
406 #endif /* _TRACE_BLOCK_H */
407
408 /* This part must be outside protection */
409 #include <trace/define_trace.h>
410