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