Add a tracepoint for block request remapping
[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 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 : 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 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 : blk_rq_pos(rq);
62                 __entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
63                 __entry->bytes     = blk_pc_request(rq) ? blk_rq_bytes(rq) : 0;
64
65                 blk_fill_rwbs_rq(__entry->rwbs, rq);
66                 blk_dump_cmd(__get_str(cmd), rq);
67                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
68         ),
69
70         TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
71                   MAJOR(__entry->dev), MINOR(__entry->dev),
72                   __entry->rwbs, __entry->bytes, __get_str(cmd),
73                   (unsigned long long)__entry->sector,
74                   __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 : blk_rq_pos(rq);
96                 __entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
97                 __entry->bytes     = blk_pc_request(rq) ? blk_rq_bytes(rq) : 0;
98
99                 blk_fill_rwbs_rq(__entry->rwbs, rq);
100                 blk_dump_cmd(__get_str(cmd), rq);
101                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
102         ),
103
104         TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
105                   MAJOR(__entry->dev), MINOR(__entry->dev),
106                   __entry->rwbs, __entry->bytes, __get_str(cmd),
107                   (unsigned long long)__entry->sector,
108                   __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 : blk_rq_pos(rq);
129                 __entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
130                 __entry->errors    = rq->errors;
131
132                 blk_fill_rwbs_rq(__entry->rwbs, rq);
133                 blk_dump_cmd(__get_str(cmd), rq);
134         ),
135
136         TP_printk("%d,%d %s (%s) %llu + %u [%d]",
137                   MAJOR(__entry->dev), MINOR(__entry->dev),
138                   __entry->rwbs, __get_str(cmd),
139                   (unsigned long long)__entry->sector,
140                   __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 : blk_rq_pos(rq);
161                 __entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
162                 __entry->errors    = rq->errors;
163
164                 blk_fill_rwbs_rq(__entry->rwbs, rq);
165                 blk_dump_cmd(__get_str(cmd), rq);
166         ),
167
168         TP_printk("%d,%d %s (%s) %llu + %u [%d]",
169                   MAJOR(__entry->dev), MINOR(__entry->dev),
170                   __entry->rwbs, __get_str(cmd),
171                   (unsigned long long)__entry->sector,
172                   __entry->nr_sector, __entry->errors)
173 );
174
175 TRACE_EVENT(block_bio_bounce,
176
177         TP_PROTO(struct request_queue *q, struct bio *bio),
178
179         TP_ARGS(q, bio),
180
181         TP_STRUCT__entry(
182                 __field( dev_t,         dev                     )
183                 __field( sector_t,      sector                  )
184                 __field( unsigned int,  nr_sector               )
185                 __array( char,          rwbs,   6               )
186                 __array( char,          comm,   TASK_COMM_LEN   )
187         ),
188
189         TP_fast_assign(
190                 __entry->dev            = bio->bi_bdev ?
191                                           bio->bi_bdev->bd_dev : 0;
192                 __entry->sector         = bio->bi_sector;
193                 __entry->nr_sector      = bio->bi_size >> 9;
194                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
195                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
196         ),
197
198         TP_printk("%d,%d %s %llu + %u [%s]",
199                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
200                   (unsigned long long)__entry->sector,
201                   __entry->nr_sector, __entry->comm)
202 );
203
204 TRACE_EVENT(block_bio_complete,
205
206         TP_PROTO(struct request_queue *q, struct bio *bio),
207
208         TP_ARGS(q, bio),
209
210         TP_STRUCT__entry(
211                 __field( dev_t,         dev             )
212                 __field( sector_t,      sector          )
213                 __field( unsigned,      nr_sector       )
214                 __field( int,           error           )
215                 __array( char,          rwbs,   6       )
216         ),
217
218         TP_fast_assign(
219                 __entry->dev            = bio->bi_bdev->bd_dev;
220                 __entry->sector         = bio->bi_sector;
221                 __entry->nr_sector      = bio->bi_size >> 9;
222                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
223         ),
224
225         TP_printk("%d,%d %s %llu + %u [%d]",
226                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
227                   (unsigned long long)__entry->sector,
228                   __entry->nr_sector, __entry->error)
229 );
230
231 TRACE_EVENT(block_bio_backmerge,
232
233         TP_PROTO(struct request_queue *q, struct bio *bio),
234
235         TP_ARGS(q, bio),
236
237         TP_STRUCT__entry(
238                 __field( dev_t,         dev                     )
239                 __field( sector_t,      sector                  )
240                 __field( unsigned int,  nr_sector               )
241                 __array( char,          rwbs,   6               )
242                 __array( char,          comm,   TASK_COMM_LEN   )
243         ),
244
245         TP_fast_assign(
246                 __entry->dev            = bio->bi_bdev->bd_dev;
247                 __entry->sector         = bio->bi_sector;
248                 __entry->nr_sector      = bio->bi_size >> 9;
249                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
250                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
251         ),
252
253         TP_printk("%d,%d %s %llu + %u [%s]",
254                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
255                   (unsigned long long)__entry->sector,
256                   __entry->nr_sector, __entry->comm)
257 );
258
259 TRACE_EVENT(block_bio_frontmerge,
260
261         TP_PROTO(struct request_queue *q, struct bio *bio),
262
263         TP_ARGS(q, bio),
264
265         TP_STRUCT__entry(
266                 __field( dev_t,         dev                     )
267                 __field( sector_t,      sector                  )
268                 __field( unsigned,      nr_sector               )
269                 __array( char,          rwbs,   6               )
270                 __array( char,          comm,   TASK_COMM_LEN   )
271         ),
272
273         TP_fast_assign(
274                 __entry->dev            = bio->bi_bdev->bd_dev;
275                 __entry->sector         = bio->bi_sector;
276                 __entry->nr_sector      = bio->bi_size >> 9;
277                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
278                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
279         ),
280
281         TP_printk("%d,%d %s %llu + %u [%s]",
282                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
283                   (unsigned long long)__entry->sector,
284                   __entry->nr_sector, __entry->comm)
285 );
286
287 TRACE_EVENT(block_bio_queue,
288
289         TP_PROTO(struct request_queue *q, struct bio *bio),
290
291         TP_ARGS(q, bio),
292
293         TP_STRUCT__entry(
294                 __field( dev_t,         dev                     )
295                 __field( sector_t,      sector                  )
296                 __field( unsigned int,  nr_sector               )
297                 __array( char,          rwbs,   6               )
298                 __array( char,          comm,   TASK_COMM_LEN   )
299         ),
300
301         TP_fast_assign(
302                 __entry->dev            = bio->bi_bdev->bd_dev;
303                 __entry->sector         = bio->bi_sector;
304                 __entry->nr_sector      = bio->bi_size >> 9;
305                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
306                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
307         ),
308
309         TP_printk("%d,%d %s %llu + %u [%s]",
310                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
311                   (unsigned long long)__entry->sector,
312                   __entry->nr_sector, __entry->comm)
313 );
314
315 TRACE_EVENT(block_getrq,
316
317         TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
318
319         TP_ARGS(q, bio, rw),
320
321         TP_STRUCT__entry(
322                 __field( dev_t,         dev                     )
323                 __field( sector_t,      sector                  )
324                 __field( unsigned int,  nr_sector               )
325                 __array( char,          rwbs,   6               )
326                 __array( char,          comm,   TASK_COMM_LEN   )
327         ),
328
329         TP_fast_assign(
330                 __entry->dev            = bio ? bio->bi_bdev->bd_dev : 0;
331                 __entry->sector         = bio ? bio->bi_sector : 0;
332                 __entry->nr_sector      = bio ? bio->bi_size >> 9 : 0;
333                 blk_fill_rwbs(__entry->rwbs,
334                               bio ? bio->bi_rw : 0, __entry->nr_sector);
335                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
336         ),
337
338         TP_printk("%d,%d %s %llu + %u [%s]",
339                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
340                   (unsigned long long)__entry->sector,
341                   __entry->nr_sector, __entry->comm)
342 );
343
344 TRACE_EVENT(block_sleeprq,
345
346         TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
347
348         TP_ARGS(q, bio, rw),
349
350         TP_STRUCT__entry(
351                 __field( dev_t,         dev                     )
352                 __field( sector_t,      sector                  )
353                 __field( unsigned int,  nr_sector               )
354                 __array( char,          rwbs,   6               )
355                 __array( char,          comm,   TASK_COMM_LEN   )
356         ),
357
358         TP_fast_assign(
359                 __entry->dev            = bio ? bio->bi_bdev->bd_dev : 0;
360                 __entry->sector         = bio ? bio->bi_sector : 0;
361                 __entry->nr_sector      = bio ? bio->bi_size >> 9 : 0;
362                 blk_fill_rwbs(__entry->rwbs,
363                             bio ? bio->bi_rw : 0, __entry->nr_sector);
364                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
365         ),
366
367         TP_printk("%d,%d %s %llu + %u [%s]",
368                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
369                   (unsigned long long)__entry->sector,
370                   __entry->nr_sector, __entry->comm)
371 );
372
373 TRACE_EVENT(block_plug,
374
375         TP_PROTO(struct request_queue *q),
376
377         TP_ARGS(q),
378
379         TP_STRUCT__entry(
380                 __array( char,          comm,   TASK_COMM_LEN   )
381         ),
382
383         TP_fast_assign(
384                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
385         ),
386
387         TP_printk("[%s]", __entry->comm)
388 );
389
390 TRACE_EVENT(block_unplug_timer,
391
392         TP_PROTO(struct request_queue *q),
393
394         TP_ARGS(q),
395
396         TP_STRUCT__entry(
397                 __field( int,           nr_rq                   )
398                 __array( char,          comm,   TASK_COMM_LEN   )
399         ),
400
401         TP_fast_assign(
402                 __entry->nr_rq  = q->rq.count[READ] + q->rq.count[WRITE];
403                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
404         ),
405
406         TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
407 );
408
409 TRACE_EVENT(block_unplug_io,
410
411         TP_PROTO(struct request_queue *q),
412
413         TP_ARGS(q),
414
415         TP_STRUCT__entry(
416                 __field( int,           nr_rq                   )
417                 __array( char,          comm,   TASK_COMM_LEN   )
418         ),
419
420         TP_fast_assign(
421                 __entry->nr_rq  = q->rq.count[READ] + q->rq.count[WRITE];
422                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
423         ),
424
425         TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
426 );
427
428 TRACE_EVENT(block_split,
429
430         TP_PROTO(struct request_queue *q, struct bio *bio,
431                  unsigned int new_sector),
432
433         TP_ARGS(q, bio, new_sector),
434
435         TP_STRUCT__entry(
436                 __field( dev_t,         dev                             )
437                 __field( sector_t,      sector                          )
438                 __field( sector_t,      new_sector                      )
439                 __array( char,          rwbs,           6               )
440                 __array( char,          comm,           TASK_COMM_LEN   )
441         ),
442
443         TP_fast_assign(
444                 __entry->dev            = bio->bi_bdev->bd_dev;
445                 __entry->sector         = bio->bi_sector;
446                 __entry->new_sector     = new_sector;
447                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
448                 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
449         ),
450
451         TP_printk("%d,%d %s %llu / %llu [%s]",
452                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
453                   (unsigned long long)__entry->sector,
454                   (unsigned long long)__entry->new_sector,
455                   __entry->comm)
456 );
457
458 TRACE_EVENT(block_remap,
459
460         TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
461                  sector_t from),
462
463         TP_ARGS(q, bio, dev, from),
464
465         TP_STRUCT__entry(
466                 __field( dev_t,         dev             )
467                 __field( sector_t,      sector          )
468                 __field( unsigned int,  nr_sector       )
469                 __field( dev_t,         old_dev         )
470                 __field( sector_t,      old_sector      )
471                 __array( char,          rwbs,   6       )
472         ),
473
474         TP_fast_assign(
475                 __entry->dev            = bio->bi_bdev->bd_dev;
476                 __entry->sector         = bio->bi_sector;
477                 __entry->nr_sector      = bio->bi_size >> 9;
478                 __entry->old_dev        = dev;
479                 __entry->old_sector     = from;
480                 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
481         ),
482
483         TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
484                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
485                   (unsigned long long)__entry->sector,
486                   __entry->nr_sector,
487                   MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
488                   (unsigned long long)__entry->old_sector)
489 );
490
491 TRACE_EVENT(block_rq_remap,
492
493         TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
494                  sector_t from),
495
496         TP_ARGS(q, rq, dev, from),
497
498         TP_STRUCT__entry(
499                 __field( dev_t,         dev             )
500                 __field( sector_t,      sector          )
501                 __field( unsigned int,  nr_sector       )
502                 __field( dev_t,         old_dev         )
503                 __field( sector_t,      old_sector      )
504                 __array( char,          rwbs,   6       )
505         ),
506
507         TP_fast_assign(
508                 __entry->dev            = disk_devt(rq->rq_disk);
509                 __entry->sector         = blk_rq_pos(rq);
510                 __entry->nr_sector      = blk_rq_sectors(rq);
511                 __entry->old_dev        = dev;
512                 __entry->old_sector     = from;
513                 blk_fill_rwbs_rq(__entry->rwbs, rq);
514         ),
515
516         TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
517                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
518                   (unsigned long long)__entry->sector,
519                   __entry->nr_sector,
520                   MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
521                   (unsigned long long)__entry->old_sector)
522 );
523
524 #endif /* _TRACE_BLOCK_H */
525
526 /* This part must be outside protection */
527 #include <trace/define_trace.h>
528