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/buffer_head.h>
10 #include <linux/tracepoint.h>
14 DECLARE_EVENT_CLASS(block_buffer
,
16 TP_PROTO(struct buffer_head
*bh
),
22 __field( sector_t
, sector
)
23 __field( size_t, size
)
27 __entry
->dev
= bh
->b_bdev
->bd_dev
;
28 __entry
->sector
= bh
->b_blocknr
;
29 __entry
->size
= bh
->b_size
;
32 TP_printk("%d,%d sector=%llu size=%zu",
33 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
34 (unsigned long long)__entry
->sector
, __entry
->size
39 * block_touch_buffer - mark a buffer accessed
40 * @bh: buffer_head being touched
42 * Called from touch_buffer().
44 DEFINE_EVENT(block_buffer
, block_touch_buffer
,
46 TP_PROTO(struct buffer_head
*bh
),
52 * block_dirty_buffer - mark a buffer dirty
53 * @bh: buffer_head being dirtied
55 * Called from mark_buffer_dirty().
57 DEFINE_EVENT(block_buffer
, block_dirty_buffer
,
59 TP_PROTO(struct buffer_head
*bh
),
64 DECLARE_EVENT_CLASS(block_rq_with_error
,
66 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
72 __field( sector_t
, sector
)
73 __field( unsigned int, nr_sector
)
74 __field( int, errors
)
75 __array( char, rwbs
, RWBS_LEN
)
76 __dynamic_array( char, cmd
, blk_cmd_buf_len(rq
) )
80 __entry
->dev
= rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0;
81 __entry
->sector
= (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
83 __entry
->nr_sector
= (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
84 0 : blk_rq_sectors(rq
);
85 __entry
->errors
= rq
->errors
;
87 blk_fill_rwbs(__entry
->rwbs
, req_op(rq
), rq
->cmd_flags
,
89 blk_dump_cmd(__get_str(cmd
), rq
);
92 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
93 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
94 __entry
->rwbs
, __get_str(cmd
),
95 (unsigned long long)__entry
->sector
,
96 __entry
->nr_sector
, __entry
->errors
)
100 * block_rq_abort - abort block operation request
101 * @q: queue containing the block operation request
102 * @rq: block IO operation request
104 * Called immediately after pending block IO operation request @rq in
105 * queue @q is aborted. The fields in the operation request @rq
106 * can be examined to determine which device and sectors the pending
107 * operation would access.
109 DEFINE_EVENT(block_rq_with_error
, block_rq_abort
,
111 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
117 * block_rq_requeue - place block IO request back on a queue
118 * @q: queue holding operation
119 * @rq: block IO operation request
121 * The block operation request @rq is being placed back into queue
122 * @q. For some reason the request was not completed and needs to be
123 * put back in the queue.
125 DEFINE_EVENT(block_rq_with_error
, block_rq_requeue
,
127 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
133 * block_rq_complete - block IO operation completed by device driver
134 * @q: queue containing the block operation request
135 * @rq: block operations request
136 * @nr_bytes: number of completed bytes
138 * The block_rq_complete tracepoint event indicates that some portion
139 * of operation request has been completed by the device driver. If
140 * the @rq->bio is %NULL, then there is absolutely no additional work to
141 * do for the request. If @rq->bio is non-NULL then there is
142 * additional work required to complete the request.
144 TRACE_EVENT(block_rq_complete
,
146 TP_PROTO(struct request_queue
*q
, struct request
*rq
,
147 unsigned int nr_bytes
),
149 TP_ARGS(q
, rq
, nr_bytes
),
152 __field( dev_t
, dev
)
153 __field( sector_t
, sector
)
154 __field( unsigned int, nr_sector
)
155 __field( int, errors
)
156 __array( char, rwbs
, RWBS_LEN
)
157 __dynamic_array( char, cmd
, blk_cmd_buf_len(rq
) )
161 __entry
->dev
= rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0;
162 __entry
->sector
= blk_rq_pos(rq
);
163 __entry
->nr_sector
= nr_bytes
>> 9;
164 __entry
->errors
= rq
->errors
;
166 blk_fill_rwbs(__entry
->rwbs
, req_op(rq
), rq
->cmd_flags
, nr_bytes
);
167 blk_dump_cmd(__get_str(cmd
), rq
);
170 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
171 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
172 __entry
->rwbs
, __get_str(cmd
),
173 (unsigned long long)__entry
->sector
,
174 __entry
->nr_sector
, __entry
->errors
)
177 DECLARE_EVENT_CLASS(block_rq
,
179 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
184 __field( dev_t
, dev
)
185 __field( sector_t
, sector
)
186 __field( unsigned int, nr_sector
)
187 __field( unsigned int, bytes
)
188 __array( char, rwbs
, RWBS_LEN
)
189 __array( char, comm
, TASK_COMM_LEN
)
190 __dynamic_array( char, cmd
, blk_cmd_buf_len(rq
) )
194 __entry
->dev
= rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0;
195 __entry
->sector
= (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
197 __entry
->nr_sector
= (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
198 0 : blk_rq_sectors(rq
);
199 __entry
->bytes
= (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
200 blk_rq_bytes(rq
) : 0;
202 blk_fill_rwbs(__entry
->rwbs
, req_op(rq
), rq
->cmd_flags
,
204 blk_dump_cmd(__get_str(cmd
), rq
);
205 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
208 TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
209 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
210 __entry
->rwbs
, __entry
->bytes
, __get_str(cmd
),
211 (unsigned long long)__entry
->sector
,
212 __entry
->nr_sector
, __entry
->comm
)
216 * block_rq_insert - insert block operation request into queue
218 * @rq: block IO operation request
220 * Called immediately before block operation request @rq is inserted
221 * into queue @q. The fields in the operation request @rq struct can
222 * be examined to determine which device and sectors the pending
223 * operation would access.
225 DEFINE_EVENT(block_rq
, block_rq_insert
,
227 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
233 * block_rq_issue - issue pending block IO request operation to device driver
234 * @q: queue holding operation
235 * @rq: block IO operation operation request
237 * Called when block operation request @rq from queue @q is sent to a
238 * device driver for processing.
240 DEFINE_EVENT(block_rq
, block_rq_issue
,
242 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
248 * block_bio_bounce - used bounce buffer when processing block operation
249 * @q: queue holding the block operation
250 * @bio: block operation
252 * A bounce buffer was used to handle the block operation @bio in @q.
253 * This occurs when hardware limitations prevent a direct transfer of
254 * data between the @bio data memory area and the IO device. Use of a
255 * bounce buffer requires extra copying of data and decreases
258 TRACE_EVENT(block_bio_bounce
,
260 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
265 __field( dev_t
, dev
)
266 __field( sector_t
, sector
)
267 __field( unsigned int, nr_sector
)
268 __array( char, rwbs
, RWBS_LEN
)
269 __array( char, comm
, TASK_COMM_LEN
)
273 __entry
->dev
= bio
->bi_bdev
?
274 bio
->bi_bdev
->bd_dev
: 0;
275 __entry
->sector
= bio
->bi_iter
.bi_sector
;
276 __entry
->nr_sector
= bio_sectors(bio
);
277 blk_fill_rwbs(__entry
->rwbs
, bio_op(bio
), bio
->bi_opf
,
278 bio
->bi_iter
.bi_size
);
279 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
282 TP_printk("%d,%d %s %llu + %u [%s]",
283 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->rwbs
,
284 (unsigned long long)__entry
->sector
,
285 __entry
->nr_sector
, __entry
->comm
)
289 * block_bio_complete - completed all work on the block operation
290 * @q: queue holding the block operation
291 * @bio: block operation completed
292 * @error: io error value
294 * This tracepoint indicates there is no further work to do on this
295 * block IO operation @bio.
297 TRACE_EVENT(block_bio_complete
,
299 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int error
),
301 TP_ARGS(q
, bio
, error
),
304 __field( dev_t
, dev
)
305 __field( sector_t
, sector
)
306 __field( unsigned, nr_sector
)
307 __field( int, error
)
308 __array( char, rwbs
, RWBS_LEN
)
312 __entry
->dev
= bio
->bi_bdev
->bd_dev
;
313 __entry
->sector
= bio
->bi_iter
.bi_sector
;
314 __entry
->nr_sector
= bio_sectors(bio
);
315 __entry
->error
= error
;
316 blk_fill_rwbs(__entry
->rwbs
, bio_op(bio
), bio
->bi_opf
,
317 bio
->bi_iter
.bi_size
);
320 TP_printk("%d,%d %s %llu + %u [%d]",
321 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->rwbs
,
322 (unsigned long long)__entry
->sector
,
323 __entry
->nr_sector
, __entry
->error
)
326 DECLARE_EVENT_CLASS(block_bio_merge
,
328 TP_PROTO(struct request_queue
*q
, struct request
*rq
, struct bio
*bio
),
333 __field( dev_t
, dev
)
334 __field( sector_t
, sector
)
335 __field( unsigned int, nr_sector
)
336 __array( char, rwbs
, RWBS_LEN
)
337 __array( char, comm
, TASK_COMM_LEN
)
341 __entry
->dev
= bio
->bi_bdev
->bd_dev
;
342 __entry
->sector
= bio
->bi_iter
.bi_sector
;
343 __entry
->nr_sector
= bio_sectors(bio
);
344 blk_fill_rwbs(__entry
->rwbs
, bio_op(bio
), bio
->bi_opf
,
345 bio
->bi_iter
.bi_size
);
346 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
349 TP_printk("%d,%d %s %llu + %u [%s]",
350 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->rwbs
,
351 (unsigned long long)__entry
->sector
,
352 __entry
->nr_sector
, __entry
->comm
)
356 * block_bio_backmerge - merging block operation to the end of an existing operation
357 * @q: queue holding operation
358 * @rq: request bio is being merged into
359 * @bio: new block operation to merge
361 * Merging block request @bio to the end of an existing block request
364 DEFINE_EVENT(block_bio_merge
, block_bio_backmerge
,
366 TP_PROTO(struct request_queue
*q
, struct request
*rq
, struct bio
*bio
),
372 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
373 * @q: queue holding operation
374 * @rq: request bio is being merged into
375 * @bio: new block operation to merge
377 * Merging block IO operation @bio to the beginning of an existing block
378 * operation in queue @q.
380 DEFINE_EVENT(block_bio_merge
, block_bio_frontmerge
,
382 TP_PROTO(struct request_queue
*q
, struct request
*rq
, struct bio
*bio
),
388 * block_bio_queue - putting new block IO operation in queue
389 * @q: queue holding operation
390 * @bio: new block operation
392 * About to place the block IO operation @bio into queue @q.
394 TRACE_EVENT(block_bio_queue
,
396 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
401 __field( dev_t
, dev
)
402 __field( sector_t
, sector
)
403 __field( unsigned int, nr_sector
)
404 __array( char, rwbs
, RWBS_LEN
)
405 __array( char, comm
, TASK_COMM_LEN
)
409 __entry
->dev
= bio
->bi_bdev
->bd_dev
;
410 __entry
->sector
= bio
->bi_iter
.bi_sector
;
411 __entry
->nr_sector
= bio_sectors(bio
);
412 blk_fill_rwbs(__entry
->rwbs
, bio_op(bio
), bio
->bi_opf
,
413 bio
->bi_iter
.bi_size
);
414 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
417 TP_printk("%d,%d %s %llu + %u [%s]",
418 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->rwbs
,
419 (unsigned long long)__entry
->sector
,
420 __entry
->nr_sector
, __entry
->comm
)
423 DECLARE_EVENT_CLASS(block_get_rq
,
425 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
430 __field( dev_t
, dev
)
431 __field( sector_t
, sector
)
432 __field( unsigned int, nr_sector
)
433 __array( char, rwbs
, RWBS_LEN
)
434 __array( char, comm
, TASK_COMM_LEN
)
438 __entry
->dev
= bio
? bio
->bi_bdev
->bd_dev
: 0;
439 __entry
->sector
= bio
? bio
->bi_iter
.bi_sector
: 0;
440 __entry
->nr_sector
= bio
? bio_sectors(bio
) : 0;
441 blk_fill_rwbs(__entry
->rwbs
, bio
? bio_op(bio
) : 0,
442 bio
? bio
->bi_opf
: 0, __entry
->nr_sector
);
443 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
446 TP_printk("%d,%d %s %llu + %u [%s]",
447 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->rwbs
,
448 (unsigned long long)__entry
->sector
,
449 __entry
->nr_sector
, __entry
->comm
)
453 * block_getrq - get a free request entry in queue for block IO operations
454 * @q: queue for operations
455 * @bio: pending block IO operation
456 * @rw: low bit indicates a read (%0) or a write (%1)
458 * A request struct for queue @q has been allocated to handle the
459 * block IO operation @bio.
461 DEFINE_EVENT(block_get_rq
, block_getrq
,
463 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
469 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
470 * @q: queue for operation
471 * @bio: pending block IO operation
472 * @rw: low bit indicates a read (%0) or a write (%1)
474 * In the case where a request struct cannot be provided for queue @q
475 * the process needs to wait for an request struct to become
476 * available. This tracepoint event is generated each time the
477 * process goes to sleep waiting for request struct become available.
479 DEFINE_EVENT(block_get_rq
, block_sleeprq
,
481 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
487 * block_plug - keep operations requests in request queue
488 * @q: request queue to plug
490 * Plug the request queue @q. Do not allow block operation requests
491 * to be sent to the device driver. Instead, accumulate requests in
492 * the queue to improve throughput performance of the block device.
494 TRACE_EVENT(block_plug
,
496 TP_PROTO(struct request_queue
*q
),
501 __array( char, comm
, TASK_COMM_LEN
)
505 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
508 TP_printk("[%s]", __entry
->comm
)
511 DECLARE_EVENT_CLASS(block_unplug
,
513 TP_PROTO(struct request_queue
*q
, unsigned int depth
, bool explicit),
515 TP_ARGS(q
, depth
, explicit),
518 __field( int, nr_rq
)
519 __array( char, comm
, TASK_COMM_LEN
)
523 __entry
->nr_rq
= depth
;
524 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
527 TP_printk("[%s] %d", __entry
->comm
, __entry
->nr_rq
)
531 * block_unplug - release of operations requests in request queue
532 * @q: request queue to unplug
533 * @depth: number of requests just added to the queue
534 * @explicit: whether this was an explicit unplug, or one from schedule()
536 * Unplug request queue @q because device driver is scheduled to work
537 * on elements in the request queue.
539 DEFINE_EVENT(block_unplug
, block_unplug
,
541 TP_PROTO(struct request_queue
*q
, unsigned int depth
, bool explicit),
543 TP_ARGS(q
, depth
, explicit)
547 * block_split - split a single bio struct into two bio structs
548 * @q: queue containing the bio
549 * @bio: block operation being split
550 * @new_sector: The starting sector for the new bio
552 * The bio request @bio in request queue @q needs to be split into two
553 * bio requests. The newly created @bio request starts at
554 * @new_sector. This split may be required due to hardware limitation
555 * such as operation crossing device boundaries in a RAID system.
557 TRACE_EVENT(block_split
,
559 TP_PROTO(struct request_queue
*q
, struct bio
*bio
,
560 unsigned int new_sector
),
562 TP_ARGS(q
, bio
, new_sector
),
565 __field( dev_t
, dev
)
566 __field( sector_t
, sector
)
567 __field( sector_t
, new_sector
)
568 __array( char, rwbs
, RWBS_LEN
)
569 __array( char, comm
, TASK_COMM_LEN
)
573 __entry
->dev
= bio
->bi_bdev
->bd_dev
;
574 __entry
->sector
= bio
->bi_iter
.bi_sector
;
575 __entry
->new_sector
= new_sector
;
576 blk_fill_rwbs(__entry
->rwbs
, bio_op(bio
), bio
->bi_opf
,
577 bio
->bi_iter
.bi_size
);
578 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
581 TP_printk("%d,%d %s %llu / %llu [%s]",
582 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->rwbs
,
583 (unsigned long long)__entry
->sector
,
584 (unsigned long long)__entry
->new_sector
,
589 * block_bio_remap - map request for a logical device to the raw device
590 * @q: queue holding the operation
591 * @bio: revised operation
592 * @dev: device for the operation
593 * @from: original sector for the operation
595 * An operation for a logical device has been mapped to the
598 TRACE_EVENT(block_bio_remap
,
600 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, dev_t dev
,
603 TP_ARGS(q
, bio
, dev
, from
),
606 __field( dev_t
, dev
)
607 __field( sector_t
, sector
)
608 __field( unsigned int, nr_sector
)
609 __field( dev_t
, old_dev
)
610 __field( sector_t
, old_sector
)
611 __array( char, rwbs
, RWBS_LEN
)
615 __entry
->dev
= bio
->bi_bdev
->bd_dev
;
616 __entry
->sector
= bio
->bi_iter
.bi_sector
;
617 __entry
->nr_sector
= bio_sectors(bio
);
618 __entry
->old_dev
= dev
;
619 __entry
->old_sector
= from
;
620 blk_fill_rwbs(__entry
->rwbs
, bio_op(bio
), bio
->bi_opf
,
621 bio
->bi_iter
.bi_size
);
624 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
625 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->rwbs
,
626 (unsigned long long)__entry
->sector
,
628 MAJOR(__entry
->old_dev
), MINOR(__entry
->old_dev
),
629 (unsigned long long)__entry
->old_sector
)
633 * block_rq_remap - map request for a block operation request
634 * @q: queue holding the operation
635 * @rq: block IO operation request
636 * @dev: device for the operation
637 * @from: original sector for the operation
639 * The block operation request @rq in @q has been remapped. The block
640 * operation request @rq holds the current information and @from hold
641 * the original sector.
643 TRACE_EVENT(block_rq_remap
,
645 TP_PROTO(struct request_queue
*q
, struct request
*rq
, dev_t dev
,
648 TP_ARGS(q
, rq
, dev
, from
),
651 __field( dev_t
, dev
)
652 __field( sector_t
, sector
)
653 __field( unsigned int, nr_sector
)
654 __field( dev_t
, old_dev
)
655 __field( sector_t
, old_sector
)
656 __field( unsigned int, nr_bios
)
657 __array( char, rwbs
, RWBS_LEN
)
661 __entry
->dev
= disk_devt(rq
->rq_disk
);
662 __entry
->sector
= blk_rq_pos(rq
);
663 __entry
->nr_sector
= blk_rq_sectors(rq
);
664 __entry
->old_dev
= dev
;
665 __entry
->old_sector
= from
;
666 __entry
->nr_bios
= blk_rq_count_bios(rq
);
667 blk_fill_rwbs(__entry
->rwbs
, req_op(rq
), rq
->cmd_flags
,
671 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
672 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->rwbs
,
673 (unsigned long long)__entry
->sector
,
675 MAJOR(__entry
->old_dev
), MINOR(__entry
->old_dev
),
676 (unsigned long long)__entry
->old_sector
, __entry
->nr_bios
)
679 #endif /* _TRACE_BLOCK_H */
681 /* This part must be outside protection */
682 #include <trace/define_trace.h>