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>
13 DECLARE_EVENT_CLASS(block_rq_with_error,
15 TP_PROTO(struct request_queue *q, struct request *rq),
21 __field( sector_t, sector )
22 __field( unsigned int, nr_sector )
23 __field( int, errors )
24 __array( char, rwbs, RWBS_LEN )
25 __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
29 __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
30 __entry->sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
32 __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
33 0 : blk_rq_sectors(rq);
34 __entry->errors = rq->errors;
36 blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
37 blk_dump_cmd(__get_str(cmd), rq);
40 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
41 MAJOR(__entry->dev), MINOR(__entry->dev),
42 __entry->rwbs, __get_str(cmd),
43 (unsigned long long)__entry->sector,
44 __entry->nr_sector, __entry->errors)
48 * block_rq_abort - abort block operation request
49 * @q: queue containing the block operation request
50 * @rq: block IO operation request
52 * Called immediately after pending block IO operation request @rq in
53 * queue @q is aborted. The fields in the operation request @rq
54 * can be examined to determine which device and sectors the pending
55 * operation would access.
57 DEFINE_EVENT(block_rq_with_error, block_rq_abort,
59 TP_PROTO(struct request_queue *q, struct request *rq),
65 * block_rq_requeue - place block IO request back on a queue
66 * @q: queue holding operation
67 * @rq: block IO operation request
69 * The block operation request @rq is being placed back into queue
70 * @q. For some reason the request was not completed and needs to be
71 * put back in the queue.
73 DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
75 TP_PROTO(struct request_queue *q, struct request *rq),
81 * block_rq_complete - block IO operation completed by device driver
82 * @q: queue containing the block operation request
83 * @rq: block operations request
84 * @nr_bytes: number of completed bytes
86 * The block_rq_complete tracepoint event indicates that some portion
87 * of operation request has been completed by the device driver. If
88 * the @rq->bio is %NULL, then there is absolutely no additional work to
89 * do for the request. If @rq->bio is non-NULL then there is
90 * additional work required to complete the request.
92 TRACE_EVENT(block_rq_complete,
94 TP_PROTO(struct request_queue *q, struct request *rq,
95 unsigned int nr_bytes),
97 TP_ARGS(q, rq, nr_bytes),
100 __field( dev_t, dev )
101 __field( sector_t, sector )
102 __field( unsigned int, nr_sector )
103 __field( int, errors )
104 __array( char, rwbs, RWBS_LEN )
105 __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
109 __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
110 __entry->sector = blk_rq_pos(rq);
111 __entry->nr_sector = nr_bytes >> 9;
112 __entry->errors = rq->errors;
114 blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, nr_bytes);
115 blk_dump_cmd(__get_str(cmd), rq);
118 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
119 MAJOR(__entry->dev), MINOR(__entry->dev),
120 __entry->rwbs, __get_str(cmd),
121 (unsigned long long)__entry->sector,
122 __entry->nr_sector, __entry->errors)
125 DECLARE_EVENT_CLASS(block_rq,
127 TP_PROTO(struct request_queue *q, struct request *rq),
132 __field( dev_t, dev )
133 __field( sector_t, sector )
134 __field( unsigned int, nr_sector )
135 __field( unsigned int, bytes )
136 __array( char, rwbs, RWBS_LEN )
137 __array( char, comm, TASK_COMM_LEN )
138 __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
142 __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
143 __entry->sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
145 __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
146 0 : blk_rq_sectors(rq);
147 __entry->bytes = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
148 blk_rq_bytes(rq) : 0;
150 blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
151 blk_dump_cmd(__get_str(cmd), rq);
152 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
155 TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
156 MAJOR(__entry->dev), MINOR(__entry->dev),
157 __entry->rwbs, __entry->bytes, __get_str(cmd),
158 (unsigned long long)__entry->sector,
159 __entry->nr_sector, __entry->comm)
163 * block_rq_insert - insert block operation request into queue
165 * @rq: block IO operation request
167 * Called immediately before block operation request @rq is inserted
168 * into queue @q. The fields in the operation request @rq struct can
169 * be examined to determine which device and sectors the pending
170 * operation would access.
172 DEFINE_EVENT(block_rq, block_rq_insert,
174 TP_PROTO(struct request_queue *q, struct request *rq),
180 * block_rq_issue - issue pending block IO request operation to device driver
181 * @q: queue holding operation
182 * @rq: block IO operation operation request
184 * Called when block operation request @rq from queue @q is sent to a
185 * device driver for processing.
187 DEFINE_EVENT(block_rq, block_rq_issue,
189 TP_PROTO(struct request_queue *q, struct request *rq),
195 * block_bio_bounce - used bounce buffer when processing block operation
196 * @q: queue holding the block operation
197 * @bio: block operation
199 * A bounce buffer was used to handle the block operation @bio in @q.
200 * This occurs when hardware limitations prevent a direct transfer of
201 * data between the @bio data memory area and the IO device. Use of a
202 * bounce buffer requires extra copying of data and decreases
205 TRACE_EVENT(block_bio_bounce,
207 TP_PROTO(struct request_queue *q, struct bio *bio),
212 __field( dev_t, dev )
213 __field( sector_t, sector )
214 __field( unsigned int, nr_sector )
215 __array( char, rwbs, RWBS_LEN )
216 __array( char, comm, TASK_COMM_LEN )
220 __entry->dev = bio->bi_bdev ?
221 bio->bi_bdev->bd_dev : 0;
222 __entry->sector = bio->bi_sector;
223 __entry->nr_sector = bio->bi_size >> 9;
224 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
225 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
228 TP_printk("%d,%d %s %llu + %u [%s]",
229 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
230 (unsigned long long)__entry->sector,
231 __entry->nr_sector, __entry->comm)
235 * block_bio_complete - completed all work on the block operation
236 * @q: queue holding the block operation
237 * @bio: block operation completed
238 * @error: io error value
240 * This tracepoint indicates there is no further work to do on this
241 * block IO operation @bio.
243 TRACE_EVENT(block_bio_complete,
245 TP_PROTO(struct request_queue *q, struct bio *bio, int error),
247 TP_ARGS(q, bio, error),
250 __field( dev_t, dev )
251 __field( sector_t, sector )
252 __field( unsigned, nr_sector )
253 __field( int, error )
254 __array( char, rwbs, RWBS_LEN)
258 __entry->dev = bio->bi_bdev->bd_dev;
259 __entry->sector = bio->bi_sector;
260 __entry->nr_sector = bio->bi_size >> 9;
261 __entry->error = error;
262 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
265 TP_printk("%d,%d %s %llu + %u [%d]",
266 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
267 (unsigned long long)__entry->sector,
268 __entry->nr_sector, __entry->error)
271 DECLARE_EVENT_CLASS(block_bio,
273 TP_PROTO(struct request_queue *q, struct bio *bio),
278 __field( dev_t, dev )
279 __field( sector_t, sector )
280 __field( unsigned int, nr_sector )
281 __array( char, rwbs, RWBS_LEN )
282 __array( char, comm, TASK_COMM_LEN )
286 __entry->dev = bio->bi_bdev->bd_dev;
287 __entry->sector = bio->bi_sector;
288 __entry->nr_sector = bio->bi_size >> 9;
289 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
290 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
293 TP_printk("%d,%d %s %llu + %u [%s]",
294 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
295 (unsigned long long)__entry->sector,
296 __entry->nr_sector, __entry->comm)
300 * block_bio_backmerge - merging block operation to the end of an existing operation
301 * @q: queue holding operation
302 * @bio: new block operation to merge
304 * Merging block request @bio to the end of an existing block request
307 DEFINE_EVENT(block_bio, block_bio_backmerge,
309 TP_PROTO(struct request_queue *q, struct bio *bio),
315 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
316 * @q: queue holding operation
317 * @bio: new block operation to merge
319 * Merging block IO operation @bio to the beginning of an existing block
320 * operation in queue @q.
322 DEFINE_EVENT(block_bio, block_bio_frontmerge,
324 TP_PROTO(struct request_queue *q, struct bio *bio),
330 * block_bio_queue - putting new block IO operation in queue
331 * @q: queue holding operation
332 * @bio: new block operation
334 * About to place the block IO operation @bio into queue @q.
336 DEFINE_EVENT(block_bio, block_bio_queue,
338 TP_PROTO(struct request_queue *q, struct bio *bio),
343 DECLARE_EVENT_CLASS(block_get_rq,
345 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
350 __field( dev_t, dev )
351 __field( sector_t, sector )
352 __field( unsigned int, nr_sector )
353 __array( char, rwbs, RWBS_LEN )
354 __array( char, comm, TASK_COMM_LEN )
358 __entry->dev = bio ? bio->bi_bdev->bd_dev : 0;
359 __entry->sector = bio ? bio->bi_sector : 0;
360 __entry->nr_sector = bio ? bio->bi_size >> 9 : 0;
361 blk_fill_rwbs(__entry->rwbs,
362 bio ? bio->bi_rw : 0, __entry->nr_sector);
363 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
366 TP_printk("%d,%d %s %llu + %u [%s]",
367 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
368 (unsigned long long)__entry->sector,
369 __entry->nr_sector, __entry->comm)
373 * block_getrq - get a free request entry in queue for block IO operations
374 * @q: queue for operations
375 * @bio: pending block IO operation
376 * @rw: low bit indicates a read (%0) or a write (%1)
378 * A request struct for queue @q has been allocated to handle the
379 * block IO operation @bio.
381 DEFINE_EVENT(block_get_rq, block_getrq,
383 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
389 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
390 * @q: queue for operation
391 * @bio: pending block IO operation
392 * @rw: low bit indicates a read (%0) or a write (%1)
394 * In the case where a request struct cannot be provided for queue @q
395 * the process needs to wait for an request struct to become
396 * available. This tracepoint event is generated each time the
397 * process goes to sleep waiting for request struct become available.
399 DEFINE_EVENT(block_get_rq, block_sleeprq,
401 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
407 * block_plug - keep operations requests in request queue
408 * @q: request queue to plug
410 * Plug the request queue @q. Do not allow block operation requests
411 * to be sent to the device driver. Instead, accumulate requests in
412 * the queue to improve throughput performance of the block device.
414 TRACE_EVENT(block_plug,
416 TP_PROTO(struct request_queue *q),
421 __array( char, comm, TASK_COMM_LEN )
425 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
428 TP_printk("[%s]", __entry->comm)
431 DECLARE_EVENT_CLASS(block_unplug,
433 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
435 TP_ARGS(q, depth, explicit),
438 __field( int, nr_rq )
439 __array( char, comm, TASK_COMM_LEN )
443 __entry->nr_rq = depth;
444 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
447 TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
451 * block_unplug - release of operations requests in request queue
452 * @q: request queue to unplug
453 * @depth: number of requests just added to the queue
454 * @explicit: whether this was an explicit unplug, or one from schedule()
456 * Unplug request queue @q because device driver is scheduled to work
457 * on elements in the request queue.
459 DEFINE_EVENT(block_unplug, block_unplug,
461 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
463 TP_ARGS(q, depth, explicit)
467 * block_split - split a single bio struct into two bio structs
468 * @q: queue containing the bio
469 * @bio: block operation being split
470 * @new_sector: The starting sector for the new bio
472 * The bio request @bio in request queue @q needs to be split into two
473 * bio requests. The newly created @bio request starts at
474 * @new_sector. This split may be required due to hardware limitation
475 * such as operation crossing device boundaries in a RAID system.
477 TRACE_EVENT(block_split,
479 TP_PROTO(struct request_queue *q, struct bio *bio,
480 unsigned int new_sector),
482 TP_ARGS(q, bio, new_sector),
485 __field( dev_t, dev )
486 __field( sector_t, sector )
487 __field( sector_t, new_sector )
488 __array( char, rwbs, RWBS_LEN )
489 __array( char, comm, TASK_COMM_LEN )
493 __entry->dev = bio->bi_bdev->bd_dev;
494 __entry->sector = bio->bi_sector;
495 __entry->new_sector = new_sector;
496 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
497 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
500 TP_printk("%d,%d %s %llu / %llu [%s]",
501 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
502 (unsigned long long)__entry->sector,
503 (unsigned long long)__entry->new_sector,
508 * block_bio_remap - map request for a logical device to the raw device
509 * @q: queue holding the operation
510 * @bio: revised operation
511 * @dev: device for the operation
512 * @from: original sector for the operation
514 * An operation for a logical device has been mapped to the
517 TRACE_EVENT(block_bio_remap,
519 TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
522 TP_ARGS(q, bio, dev, from),
525 __field( dev_t, dev )
526 __field( sector_t, sector )
527 __field( unsigned int, nr_sector )
528 __field( dev_t, old_dev )
529 __field( sector_t, old_sector )
530 __array( char, rwbs, RWBS_LEN)
534 __entry->dev = bio->bi_bdev->bd_dev;
535 __entry->sector = bio->bi_sector;
536 __entry->nr_sector = bio->bi_size >> 9;
537 __entry->old_dev = dev;
538 __entry->old_sector = from;
539 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
542 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
543 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
544 (unsigned long long)__entry->sector,
546 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
547 (unsigned long long)__entry->old_sector)
551 * block_rq_remap - map request for a block operation request
552 * @q: queue holding the operation
553 * @rq: block IO operation request
554 * @dev: device for the operation
555 * @from: original sector for the operation
557 * The block operation request @rq in @q has been remapped. The block
558 * operation request @rq holds the current information and @from hold
559 * the original sector.
561 TRACE_EVENT(block_rq_remap,
563 TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
566 TP_ARGS(q, rq, dev, from),
569 __field( dev_t, dev )
570 __field( sector_t, sector )
571 __field( unsigned int, nr_sector )
572 __field( dev_t, old_dev )
573 __field( sector_t, old_sector )
574 __array( char, rwbs, RWBS_LEN)
578 __entry->dev = disk_devt(rq->rq_disk);
579 __entry->sector = blk_rq_pos(rq);
580 __entry->nr_sector = blk_rq_sectors(rq);
581 __entry->old_dev = dev;
582 __entry->old_sector = from;
583 blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
586 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
587 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
588 (unsigned long long)__entry->sector,
590 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
591 (unsigned long long)__entry->old_sector)
594 #endif /* _TRACE_BLOCK_H */
596 /* This part must be outside protection */
597 #include <trace/define_trace.h>