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_text( char, cmd
, blk_cmd_buf_len(rq
) )
65 tp_assign(dev
, rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0)
66 tp_assign(sector
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
68 tp_assign(nr_sector
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
69 0 : blk_rq_sectors(rq
))
70 tp_assign(errors
, rq
->errors
)
71 blk_fill_rwbs(rwbs
, rq
->cmd_flags
, blk_rq_bytes(rq
))
72 tp_memcpy_dyn(cmd
, rq
->cmd
)
75 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
76 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
77 __print_rwbs_flags(__entry
->rwbs
),
78 __blk_dump_cmd(__get_dynamic_array(cmd
),
79 __get_dynamic_array_len(cmd
)),
80 (unsigned long long)__entry
->sector
,
81 __entry
->nr_sector
, __entry
->errors
)
85 * block_rq_abort - abort block operation request
86 * @q: queue containing the block operation request
87 * @rq: block IO operation request
89 * Called immediately after pending block IO operation request @rq in
90 * queue @q is aborted. The fields in the operation request @rq
91 * can be examined to determine which device and sectors the pending
92 * operation would access.
94 DEFINE_EVENT(block_rq_with_error
, block_rq_abort
,
96 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
102 * block_rq_requeue - place block IO request back on a queue
103 * @q: queue holding operation
104 * @rq: block IO operation request
106 * The block operation request @rq is being placed back into queue
107 * @q. For some reason the request was not completed and needs to be
108 * put back in the queue.
110 DEFINE_EVENT(block_rq_with_error
, block_rq_requeue
,
112 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
118 * block_rq_complete - block IO operation completed by device driver
119 * @q: queue containing the block operation request
120 * @rq: block operations request
122 * The block_rq_complete tracepoint event indicates that some portion
123 * of operation request has been completed by the device driver. If
124 * the @rq->bio is %NULL, then there is absolutely no additional work to
125 * do for the request. If @rq->bio is non-NULL then there is
126 * additional work required to complete the request.
128 DEFINE_EVENT(block_rq_with_error
, block_rq_complete
,
130 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
135 DECLARE_EVENT_CLASS(block_rq
,
137 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
142 __field( dev_t
, dev
)
143 __field( sector_t
, sector
)
144 __field( unsigned int, nr_sector
)
145 __field( unsigned int, bytes
)
146 __field( unsigned int, rwbs
)
147 __array_text( char, comm
, TASK_COMM_LEN
)
148 __dynamic_array_text( char, cmd
, blk_cmd_buf_len(rq
) )
152 tp_assign(dev
, rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0)
153 tp_assign(sector
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
155 tp_assign(nr_sector
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
156 0 : blk_rq_sectors(rq
))
157 tp_assign(bytes
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
158 blk_rq_bytes(rq
) : 0)
159 blk_fill_rwbs(rwbs
, rq
->cmd_flags
, blk_rq_bytes(rq
))
160 tp_memcpy_dyn(cmd
, rq
->cmd
)
161 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
164 TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
165 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
166 __print_rwbs_flags(__entry
->rwbs
),
168 __blk_dump_cmd(__get_dynamic_array(cmd
),
169 __get_dynamic_array_len(cmd
)),
170 (unsigned long long)__entry
->sector
,
171 __entry
->nr_sector
, __entry
->comm
)
175 * block_rq_insert - insert block operation request into queue
177 * @rq: block IO operation request
179 * Called immediately before block operation request @rq is inserted
180 * into queue @q. The fields in the operation request @rq struct can
181 * be examined to determine which device and sectors the pending
182 * operation would access.
184 DEFINE_EVENT(block_rq
, block_rq_insert
,
186 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
192 * block_rq_issue - issue pending block IO request operation to device driver
193 * @q: queue holding operation
194 * @rq: block IO operation operation request
196 * Called when block operation request @rq from queue @q is sent to a
197 * device driver for processing.
199 DEFINE_EVENT(block_rq
, block_rq_issue
,
201 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
207 * block_bio_bounce - used bounce buffer when processing block operation
208 * @q: queue holding the block operation
209 * @bio: block operation
211 * A bounce buffer was used to handle the block operation @bio in @q.
212 * This occurs when hardware limitations prevent a direct transfer of
213 * data between the @bio data memory area and the IO device. Use of a
214 * bounce buffer requires extra copying of data and decreases
217 TRACE_EVENT(block_bio_bounce
,
219 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
224 __field( dev_t
, dev
)
225 __field( sector_t
, sector
)
226 __field( unsigned int, nr_sector
)
227 __field( unsigned int, rwbs
)
228 __array_text( char, comm
, TASK_COMM_LEN
)
232 tp_assign(dev
, bio
->bi_bdev
?
233 bio
->bi_bdev
->bd_dev
: 0)
234 tp_assign(sector
, bio
->bi_sector
)
235 tp_assign(nr_sector
, bio
->bi_size
>> 9)
236 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
237 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
240 TP_printk("%d,%d %s %llu + %u [%s]",
241 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
242 __print_rwbs_flags(__entry
->rwbs
),
243 (unsigned long long)__entry
->sector
,
244 __entry
->nr_sector
, __entry
->comm
)
248 * block_bio_complete - completed all work on the block operation
249 * @q: queue holding the block operation
250 * @bio: block operation completed
251 * @error: io error value
253 * This tracepoint indicates there is no further work to do on this
254 * block IO operation @bio.
256 TRACE_EVENT(block_bio_complete
,
258 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int error
),
260 TP_ARGS(q
, bio
, error
),
263 __field( dev_t
, dev
)
264 __field( sector_t
, sector
)
265 __field( unsigned, nr_sector
)
266 __field( int, error
)
267 __field( unsigned int, rwbs
)
271 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
272 tp_assign(sector
, bio
->bi_sector
)
273 tp_assign(nr_sector
, bio
->bi_size
>> 9)
274 tp_assign(error
, error
)
275 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
278 TP_printk("%d,%d %s %llu + %u [%d]",
279 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
280 __print_rwbs_flags(__entry
->rwbs
),
281 (unsigned long long)__entry
->sector
,
282 __entry
->nr_sector
, __entry
->error
)
285 DECLARE_EVENT_CLASS(block_bio
,
287 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
292 __field( dev_t
, dev
)
293 __field( sector_t
, sector
)
294 __field( unsigned int, nr_sector
)
295 __field( unsigned int, rwbs
)
296 __array_text( char, comm
, TASK_COMM_LEN
)
300 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
301 tp_assign(sector
, bio
->bi_sector
)
302 tp_assign(nr_sector
, bio
->bi_size
>> 9)
303 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
304 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
307 TP_printk("%d,%d %s %llu + %u [%s]",
308 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
309 __print_rwbs_flags(__entry
->rwbs
),
310 (unsigned long long)__entry
->sector
,
311 __entry
->nr_sector
, __entry
->comm
)
315 * block_bio_backmerge - merging block operation to the end of an existing operation
316 * @q: queue holding operation
317 * @bio: new block operation to merge
319 * Merging block request @bio to the end of an existing block request
322 DEFINE_EVENT(block_bio
, block_bio_backmerge
,
324 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
330 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
331 * @q: queue holding operation
332 * @bio: new block operation to merge
334 * Merging block IO operation @bio to the beginning of an existing block
335 * operation in queue @q.
337 DEFINE_EVENT(block_bio
, block_bio_frontmerge
,
339 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
345 * block_bio_queue - putting new block IO operation in queue
346 * @q: queue holding operation
347 * @bio: new block operation
349 * About to place the block IO operation @bio into queue @q.
351 DEFINE_EVENT(block_bio
, block_bio_queue
,
353 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
358 DECLARE_EVENT_CLASS(block_get_rq
,
360 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
365 __field( dev_t
, dev
)
366 __field( sector_t
, sector
)
367 __field( unsigned int, nr_sector
)
368 __field( unsigned int, rwbs
)
369 __array_text( char, comm
, TASK_COMM_LEN
)
373 tp_assign(dev
, bio
? bio
->bi_bdev
->bd_dev
: 0)
374 tp_assign(sector
, bio
? bio
->bi_sector
: 0)
375 tp_assign(nr_sector
, bio
? bio
->bi_size
>> 9 : 0)
376 blk_fill_rwbs(rwbs
, bio
? bio
->bi_rw
: 0,
377 bio
? bio
->bi_size
>> 9 : 0)
378 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
381 TP_printk("%d,%d %s %llu + %u [%s]",
382 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
383 __print_rwbs_flags(__entry
->rwbs
),
384 (unsigned long long)__entry
->sector
,
385 __entry
->nr_sector
, __entry
->comm
)
389 * block_getrq - get a free request entry in queue for block IO operations
390 * @q: queue for operations
391 * @bio: pending block IO operation
392 * @rw: low bit indicates a read (%0) or a write (%1)
394 * A request struct for queue @q has been allocated to handle the
395 * block IO operation @bio.
397 DEFINE_EVENT(block_get_rq
, block_getrq
,
399 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
405 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
406 * @q: queue for operation
407 * @bio: pending block IO operation
408 * @rw: low bit indicates a read (%0) or a write (%1)
410 * In the case where a request struct cannot be provided for queue @q
411 * the process needs to wait for an request struct to become
412 * available. This tracepoint event is generated each time the
413 * process goes to sleep waiting for request struct become available.
415 DEFINE_EVENT(block_get_rq
, block_sleeprq
,
417 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
423 * block_plug - keep operations requests in request queue
424 * @q: request queue to plug
426 * Plug the request queue @q. Do not allow block operation requests
427 * to be sent to the device driver. Instead, accumulate requests in
428 * the queue to improve throughput performance of the block device.
430 TRACE_EVENT(block_plug
,
432 TP_PROTO(struct request_queue
*q
),
437 __array_text( char, comm
, TASK_COMM_LEN
)
441 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
444 TP_printk("[%s]", __entry
->comm
)
447 DECLARE_EVENT_CLASS(block_unplug
,
449 TP_PROTO(struct request_queue
*q
, unsigned int depth
, bool explicit),
451 TP_ARGS(q
, depth
, explicit),
454 __field( int, nr_rq
)
455 __array_text( char, comm
, TASK_COMM_LEN
)
459 tp_assign(nr_rq
, depth
)
460 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
463 TP_printk("[%s] %d", __entry
->comm
, __entry
->nr_rq
)
467 * block_unplug - release of operations requests in request queue
468 * @q: request queue to unplug
469 * @depth: number of requests just added to the queue
470 * @explicit: whether this was an explicit unplug, or one from schedule()
472 * Unplug request queue @q because device driver is scheduled to work
473 * on elements in the request queue.
475 DEFINE_EVENT(block_unplug
, block_unplug
,
477 TP_PROTO(struct request_queue
*q
, unsigned int depth
, bool explicit),
479 TP_ARGS(q
, depth
, explicit)
483 * block_split - split a single bio struct into two bio structs
484 * @q: queue containing the bio
485 * @bio: block operation being split
486 * @new_sector: The starting sector for the new bio
488 * The bio request @bio in request queue @q needs to be split into two
489 * bio requests. The newly created @bio request starts at
490 * @new_sector. This split may be required due to hardware limitation
491 * such as operation crossing device boundaries in a RAID system.
493 TRACE_EVENT(block_split
,
495 TP_PROTO(struct request_queue
*q
, struct bio
*bio
,
496 unsigned int new_sector
),
498 TP_ARGS(q
, bio
, new_sector
),
501 __field( dev_t
, dev
)
502 __field( sector_t
, sector
)
503 __field( sector_t
, new_sector
)
504 __field( unsigned int, rwbs
)
505 __array_text( char, comm
, TASK_COMM_LEN
)
509 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
510 tp_assign(sector
, bio
->bi_sector
)
511 tp_assign(new_sector
, new_sector
)
512 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
513 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
516 TP_printk("%d,%d %s %llu / %llu [%s]",
517 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
518 __print_rwbs_flags(__entry
->rwbs
),
519 (unsigned long long)__entry
->sector
,
520 (unsigned long long)__entry
->new_sector
,
525 * block_bio_remap - map request for a logical device to the raw device
526 * @q: queue holding the operation
527 * @bio: revised operation
528 * @dev: device for the operation
529 * @from: original sector for the operation
531 * An operation for a logical device has been mapped to the
534 TRACE_EVENT(block_bio_remap
,
536 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, dev_t dev
,
539 TP_ARGS(q
, bio
, dev
, from
),
542 __field( dev_t
, dev
)
543 __field( sector_t
, sector
)
544 __field( unsigned int, nr_sector
)
545 __field( dev_t
, old_dev
)
546 __field( sector_t
, old_sector
)
547 __field( unsigned int, rwbs
)
551 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
552 tp_assign(sector
, bio
->bi_sector
)
553 tp_assign(nr_sector
, bio
->bi_size
>> 9)
554 tp_assign(old_dev
, dev
)
555 tp_assign(old_sector
, from
)
556 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
559 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
560 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
561 __print_rwbs_flags(__entry
->rwbs
),
562 (unsigned long long)__entry
->sector
,
564 MAJOR(__entry
->old_dev
), MINOR(__entry
->old_dev
),
565 (unsigned long long)__entry
->old_sector
)
569 * block_rq_remap - map request for a block operation request
570 * @q: queue holding the operation
571 * @rq: block IO operation request
572 * @dev: device for the operation
573 * @from: original sector for the operation
575 * The block operation request @rq in @q has been remapped. The block
576 * operation request @rq holds the current information and @from hold
577 * the original sector.
579 TRACE_EVENT(block_rq_remap
,
581 TP_PROTO(struct request_queue
*q
, struct request
*rq
, dev_t dev
,
584 TP_ARGS(q
, rq
, dev
, from
),
587 __field( dev_t
, dev
)
588 __field( sector_t
, sector
)
589 __field( unsigned int, nr_sector
)
590 __field( dev_t
, old_dev
)
591 __field( sector_t
, old_sector
)
592 __field( unsigned int, rwbs
)
596 tp_assign(dev
, disk_devt(rq
->rq_disk
))
597 tp_assign(sector
, blk_rq_pos(rq
))
598 tp_assign(nr_sector
, blk_rq_sectors(rq
))
599 tp_assign(old_dev
, dev
)
600 tp_assign(old_sector
, from
)
601 blk_fill_rwbs(rwbs
, rq
->cmd_flags
, blk_rq_bytes(rq
))
604 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
605 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
606 __print_rwbs_flags(__entry
->rwbs
),
607 (unsigned long long)__entry
->sector
,
609 MAJOR(__entry
->old_dev
), MINOR(__entry
->old_dev
),
610 (unsigned long long)__entry
->old_sector
)
613 #undef __print_rwbs_flags
616 #endif /* _TRACE_BLOCK_H */
618 /* This part must be outside protection */
619 #include "../../../probes/define_trace.h"
This page took 0.042599 seconds and 4 git commands to generate.