eddfaab922f35ecb60b08f038181b5bb502767a3
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_type
== REQ_TYPE_BLOCK_PC
) ?
73 rq
->cmd
: (unsigned char *) "");
76 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
77 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
78 __print_rwbs_flags(__entry
->rwbs
),
79 __blk_dump_cmd(__get_dynamic_array(cmd
),
80 __get_dynamic_array_len(cmd
)),
81 (unsigned long long)__entry
->sector
,
82 __entry
->nr_sector
, __entry
->errors
)
86 * block_rq_abort - abort block operation request
87 * @q: queue containing the block operation request
88 * @rq: block IO operation request
90 * Called immediately after pending block IO operation request @rq in
91 * queue @q is aborted. The fields in the operation request @rq
92 * can be examined to determine which device and sectors the pending
93 * operation would access.
95 DEFINE_EVENT(block_rq_with_error
, block_rq_abort
,
97 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
103 * block_rq_requeue - place block IO request back on a queue
104 * @q: queue holding operation
105 * @rq: block IO operation request
107 * The block operation request @rq is being placed back into queue
108 * @q. For some reason the request was not completed and needs to be
109 * put back in the queue.
111 DEFINE_EVENT(block_rq_with_error
, block_rq_requeue
,
113 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
119 * block_rq_complete - block IO operation completed by device driver
120 * @q: queue containing the block operation request
121 * @rq: block operations request
123 * The block_rq_complete tracepoint event indicates that some portion
124 * of operation request has been completed by the device driver. If
125 * the @rq->bio is %NULL, then there is absolutely no additional work to
126 * do for the request. If @rq->bio is non-NULL then there is
127 * additional work required to complete the request.
129 DEFINE_EVENT(block_rq_with_error
, block_rq_complete
,
131 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
136 DECLARE_EVENT_CLASS(block_rq
,
138 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
143 __field( dev_t
, dev
)
144 __field( sector_t
, sector
)
145 __field( unsigned int, nr_sector
)
146 __field( unsigned int, bytes
)
147 __field( unsigned int, rwbs
)
148 __array_text( char, comm
, TASK_COMM_LEN
)
149 __dynamic_array_text( char, cmd
, blk_cmd_buf_len(rq
) )
153 tp_assign(dev
, rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0)
154 tp_assign(sector
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
156 tp_assign(nr_sector
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
157 0 : blk_rq_sectors(rq
))
158 tp_assign(bytes
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
159 blk_rq_bytes(rq
) : 0)
160 blk_fill_rwbs(rwbs
, rq
->cmd_flags
, blk_rq_bytes(rq
))
161 tp_memcpy_dyn(cmd
, (rq
->cmd_type
== REQ_TYPE_BLOCK_PC
) ?
162 rq
->cmd
: (unsigned char *) "");
163 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
166 TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
167 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
168 __print_rwbs_flags(__entry
->rwbs
),
170 __blk_dump_cmd(__get_dynamic_array(cmd
),
171 __get_dynamic_array_len(cmd
)),
172 (unsigned long long)__entry
->sector
,
173 __entry
->nr_sector
, __entry
->comm
)
177 * block_rq_insert - insert block operation request into queue
179 * @rq: block IO operation request
181 * Called immediately before block operation request @rq is inserted
182 * into queue @q. The fields in the operation request @rq struct can
183 * be examined to determine which device and sectors the pending
184 * operation would access.
186 DEFINE_EVENT(block_rq
, block_rq_insert
,
188 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
194 * block_rq_issue - issue pending block IO request operation to device driver
195 * @q: queue holding operation
196 * @rq: block IO operation operation request
198 * Called when block operation request @rq from queue @q is sent to a
199 * device driver for processing.
201 DEFINE_EVENT(block_rq
, block_rq_issue
,
203 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
209 * block_bio_bounce - used bounce buffer when processing block operation
210 * @q: queue holding the block operation
211 * @bio: block operation
213 * A bounce buffer was used to handle the block operation @bio in @q.
214 * This occurs when hardware limitations prevent a direct transfer of
215 * data between the @bio data memory area and the IO device. Use of a
216 * bounce buffer requires extra copying of data and decreases
219 TRACE_EVENT(block_bio_bounce
,
221 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
226 __field( dev_t
, dev
)
227 __field( sector_t
, sector
)
228 __field( unsigned int, nr_sector
)
229 __field( unsigned int, rwbs
)
230 __array_text( char, comm
, TASK_COMM_LEN
)
234 tp_assign(dev
, bio
->bi_bdev
?
235 bio
->bi_bdev
->bd_dev
: 0)
236 tp_assign(sector
, bio
->bi_sector
)
237 tp_assign(nr_sector
, bio
->bi_size
>> 9)
238 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
239 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
242 TP_printk("%d,%d %s %llu + %u [%s]",
243 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
244 __print_rwbs_flags(__entry
->rwbs
),
245 (unsigned long long)__entry
->sector
,
246 __entry
->nr_sector
, __entry
->comm
)
250 * block_bio_complete - completed all work on the block operation
251 * @q: queue holding the block operation
252 * @bio: block operation completed
253 * @error: io error value
255 * This tracepoint indicates there is no further work to do on this
256 * block IO operation @bio.
258 TRACE_EVENT(block_bio_complete
,
260 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int error
),
262 TP_ARGS(q
, bio
, error
),
265 __field( dev_t
, dev
)
266 __field( sector_t
, sector
)
267 __field( unsigned, nr_sector
)
268 __field( int, error
)
269 __field( unsigned int, rwbs
)
273 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
274 tp_assign(sector
, bio
->bi_sector
)
275 tp_assign(nr_sector
, bio
->bi_size
>> 9)
276 tp_assign(error
, error
)
277 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
280 TP_printk("%d,%d %s %llu + %u [%d]",
281 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
282 __print_rwbs_flags(__entry
->rwbs
),
283 (unsigned long long)__entry
->sector
,
284 __entry
->nr_sector
, __entry
->error
)
287 DECLARE_EVENT_CLASS(block_bio
,
289 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
294 __field( dev_t
, dev
)
295 __field( sector_t
, sector
)
296 __field( unsigned int, nr_sector
)
297 __field( unsigned int, rwbs
)
298 __array_text( char, comm
, TASK_COMM_LEN
)
302 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
303 tp_assign(sector
, bio
->bi_sector
)
304 tp_assign(nr_sector
, bio
->bi_size
>> 9)
305 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
306 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
309 TP_printk("%d,%d %s %llu + %u [%s]",
310 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
311 __print_rwbs_flags(__entry
->rwbs
),
312 (unsigned long long)__entry
->sector
,
313 __entry
->nr_sector
, __entry
->comm
)
317 * block_bio_backmerge - merging block operation to the end of an existing operation
318 * @q: queue holding operation
319 * @bio: new block operation to merge
321 * Merging block request @bio to the end of an existing block request
324 DEFINE_EVENT(block_bio
, block_bio_backmerge
,
326 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
332 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
333 * @q: queue holding operation
334 * @bio: new block operation to merge
336 * Merging block IO operation @bio to the beginning of an existing block
337 * operation in queue @q.
339 DEFINE_EVENT(block_bio
, block_bio_frontmerge
,
341 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
347 * block_bio_queue - putting new block IO operation in queue
348 * @q: queue holding operation
349 * @bio: new block operation
351 * About to place the block IO operation @bio into queue @q.
353 DEFINE_EVENT(block_bio
, block_bio_queue
,
355 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
360 DECLARE_EVENT_CLASS(block_get_rq
,
362 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
367 __field( dev_t
, dev
)
368 __field( sector_t
, sector
)
369 __field( unsigned int, nr_sector
)
370 __field( unsigned int, rwbs
)
371 __array_text( char, comm
, TASK_COMM_LEN
)
375 tp_assign(dev
, bio
? bio
->bi_bdev
->bd_dev
: 0)
376 tp_assign(sector
, bio
? bio
->bi_sector
: 0)
377 tp_assign(nr_sector
, bio
? bio
->bi_size
>> 9 : 0)
378 blk_fill_rwbs(rwbs
, bio
? bio
->bi_rw
: 0,
379 bio
? bio
->bi_size
>> 9 : 0)
380 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
383 TP_printk("%d,%d %s %llu + %u [%s]",
384 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
385 __print_rwbs_flags(__entry
->rwbs
),
386 (unsigned long long)__entry
->sector
,
387 __entry
->nr_sector
, __entry
->comm
)
391 * block_getrq - get a free request entry in queue for block IO operations
392 * @q: queue for operations
393 * @bio: pending block IO operation
394 * @rw: low bit indicates a read (%0) or a write (%1)
396 * A request struct for queue @q has been allocated to handle the
397 * block IO operation @bio.
399 DEFINE_EVENT(block_get_rq
, block_getrq
,
401 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
407 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
408 * @q: queue for operation
409 * @bio: pending block IO operation
410 * @rw: low bit indicates a read (%0) or a write (%1)
412 * In the case where a request struct cannot be provided for queue @q
413 * the process needs to wait for an request struct to become
414 * available. This tracepoint event is generated each time the
415 * process goes to sleep waiting for request struct become available.
417 DEFINE_EVENT(block_get_rq
, block_sleeprq
,
419 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
425 * block_plug - keep operations requests in request queue
426 * @q: request queue to plug
428 * Plug the request queue @q. Do not allow block operation requests
429 * to be sent to the device driver. Instead, accumulate requests in
430 * the queue to improve throughput performance of the block device.
432 TRACE_EVENT(block_plug
,
434 TP_PROTO(struct request_queue
*q
),
439 __array_text( char, comm
, TASK_COMM_LEN
)
443 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
446 TP_printk("[%s]", __entry
->comm
)
449 DECLARE_EVENT_CLASS(block_unplug
,
451 TP_PROTO(struct request_queue
*q
, unsigned int depth
, bool explicit),
453 TP_ARGS(q
, depth
, explicit),
456 __field( int, nr_rq
)
457 __array_text( char, comm
, TASK_COMM_LEN
)
461 tp_assign(nr_rq
, depth
)
462 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
465 TP_printk("[%s] %d", __entry
->comm
, __entry
->nr_rq
)
469 * block_unplug - release of operations requests in request queue
470 * @q: request queue to unplug
471 * @depth: number of requests just added to the queue
472 * @explicit: whether this was an explicit unplug, or one from schedule()
474 * Unplug request queue @q because device driver is scheduled to work
475 * on elements in the request queue.
477 DEFINE_EVENT(block_unplug
, block_unplug
,
479 TP_PROTO(struct request_queue
*q
, unsigned int depth
, bool explicit),
481 TP_ARGS(q
, depth
, explicit)
485 * block_split - split a single bio struct into two bio structs
486 * @q: queue containing the bio
487 * @bio: block operation being split
488 * @new_sector: The starting sector for the new bio
490 * The bio request @bio in request queue @q needs to be split into two
491 * bio requests. The newly created @bio request starts at
492 * @new_sector. This split may be required due to hardware limitation
493 * such as operation crossing device boundaries in a RAID system.
495 TRACE_EVENT(block_split
,
497 TP_PROTO(struct request_queue
*q
, struct bio
*bio
,
498 unsigned int new_sector
),
500 TP_ARGS(q
, bio
, new_sector
),
503 __field( dev_t
, dev
)
504 __field( sector_t
, sector
)
505 __field( sector_t
, new_sector
)
506 __field( unsigned int, rwbs
)
507 __array_text( char, comm
, TASK_COMM_LEN
)
511 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
512 tp_assign(sector
, bio
->bi_sector
)
513 tp_assign(new_sector
, new_sector
)
514 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
515 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
518 TP_printk("%d,%d %s %llu / %llu [%s]",
519 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
520 __print_rwbs_flags(__entry
->rwbs
),
521 (unsigned long long)__entry
->sector
,
522 (unsigned long long)__entry
->new_sector
,
527 * block_bio_remap - map request for a logical device to the raw device
528 * @q: queue holding the operation
529 * @bio: revised operation
530 * @dev: device for the operation
531 * @from: original sector for the operation
533 * An operation for a logical device has been mapped to the
536 TRACE_EVENT(block_bio_remap
,
538 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, dev_t dev
,
541 TP_ARGS(q
, bio
, dev
, from
),
544 __field( dev_t
, dev
)
545 __field( sector_t
, sector
)
546 __field( unsigned int, nr_sector
)
547 __field( dev_t
, old_dev
)
548 __field( sector_t
, old_sector
)
549 __field( unsigned int, rwbs
)
553 tp_assign(dev
, bio
->bi_bdev
->bd_dev
)
554 tp_assign(sector
, bio
->bi_sector
)
555 tp_assign(nr_sector
, bio
->bi_size
>> 9)
556 tp_assign(old_dev
, dev
)
557 tp_assign(old_sector
, from
)
558 blk_fill_rwbs(rwbs
, bio
->bi_rw
, bio
->bi_size
)
561 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
562 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
563 __print_rwbs_flags(__entry
->rwbs
),
564 (unsigned long long)__entry
->sector
,
566 MAJOR(__entry
->old_dev
), MINOR(__entry
->old_dev
),
567 (unsigned long long)__entry
->old_sector
)
571 * block_rq_remap - map request for a block operation request
572 * @q: queue holding the operation
573 * @rq: block IO operation request
574 * @dev: device for the operation
575 * @from: original sector for the operation
577 * The block operation request @rq in @q has been remapped. The block
578 * operation request @rq holds the current information and @from hold
579 * the original sector.
581 TRACE_EVENT(block_rq_remap
,
583 TP_PROTO(struct request_queue
*q
, struct request
*rq
, dev_t dev
,
586 TP_ARGS(q
, rq
, dev
, from
),
589 __field( dev_t
, dev
)
590 __field( sector_t
, sector
)
591 __field( unsigned int, nr_sector
)
592 __field( dev_t
, old_dev
)
593 __field( sector_t
, old_sector
)
594 __field( unsigned int, rwbs
)
598 tp_assign(dev
, disk_devt(rq
->rq_disk
))
599 tp_assign(sector
, blk_rq_pos(rq
))
600 tp_assign(nr_sector
, blk_rq_sectors(rq
))
601 tp_assign(old_dev
, dev
)
602 tp_assign(old_sector
, from
)
603 blk_fill_rwbs(rwbs
, rq
->cmd_flags
, blk_rq_bytes(rq
))
606 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
607 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
608 __print_rwbs_flags(__entry
->rwbs
),
609 (unsigned long long)__entry
->sector
,
611 MAJOR(__entry
->old_dev
), MINOR(__entry
->old_dev
),
612 (unsigned long long)__entry
->old_sector
)
615 #undef __print_rwbs_flags
618 #endif /* _TRACE_BLOCK_H */
620 /* This part must be outside protection */
621 #include "../../../probes/define_trace.h"
This page took 0.043518 seconds and 5 git commands to generate.