2 #define TRACE_SYSTEM block
4 #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/blktrace_api.h>
8 #include <linux/blkdev.h>
9 #include <linux/tracepoint.h>
11 DECLARE_EVENT_CLASS(block_rq_with_error
,
13 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
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
) )
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
;
32 blk_fill_rwbs_rq(__entry
->rwbs
, rq
);
33 blk_dump_cmd(__get_str(cmd
), rq
);
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
)
43 DEFINE_EVENT(block_rq_with_error
, block_rq_abort
,
45 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
50 DEFINE_EVENT(block_rq_with_error
, block_rq_requeue
,
52 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
57 DEFINE_EVENT(block_rq_with_error
, block_rq_complete
,
59 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
64 DECLARE_EVENT_CLASS(block_rq
,
66 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
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
) )
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;
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
);
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
)
98 DEFINE_EVENT(block_rq
, block_rq_insert
,
100 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
105 DEFINE_EVENT(block_rq
, block_rq_issue
,
107 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
112 TRACE_EVENT(block_bio_bounce
,
114 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
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
)
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
);
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
)
141 TRACE_EVENT(block_bio_complete
,
143 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
148 __field( dev_t
, dev
)
149 __field( sector_t
, sector
)
150 __field( unsigned, nr_sector
)
151 __field( int, error
)
152 __array( char, rwbs
, 6 )
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
);
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
)
168 DECLARE_EVENT_CLASS(block_bio
,
170 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
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
)
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
);
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
)
196 DEFINE_EVENT(block_bio
, block_bio_backmerge
,
198 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
203 DEFINE_EVENT(block_bio
, block_bio_frontmerge
,
205 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
210 DEFINE_EVENT(block_bio
, block_bio_queue
,
212 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
217 DECLARE_EVENT_CLASS(block_get_rq
,
219 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
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
)
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
);
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
)
246 DEFINE_EVENT(block_get_rq
, block_getrq
,
248 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
253 DEFINE_EVENT(block_get_rq
, block_sleeprq
,
255 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
260 TRACE_EVENT(block_plug
,
262 TP_PROTO(struct request_queue
*q
),
267 __array( char, comm
, TASK_COMM_LEN
)
271 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
274 TP_printk("[%s]", __entry
->comm
)
277 DECLARE_EVENT_CLASS(block_unplug
,
279 TP_PROTO(struct request_queue
*q
),
284 __field( int, nr_rq
)
285 __array( char, comm
, TASK_COMM_LEN
)
289 __entry
->nr_rq
= q
->rq
.count
[READ
] + q
->rq
.count
[WRITE
];
290 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
293 TP_printk("[%s] %d", __entry
->comm
, __entry
->nr_rq
)
296 DEFINE_EVENT(block_unplug
, block_unplug_timer
,
298 TP_PROTO(struct request_queue
*q
),
303 DEFINE_EVENT(block_unplug
, block_unplug_io
,
305 TP_PROTO(struct request_queue
*q
),
310 TRACE_EVENT(block_split
,
312 TP_PROTO(struct request_queue
*q
, struct bio
*bio
,
313 unsigned int new_sector
),
315 TP_ARGS(q
, bio
, new_sector
),
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
)
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
);
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
,
340 TRACE_EVENT(block_remap
,
342 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, dev_t dev
,
345 TP_ARGS(q
, bio
, dev
, from
),
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 )
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
);
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
,
369 MAJOR(__entry
->old_dev
), MINOR(__entry
->old_dev
),
370 (unsigned long long)__entry
->old_sector
)
373 TRACE_EVENT(block_rq_remap
,
375 TP_PROTO(struct request_queue
*q
, struct request
*rq
, dev_t dev
,
378 TP_ARGS(q
, rq
, dev
, from
),
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 )
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
);
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
,
402 MAJOR(__entry
->old_dev
), MINOR(__entry
->old_dev
),
403 (unsigned long long)__entry
->old_sector
)
406 #endif /* _TRACE_BLOCK_H */
408 /* This part must be outside protection */
409 #include <trace/define_trace.h>