42184f3d1e715555aa4eed32c30b27359949372c
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>
10 #include <linux/trace_seq.h>
12 #ifndef _TRACE_BLOCK_DEF_
13 #define _TRACE_BLOCK_DEF_
15 #define __blk_dump_cmd(cmd, len) "<unknown>"
18 RWBS_FLAG_WRITE
= (1 << 0),
19 RWBS_FLAG_DISCARD
= (1 << 1),
20 RWBS_FLAG_READ
= (1 << 2),
21 RWBS_FLAG_RAHEAD
= (1 << 3),
22 RWBS_FLAG_SYNC
= (1 << 4),
23 RWBS_FLAG_META
= (1 << 5),
24 RWBS_FLAG_SECURE
= (1 << 6),
27 #endif /* _TRACE_BLOCK_DEF_ */
29 #define __print_rwbs_flags(rwbs) \
30 __print_flags(rwbs, "", \
31 { RWBS_FLAG_WRITE, "W" }, \
32 { RWBS_FLAG_DISCARD, "D" }, \
33 { RWBS_FLAG_READ, "R" }, \
34 { RWBS_FLAG_RAHEAD, "A" }, \
35 { RWBS_FLAG_SYNC, "S" }, \
36 { RWBS_FLAG_META, "M" }, \
37 { RWBS_FLAG_SECURE, "E" })
39 #define blk_fill_rwbs(rwbs, rw, bytes) \
40 tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
41 ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \
42 ( (bytes) ? RWBS_FLAG_READ : \
44 | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \
45 | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \
46 | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \
47 | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0))
49 DECLARE_EVENT_CLASS(block_rq_with_error
,
51 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
57 __field( sector_t
, sector
)
58 __field( unsigned int, nr_sector
)
59 __field( int, errors
)
60 __field( unsigned int, rwbs
)
61 __dynamic_array_hex( unsigned char, cmd
,
62 (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
67 tp_assign(dev
, rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0)
68 tp_assign(sector
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
70 tp_assign(nr_sector
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
71 0 : blk_rq_sectors(rq
))
72 tp_assign(errors
, rq
->errors
)
73 blk_fill_rwbs(rwbs
, rq
->cmd_flags
, blk_rq_bytes(rq
))
74 tp_memcpy_dyn(cmd
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
78 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
79 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
80 __print_rwbs_flags(__entry
->rwbs
),
81 __blk_dump_cmd(__get_dynamic_array(cmd
),
82 __get_dynamic_array_len(cmd
)),
83 (unsigned long long)__entry
->sector
,
84 __entry
->nr_sector
, __entry
->errors
)
88 * block_rq_abort - abort block operation request
89 * @q: queue containing the block operation request
90 * @rq: block IO operation request
92 * Called immediately after pending block IO operation request @rq in
93 * queue @q is aborted. The fields in the operation request @rq
94 * can be examined to determine which device and sectors the pending
95 * operation would access.
97 DEFINE_EVENT(block_rq_with_error
, block_rq_abort
,
99 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
105 * block_rq_requeue - place block IO request back on a queue
106 * @q: queue holding operation
107 * @rq: block IO operation request
109 * The block operation request @rq is being placed back into queue
110 * @q. For some reason the request was not completed and needs to be
111 * put back in the queue.
113 DEFINE_EVENT(block_rq_with_error
, block_rq_requeue
,
115 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
121 * block_rq_complete - block IO operation completed by device driver
122 * @q: queue containing the block operation request
123 * @rq: block operations request
125 * The block_rq_complete tracepoint event indicates that some portion
126 * of operation request has been completed by the device driver. If
127 * the @rq->bio is %NULL, then there is absolutely no additional work to
128 * do for the request. If @rq->bio is non-NULL then there is
129 * additional work required to complete the request.
131 DEFINE_EVENT(block_rq_with_error
, block_rq_complete
,
133 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
138 DECLARE_EVENT_CLASS(block_rq
,
140 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
145 __field( dev_t
, dev
)
146 __field( sector_t
, sector
)
147 __field( unsigned int, nr_sector
)
148 __field( unsigned int, bytes
)
149 __field( unsigned int, rwbs
)
150 __array_text( char, comm
, TASK_COMM_LEN
)
151 __dynamic_array_hex( unsigned char, cmd
,
152 (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
157 tp_assign(dev
, rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0)
158 tp_assign(sector
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
160 tp_assign(nr_sector
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
161 0 : blk_rq_sectors(rq
))
162 tp_assign(bytes
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
163 blk_rq_bytes(rq
) : 0)
164 blk_fill_rwbs(rwbs
, rq
->cmd_flags
, blk_rq_bytes(rq
))
165 tp_memcpy_dyn(cmd
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
167 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
170 TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
171 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
172 __print_rwbs_flags(__entry
->rwbs
),
174 __blk_dump_cmd(__get_dynamic_array(cmd
),
175 __get_dynamic_array_len(cmd
)),
176 (unsigned long long)__entry
->sector
,
177 __entry
->nr_sector
, __entry
->comm
)
181 * block_rq_insert - insert block operation request into queue
183 * @rq: block IO operation request
185 * Called immediately before block operation request @rq is inserted
186 * into queue @q. The fields in the operation request @rq struct can
187 * be examined to determine which device and sectors the pending
188 * operation would access.
190 DEFINE_EVENT(block_rq
, block_rq_insert
,
192 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
198 * block_rq_issue - issue pending block IO request operation to device driver
199 * @q: queue holding operation
200 * @rq: block IO operation operation request
202 * Called when block operation request @rq from queue @q is sent to a
203 * device driver for processing.
205 DEFINE_EVENT(block_rq
, block_rq_issue
,
207 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
213 * block_bio_bounce - used bounce buffer when processing block operation
214 * @q: queue holding the block operation
215 * @bio: block operation
217 * A bounce buffer was used to handle the block operation @bio in @q.
218 * This occurs when hardware limitations prevent a direct transfer of
219 * data between the @bio data memory area and the IO device. Use of a
220 * bounce buffer requires extra copying of data and decreases
223 TRACE_EVENT(block_bio_bounce
,
225 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
230 __field( dev_t
, dev
)
231 __field( sector_t
, sector
)
232 __field( unsigned int, nr_sector
)
233 __field( unsigned int, rwbs
)
234 __array_text( char, comm
, TASK_COMM_LEN
)
238 tp_assign(dev
, bio
->bi_bdev
?
239 bio
->bi_bdev
->bd_dev
: 0)
240 tp_assign(sector
, bio
->bi_sector
)
241 tp_assign(nr_sector
, bio
->bi_size
>> 9)
242 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
243 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
246 TP_printk("%d,%d %s %llu + %u [%s]",
247 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
248 __print_rwbs_flags(__entry
->rwbs
),
249 (unsigned long long)__entry
->sector
,
250 __entry
->nr_sector
, __entry
->comm
)
254 * block_bio_complete - completed all work on the block operation
255 * @q: queue holding the block operation
256 * @bio: block operation completed
257 * @error: io error value
259 * This tracepoint indicates there is no further work to do on this
260 * block IO operation @bio.
262 TRACE_EVENT(block_bio_complete
,
264 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int error
),
266 TP_ARGS(q
, bio
, error
),
269 __field( dev_t
, dev
)
270 __field( sector_t
, sector
)
271 __field( unsigned, nr_sector
)
272 __field( int, error
)
273 __field( unsigned int, rwbs
)
277 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
278 tp_assign(sector
, bio
->bi_sector
)
279 tp_assign(nr_sector
, bio
->bi_size
>> 9)
280 tp_assign(error
, error
)
281 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
284 TP_printk("%d,%d %s %llu + %u [%d]",
285 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
286 __print_rwbs_flags(__entry
->rwbs
),
287 (unsigned long long)__entry
->sector
,
288 __entry
->nr_sector
, __entry
->error
)
291 DECLARE_EVENT_CLASS(block_bio
,
293 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
298 __field( dev_t
, dev
)
299 __field( sector_t
, sector
)
300 __field( unsigned int, nr_sector
)
301 __field( unsigned int, rwbs
)
302 __array_text( char, comm
, TASK_COMM_LEN
)
306 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
307 tp_assign(sector
, bio
->bi_sector
)
308 tp_assign(nr_sector
, bio
->bi_size
>> 9)
309 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
310 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
313 TP_printk("%d,%d %s %llu + %u [%s]",
314 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
315 __print_rwbs_flags(__entry
->rwbs
),
316 (unsigned long long)__entry
->sector
,
317 __entry
->nr_sector
, __entry
->comm
)
321 * block_bio_backmerge - merging block operation to the end of an existing operation
322 * @q: queue holding operation
323 * @bio: new block operation to merge
325 * Merging block request @bio to the end of an existing block request
328 DEFINE_EVENT(block_bio
, block_bio_backmerge
,
330 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
336 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
337 * @q: queue holding operation
338 * @bio: new block operation to merge
340 * Merging block IO operation @bio to the beginning of an existing block
341 * operation in queue @q.
343 DEFINE_EVENT(block_bio
, block_bio_frontmerge
,
345 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
351 * block_bio_queue - putting new block IO operation in queue
352 * @q: queue holding operation
353 * @bio: new block operation
355 * About to place the block IO operation @bio into queue @q.
357 DEFINE_EVENT(block_bio
, block_bio_queue
,
359 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
364 DECLARE_EVENT_CLASS(block_get_rq
,
366 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
371 __field( dev_t
, dev
)
372 __field( sector_t
, sector
)
373 __field( unsigned int, nr_sector
)
374 __field( unsigned int, rwbs
)
375 __array_text( char, comm
, TASK_COMM_LEN
)
379 tp_assign(dev
, bio
? bio
->bi_bdev
->bd_dev
: 0)
380 tp_assign(sector
, bio
? bio
->bi_sector
: 0)
381 tp_assign(nr_sector
, bio
? bio
->bi_size
>> 9 : 0)
382 blk_fill_rwbs(rwbs
, bio
? bio
->bi_rw
: 0,
383 bio
? bio
->bi_size
>> 9 : 0)
384 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
387 TP_printk("%d,%d %s %llu + %u [%s]",
388 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
389 __print_rwbs_flags(__entry
->rwbs
),
390 (unsigned long long)__entry
->sector
,
391 __entry
->nr_sector
, __entry
->comm
)
395 * block_getrq - get a free request entry in queue for block IO operations
396 * @q: queue for operations
397 * @bio: pending block IO operation
398 * @rw: low bit indicates a read (%0) or a write (%1)
400 * A request struct for queue @q has been allocated to handle the
401 * block IO operation @bio.
403 DEFINE_EVENT(block_get_rq
, block_getrq
,
405 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
411 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
412 * @q: queue for operation
413 * @bio: pending block IO operation
414 * @rw: low bit indicates a read (%0) or a write (%1)
416 * In the case where a request struct cannot be provided for queue @q
417 * the process needs to wait for an request struct to become
418 * available. This tracepoint event is generated each time the
419 * process goes to sleep waiting for request struct become available.
421 DEFINE_EVENT(block_get_rq
, block_sleeprq
,
423 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
429 * block_plug - keep operations requests in request queue
430 * @q: request queue to plug
432 * Plug the request queue @q. Do not allow block operation requests
433 * to be sent to the device driver. Instead, accumulate requests in
434 * the queue to improve throughput performance of the block device.
436 TRACE_EVENT(block_plug
,
438 TP_PROTO(struct request_queue
*q
),
443 __array_text( char, comm
, TASK_COMM_LEN
)
447 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
450 TP_printk("[%s]", __entry
->comm
)
453 DECLARE_EVENT_CLASS(block_unplug
,
455 TP_PROTO(struct request_queue
*q
, unsigned int depth
, bool explicit),
457 TP_ARGS(q
, depth
, explicit),
460 __field( int, nr_rq
)
461 __array_text( char, comm
, TASK_COMM_LEN
)
465 tp_assign(nr_rq
, depth
)
466 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
469 TP_printk("[%s] %d", __entry
->comm
, __entry
->nr_rq
)
473 * block_unplug - release of operations requests in request queue
474 * @q: request queue to unplug
475 * @depth: number of requests just added to the queue
476 * @explicit: whether this was an explicit unplug, or one from schedule()
478 * Unplug request queue @q because device driver is scheduled to work
479 * on elements in the request queue.
481 DEFINE_EVENT(block_unplug
, block_unplug
,
483 TP_PROTO(struct request_queue
*q
, unsigned int depth
, bool explicit),
485 TP_ARGS(q
, depth
, explicit)
489 * block_split - split a single bio struct into two bio structs
490 * @q: queue containing the bio
491 * @bio: block operation being split
492 * @new_sector: The starting sector for the new bio
494 * The bio request @bio in request queue @q needs to be split into two
495 * bio requests. The newly created @bio request starts at
496 * @new_sector. This split may be required due to hardware limitation
497 * such as operation crossing device boundaries in a RAID system.
499 TRACE_EVENT(block_split
,
501 TP_PROTO(struct request_queue
*q
, struct bio
*bio
,
502 unsigned int new_sector
),
504 TP_ARGS(q
, bio
, new_sector
),
507 __field( dev_t
, dev
)
508 __field( sector_t
, sector
)
509 __field( sector_t
, new_sector
)
510 __field( unsigned int, rwbs
)
511 __array_text( char, comm
, TASK_COMM_LEN
)
515 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
516 tp_assign(sector
, bio
->bi_sector
)
517 tp_assign(new_sector
, new_sector
)
518 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
519 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
522 TP_printk("%d,%d %s %llu / %llu [%s]",
523 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
524 __print_rwbs_flags(__entry
->rwbs
),
525 (unsigned long long)__entry
->sector
,
526 (unsigned long long)__entry
->new_sector
,
531 * block_bio_remap - map request for a logical device to the raw device
532 * @q: queue holding the operation
533 * @bio: revised operation
534 * @dev: device for the operation
535 * @from: original sector for the operation
537 * An operation for a logical device has been mapped to the
540 TRACE_EVENT(block_bio_remap
,
542 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, dev_t dev
,
545 TP_ARGS(q
, bio
, dev
, from
),
548 __field( dev_t
, dev
)
549 __field( sector_t
, sector
)
550 __field( unsigned int, nr_sector
)
551 __field( dev_t
, old_dev
)
552 __field( sector_t
, old_sector
)
553 __field( unsigned int, rwbs
)
557 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
558 tp_assign(sector
, bio
->bi_sector
)
559 tp_assign(nr_sector
, bio
->bi_size
>> 9)
560 tp_assign(old_dev
, dev
)
561 tp_assign(old_sector
, from
)
562 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
565 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
566 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
567 __print_rwbs_flags(__entry
->rwbs
),
568 (unsigned long long)__entry
->sector
,
570 MAJOR(__entry
->old_dev
), MINOR(__entry
->old_dev
),
571 (unsigned long long)__entry
->old_sector
)
575 * block_rq_remap - map request for a block operation request
576 * @q: queue holding the operation
577 * @rq: block IO operation request
578 * @dev: device for the operation
579 * @from: original sector for the operation
581 * The block operation request @rq in @q has been remapped. The block
582 * operation request @rq holds the current information and @from hold
583 * the original sector.
585 TRACE_EVENT(block_rq_remap
,
587 TP_PROTO(struct request_queue
*q
, struct request
*rq
, dev_t dev
,
590 TP_ARGS(q
, rq
, dev
, from
),
593 __field( dev_t
, dev
)
594 __field( sector_t
, sector
)
595 __field( unsigned int, nr_sector
)
596 __field( dev_t
, old_dev
)
597 __field( sector_t
, old_sector
)
598 __field( unsigned int, rwbs
)
602 tp_assign(dev
, disk_devt(rq
->rq_disk
))
603 tp_assign(sector
, blk_rq_pos(rq
))
604 tp_assign(nr_sector
, blk_rq_sectors(rq
))
605 tp_assign(old_dev
, dev
)
606 tp_assign(old_sector
, from
)
607 blk_fill_rwbs(rwbs
, rq
->cmd_flags
, blk_rq_bytes(rq
))
610 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
611 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
612 __print_rwbs_flags(__entry
->rwbs
),
613 (unsigned long long)__entry
->sector
,
615 MAJOR(__entry
->old_dev
), MINOR(__entry
->old_dev
),
616 (unsigned long long)__entry
->old_sector
)
619 #undef __print_rwbs_flags
622 #endif /* _TRACE_BLOCK_H */
624 /* This part must be outside protection */
625 #include "../../../probes/define_trace.h"
This page took 0.043567 seconds and 3 git commands to generate.